Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-8]: src/sys/ufs/ufs Pull up following revision(s) (requested by m...



details:   https://anonhg.NetBSD.org/src/rev/e78fa285bea1
branches:  netbsd-8
changeset: 852750:e78fa285bea1
user:      martin <martin%NetBSD.org@localhost>
date:      Thu Feb 27 14:41:05 2020 +0000

description:
Pull up following revision(s) (requested by maxv in ticket #1511):

        sys/ufs/ufs/ufs_vnops.c: revision 1.249

Zero out the padding in 'd_namlen', to prevent info leaks. Same logic as
ufs_makedirentry().

Found by kMSan: the unzeroed bytes of the pool_cache were getting copied
to the disk via a DMA write operation, and there kMSan was noticing
uninitialized memory leaving the system.

diffstat:

 sys/ufs/ufs/ufs_vnops.c |  10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)

diffs (31 lines):

diff -r 76e2bdd06d36 -r e78fa285bea1 sys/ufs/ufs/ufs_vnops.c
--- a/sys/ufs/ufs/ufs_vnops.c   Thu Feb 27 14:34:11 2020 +0000
+++ b/sys/ufs/ufs/ufs_vnops.c   Thu Feb 27 14:41:05 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ufs_vnops.c,v 1.237.4.1 2017/11/02 21:29:53 snj Exp $  */
+/*     $NetBSD: ufs_vnops.c,v 1.237.4.2 2020/02/27 14:41:05 martin Exp $       */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -66,7 +66,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ufs_vnops.c,v 1.237.4.1 2017/11/02 21:29:53 snj Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ufs_vnops.c,v 1.237.4.2 2020/02/27 14:41:05 martin Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_ffs.h"
@@ -873,7 +873,11 @@
                newdir->d_namlen = cnp->cn_namelen;
                memcpy(newdir->d_name, cnp->cn_nameptr,
                    (size_t)cnp->cn_namelen);
-               newdir->d_name[cnp->cn_namelen] = '\0';
+
+               /* NUL terminate and zero out padding */
+               memset(&newdir->d_name[cnp->cn_namelen], 0,
+                   UFS_NAMEPAD(cnp->cn_namelen));
+
                newdir->d_type = DT_WHT;
                error = ufs_direnter(dvp, ulr, NULL, newdir, cnp, NULL);
                pool_cache_put(ufs_direct_cache, newdir);



Home | Main Index | Thread Index | Old Index