Source-Changes-HG archive

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

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



details:   https://anonhg.NetBSD.org/src/rev/37b9bc7c20f8
branches:  netbsd-9
changeset: 745299:37b9bc7c20f8
user:      martin <martin%NetBSD.org@localhost>
date:      Thu Feb 27 18:55:05 2020 +0000

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

        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 5f3ef947ab0d -r 37b9bc7c20f8 sys/ufs/ufs/ufs_vnops.c
--- a/sys/ufs/ufs/ufs_vnops.c   Thu Feb 27 18:53:04 2020 +0000
+++ b/sys/ufs/ufs/ufs_vnops.c   Thu Feb 27 18:55:05 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ufs_vnops.c,v 1.247 2019/07/01 00:57:06 dholland Exp $ */
+/*     $NetBSD: ufs_vnops.c,v 1.247.2.1 2020/02/27 18:55: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.247 2019/07/01 00:57:06 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ufs_vnops.c,v 1.247.2.1 2020/02/27 18:55: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