From nobody Mon Apr 11 20:30:07 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 16A9811DEF8D; Mon, 11 Apr 2022 20:30:08 +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 4KcgTC6XGNz3Pdd; Mon, 11 Apr 2022 20:30:07 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1649709007; 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=dk5F0tsDE3tmB0IZ90/6VWqss4vG7gNDqEGq/Mdt2jk=; b=SuU7P7Vygs9NWNoEFmdLMl0fbQ/KNmTpOPkYkmKuURHiefHS5qqiJAOyENns651xdkXpl/ MbbsnLjcNR9VBz6fE/SOUBKpaBjjSss73A0UzqXD5Xve988eZIleJkwCc07s5Rl6s55DQ6 wzseOdXJB3g3hHmqtHeBMxi83Y0ZkQGy7GRFmlsDC1cMxD9NPLbSdhOc7AF8Hjicee/o6U klaKLjE0FtI89x/VdlY9W/mQX0u7OQAr1tXo58ZWLgoYsauZ/gvg372pixg87d6/0VP1q3 3vpWSyhqjMXwqyTbKZcS4suDdDEUPj3JTbThviBz+DqbK75+32VzU4qwV01Mgg== 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 C066B1AA3; Mon, 11 Apr 2022 20:30:07 +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 23BKU7lK072773; Mon, 11 Apr 2022 20:30:07 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 23BKU7bv072770; Mon, 11 Apr 2022 20:30:07 GMT (envelope-from git) Date: Mon, 11 Apr 2022 20:30:07 GMT Message-Id: <202204112030.23BKU7bv072770@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Dmitry Chagin Subject: git: bb46e9b5107f - main - 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/main X-Git-Reftype: branch X-Git-Commit: bb46e9b5107fd8763742f7e55b66ea2e574f5815 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1649709007; 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=dk5F0tsDE3tmB0IZ90/6VWqss4vG7gNDqEGq/Mdt2jk=; b=K7KZGTnRM3l68ZKVlaYifQHuAJY1FyycNe9UpRc0pGxixhvESi3bvfh9BWSQoYKxP8uvnR dXLPoUUOLe0O53BeDIarI2UX7gIgb92OdP5sbs5eeetn8jzZ/8xcjvbPvEm0e5BQ/LeGLu 5SgWOLmaLlDglxhV5CHuTfHPY7t1Yc2zJc71zp7xOwjEj5lQvI/NEl7W53chqDcFPsRgCy tSq9LO5Jll3kw9gWKQ73HFPVn0E2ZPaVnazXCEzT0FPcPWpnENiJygOX0AhSvn6UmiUUAK j9rG8bAurpiuX3CvRk+Guur4tBjAfAh5j2wcHlrEQP0pUy5R6/+Gfx5b1xRl4Q== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1649709007; a=rsa-sha256; cv=none; b=b5e6bdbZN5t6ZCRMf0Sn3Z5akyaAFXK0plPSlnEs5yY7I6m29uhKVv+DRAoORfH1px3y3A evxwfY6fka2gwiPsJOUhCFngH4wn+jQgHB13d2z2Oi/3FIl1ny4PkAg7/JL4/RnRMO+Lmf rC5BmHFZtodS3EgdA9AKv1P1TgflkUiHd9qp0FL74gHHTWdWERL/P8HmnaFeYYx2LcpFnW LYJmFjfEnzKp419tkGNAFraW/IGNe/gRWoAeBaS0NdOm9wjj+4fF4HtixFWp/NHwZoXRgY Vq5I89muxuOX7W4bf6s/QhM3mQtYEDPwEPvIfL6F5VnHmk2SNRp6H842vkf33A== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by dchagin: URL: https://cgit.FreeBSD.org/src/commit/?id=bb46e9b5107fd8763742f7e55b66ea2e574f5815 commit bb46e9b5107fd8763742f7e55b66ea2e574f5815 Author: Dmitry Chagin AuthorDate: 2022-04-11 20:29:45 +0000 Commit: Dmitry Chagin CommitDate: 2022-04-11 20:29:45 +0000 linux(4): Prevent an attempt to copy an uninitialized source address. PR: 259380 MFC after: 3 days --- 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),