Module Name: src
Committed By: martin
Date: Thu Feb 27 18:55:05 UTC 2020
Modified Files:
src/sys/ufs/ufs [netbsd-9]: ufs_vnops.c
Log Message:
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.
To generate a diff of this commit:
cvs rdiff -u -r1.247 -r1.247.2.1 src/sys/ufs/ufs/ufs_vnops.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/ufs/ufs/ufs_vnops.c
diff -u src/sys/ufs/ufs/ufs_vnops.c:1.247 src/sys/ufs/ufs/ufs_vnops.c:1.247.2.1
--- src/sys/ufs/ufs/ufs_vnops.c:1.247 Mon Jul 1 00:57:06 2019
+++ src/sys/ufs/ufs/ufs_vnops.c Thu Feb 27 18:55:05 2020
@@ -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 @@ ufs_whiteout(void *v)
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);