Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 12 May 2021 17:09:33 GMT
From:      Mark Johnston <markj@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 06d1fd9f42fa - main - swap_pager: Zero swap info before exporting to userspace
Message-ID:  <202105121709.14CH9Xug031730@gitrepo.freebsd.org>

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

URL: https://cgit.FreeBSD.org/src/commit/?id=06d1fd9f42fa9c060fad8f3a71fcaada3baaf200

commit 06d1fd9f42fa9c060fad8f3a71fcaada3baaf200
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2021-05-12 13:42:44 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2021-05-12 16:52:05 +0000

    swap_pager: Zero swap info before exporting to userspace
    
    Otherwise padding bytes are leaked.
    
    Reported by:    KMSAN
    MFC after:      1 week
    Sponsored by:   The FreeBSD Foundation
---
 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 b0b0b41d2148..57c953542a88 100644
--- a/sys/vm/swap_pager.c
+++ b/sys/vm/swap_pager.c
@@ -2706,11 +2706,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;
@@ -2723,6 +2726,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?202105121709.14CH9Xug031730>