Source-Changes-HG archive

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

[src/trunk]: src/sys/kern Inline the block in the parent block, for clarity, ...



details:   https://anonhg.NetBSD.org/src/rev/c8a128afd68c
branches:  trunk
changeset: 745055:c8a128afd68c
user:      maxv <maxv%NetBSD.org@localhost>
date:      Sat Feb 22 08:58:39 2020 +0000

description:
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.

diffstat:

 sys/kern/vfs_syscalls.c |  12 +++++++-----
 1 files changed, 7 insertions(+), 5 deletions(-)

diffs (34 lines):

diff -r 71740ddde4a6 -r c8a128afd68c sys/kern/vfs_syscalls.c
--- a/sys/kern/vfs_syscalls.c   Sat Feb 22 08:39:33 2020 +0000
+++ b/sys/kern/vfs_syscalls.c   Sat Feb 22 08:58:39 2020 +0000
@@ -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 @@
                        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:



Home | Main Index | Thread Index | Old Index