From nobody Fri Jun 17 19:39:03 2022 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 5906B85B973; Fri, 17 Jun 2022 19:39:04 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4LPq9M6Y8Xz3R1g; Fri, 17 Jun 2022 19:39:03 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1655494744; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=YYBSx0HT+YSL66Krsd/6F/qlfPWtfYaCWkci+0F0ZHA=; b=Jq/IphML+/poogpV8ISIvhoNdncksrlU4xPzPn9eC+rMQuXSi4LWfuQbfo5HasEdeUFcio cp7e+fXAB25HrC+W5o3BgUKblYjiiYmc8M4FrgWrkkdUy7DoEoU+YdSx28+qeCd3PQ4IEu x8bGcbD1CgFrktCkvug7JGXEGwpOEizfU3iTbUwU2n9ISn9tLMOcyC4f3tT5Qmeq9u9q2f WdAItPEz2SQzOoUd00qIH7fxv185x5oWHblA28MvVz303uFGp+N+jAIAQIlBuroifas47D YUeINitkZEzOobxDa/baWBX9cE3q9JIFZk9Mo70XgEbhmyAKX5A8hXUTDCyq2w== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id BF71B25D8A; Fri, 17 Jun 2022 19:39:03 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 25HJd3jT015505; Fri, 17 Jun 2022 19:39:03 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 25HJd32s015504; Fri, 17 Jun 2022 19:39:03 GMT (envelope-from git) Date: Fri, 17 Jun 2022 19:39:03 GMT Message-Id: <202206171939.25HJd32s015504@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Dmitry Chagin Subject: git: d33fba34ab19 - stable/13 - linux(4): Prevent an attempt to copy an uninitialized source address. List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dchagin X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: d33fba34ab195d7d8bb5a8daabdad39ec7d9f4c4 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1655494744; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=YYBSx0HT+YSL66Krsd/6F/qlfPWtfYaCWkci+0F0ZHA=; b=B0fiWanuWjtRAGWjXq5tcr9V36BEtxFTsUL1mCo4HuWTZbvkh83OtKUgvFjx0kp9wAOOi+ 4ywqFGQL97qcX5aRTd35e/Xcm2eup5sfwnqJxO3UipLKH6FcEsh7llrRt2PULjiolmlNhw L92CBo12PUtqedDPwqfs2VMUlgxy1PwSeVEqQmW+C0723tjkT7NX3kdD9jYJH9L2LFso6h rf83kY3C5Hq/R4DKnPofZeMHDVHjg846RYkTTYlZG9V1SqGN0d7BPJEETMMlCrLLMKOexq w17b7LDxBg+WAyrxJALIjMeJHAWNTuTVhq+tKQ8VuKsT7x2/7hHLsAjk6W+QOg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1655494744; a=rsa-sha256; cv=none; b=azckwYgNPvCxzPTQHV3Tvu4gTk8rKeSXym3i/cjfn9zTf1+WcCUufLVcXTSogzgCzWZeHe mL505nBGD3HB/JUfuH3VSvR0jursFVZJ+Ci57DoKrzraHvAheAbkL1fVsGCxbfc/d6vblR i5E4+l4TfjS44TNXeK9lD1fetkXNQGDLEbEX+7ozWkeTkVzNIzTioENTiXuCumo098dAk9 kvaM+PCsfU3G5DAg2pRGYHvPsvnfwe5XHdHNsLt4b2X0WiLzocabO+YzQhvKXS6NChFSXR 0UMxBpIFPfgVaEJO4KXg0ta/H3x/KDaQhU6wd+GjsbGE2LPDodxpYF8yQmVh2g== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by dchagin: URL: https://cgit.FreeBSD.org/src/commit/?id=d33fba34ab195d7d8bb5a8daabdad39ec7d9f4c4 commit d33fba34ab195d7d8bb5a8daabdad39ec7d9f4c4 Author: Dmitry Chagin AuthorDate: 2022-04-11 20:29:45 +0000 Commit: Dmitry Chagin CommitDate: 2022-06-17 19:33:50 +0000 linux(4): Prevent an attempt to copy an uninitialized source address. PR: 259380 MFC after: 3 days (cherry picked from commit bb46e9b5107fd8763742f7e55b66ea2e574f5815) --- sys/compat/linux/linux_socket.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/sys/compat/linux/linux_socket.c b/sys/compat/linux/linux_socket.c index 453a6621d9a7..935d07ecb7e0 100644 --- a/sys/compat/linux/linux_socket.c +++ b/sys/compat/linux/linux_socket.c @@ -1289,8 +1289,16 @@ linux_recvfrom(struct thread *td, struct linux_recvfrom_args *args) if (error != 0) goto out; - if (PTRIN(args->from) != NULL) - error = linux_copyout_sockaddr(sa, PTRIN(args->from), msg.msg_namelen); + /* + * XXX. Seems that FreeBSD is different from Linux here. Linux + * fill source address if underlying protocol provides it, while + * FreeBSD fill it if underlying protocol is not connection-oriented. + * So, kern_recvit() set msg.msg_namelen to 0 if protocol pr_flags + * does not contains PR_ADDR flag. + */ + if (PTRIN(args->from) != NULL && msg.msg_namelen != 0) + error = linux_copyout_sockaddr(sa, PTRIN(args->from), + msg.msg_namelen); if (error == 0 && PTRIN(args->fromlen) != NULL) error = copyout(&msg.msg_namelen, PTRIN(args->fromlen),