From owner-dev-commits-src-branches@freebsd.org Wed May 19 13:35:23 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 54B9F641F6C; Wed, 19 May 2021 13:35:23 +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 4FlYlb1sRcz4gkP; Wed, 19 May 2021 13:35:23 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 2750D13BA6; Wed, 19 May 2021 13:35:23 +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 14JDZN9J074638; Wed, 19 May 2021 13:35:23 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14JDZNGT074637; Wed, 19 May 2021 13:35:23 GMT (envelope-from git) Date: Wed, 19 May 2021 13:35:23 GMT Message-Id: <202105191335.14JDZNGT074637@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: 4a6c5c8f592f - stable/13 - swap_pager: Zero swap info before exporting to userspace MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 4a6c5c8f592f320bd72616836239b765f042b323 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 19 May 2021 13:35:23 -0000 The branch stable/13 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=4a6c5c8f592f320bd72616836239b765f042b323 commit 4a6c5c8f592f320bd72616836239b765f042b323 Author: Mark Johnston AuthorDate: 2021-05-12 13:42:44 +0000 Commit: Mark Johnston CommitDate: 2021-05-19 13:32:18 +0000 swap_pager: Zero swap info before exporting to userspace Otherwise padding bytes are leaked. Reported by: KMSAN Sponsored by: The FreeBSD Foundation (cherry picked from commit 06d1fd9f42fa9c060fad8f3a71fcaada3baaf200) --- sys/vm/swap_pager.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sys/vm/swap_pager.c b/sys/vm/swap_pager.c index 888df04741b4..f7cde181a7c4 100644 --- a/sys/vm/swap_pager.c +++ b/sys/vm/swap_pager.c @@ -2668,11 +2668,14 @@ sysctl_vm_swap_info(SYSCTL_HANDLER_ARGS) if (arg2 != 1) /* name length */ return (EINVAL); + + memset(&xs, 0, sizeof(xs)); error = swap_dev_info(*(int *)arg1, &xs, NULL, 0); if (error != 0) return (error); #if defined(__amd64__) && defined(COMPAT_FREEBSD32) if (req->oldlen == sizeof(xs32)) { + memset(&xs32, 0, sizeof(xs32)); xs32.xsw_version = XSWDEV_VERSION; xs32.xsw_dev1 = xs.xsw_dev; xs32.xsw_dev2 = xs.xsw_dev >> 32; @@ -2685,6 +2688,7 @@ sysctl_vm_swap_info(SYSCTL_HANDLER_ARGS) #endif #if defined(COMPAT_FREEBSD11) if (req->oldlen == sizeof(xs11)) { + memset(&xs11, 0, sizeof(xs11)); xs11.xsw_version = XSWDEV_VERSION_11; xs11.xsw_dev = xs.xsw_dev; /* truncation */ xs11.xsw_flags = xs.xsw_flags;