Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 19 May 2021 13:35:23 GMT
From:      Mark Johnston <markj@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 4a6c5c8f592f - stable/13 - swap_pager: Zero swap info before exporting to userspace
Message-ID:  <202105191335.14JDZNGT074637@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by markj:

URL: https://cgit.FreeBSD.org/src/commit/?id=4a6c5c8f592f320bd72616836239b765f042b323

commit 4a6c5c8f592f320bd72616836239b765f042b323
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2021-05-12 13:42:44 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
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;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202105191335.14JDZNGT074637>