Module Name: src
Committed By: maxv
Date: Sat Feb 22 08:58:39 UTC 2020
Modified Files:
src/sys/kern: vfs_syscalls.c
Log Message:
Inline the block in the parent block, for clarity, and also to prevent a
false positive with kMSan.
Here, LLVM reorders the conditions and checks 'vattr' before 'error'. But
if 'error' is non-zero then 'vattr' is not initialized, and kMSan notices
the uninitialized memory read.
To generate a diff of this commit:
cvs rdiff -u -r1.540 -r1.541 src/sys/kern/vfs_syscalls.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/kern/vfs_syscalls.c
diff -u src/sys/kern/vfs_syscalls.c:1.540 src/sys/kern/vfs_syscalls.c:1.541
--- src/sys/kern/vfs_syscalls.c:1.540 Fri Jan 17 20:08:09 2020
+++ src/sys/kern/vfs_syscalls.c Sat Feb 22 08:58:39 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: vfs_syscalls.c,v 1.540 2020/01/17 20:08:09 ad Exp $ */
+/* $NetBSD: vfs_syscalls.c,v 1.541 2020/02/22 08:58:39 maxv Exp $ */
/*-
* Copyright (c) 2008, 2009, 2019 The NetBSD Foundation, Inc.
@@ -70,7 +70,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls.c,v 1.540 2020/01/17 20:08:09 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls.c,v 1.541 2020/02/22 08:58:39 maxv Exp $");
#ifdef _KERNEL_OPT
#include "opt_fileassoc.h"
@@ -2286,10 +2286,12 @@ do_sys_mknodat(struct lwp *l, int fdat,
error = EINVAL;
break;
}
+
+ if (error == 0 && optype == VOP_MKNOD_DESCOFFSET &&
+ vattr.va_rdev == VNOVAL)
+ error = EINVAL;
}
- if (error == 0 && optype == VOP_MKNOD_DESCOFFSET
- && vattr.va_rdev == VNOVAL)
- error = EINVAL;
+
if (!error) {
switch (optype) {
case VOP_WHITEOUT_DESCOFFSET: