Source-Changes-HG archive

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

[src/trunk]: src/sys/kern In bwrite, add assertion that vp != NULL. (vp is th...



details:   https://anonhg.NetBSD.org/src/rev/7c7e2cff5241
branches:  trunk
changeset: 816879:7c7e2cff5241
user:      dholland <dholland%NetBSD.org@localhost>
date:      Sun Jul 31 04:05:32 2016 +0000

description:
In bwrite, add assertion that vp != NULL. (vp is the vnode from the
buffer being written.)

There's some logic here that carefully checks for vp being null, and
other logic that will crash if it is. It appears that it's all
needless paranoia. See tech-kern for more info.

Unless someone sees the assertion go off (in which case a lot more
investigation is needed) I or someone will clean out the logic at some
future point.

Spotted by coypu.

diffstat:

 sys/kern/vfs_bio.c |  12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)

diffs (33 lines):

diff -r fff3faf4b595 -r 7c7e2cff5241 sys/kern/vfs_bio.c
--- a/sys/kern/vfs_bio.c        Sun Jul 31 02:15:54 2016 +0000
+++ b/sys/kern/vfs_bio.c        Sun Jul 31 04:05:32 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vfs_bio.c,v 1.259 2016/02/01 05:05:43 riz Exp $        */
+/*     $NetBSD: vfs_bio.c,v 1.260 2016/07/31 04:05:32 dholland Exp $   */
 
 /*-
  * Copyright (c) 2007, 2008, 2009 The NetBSD Foundation, Inc.
@@ -123,7 +123,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_bio.c,v 1.259 2016/02/01 05:05:43 riz Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_bio.c,v 1.260 2016/07/31 04:05:32 dholland Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_bufcache.h"
@@ -800,6 +800,14 @@
        KASSERT(!cv_has_waiters(&bp->b_done));
 
        vp = bp->b_vp;
+
+       /*
+        * dholland 20160728 AFAICT vp==NULL must be impossible as it
+        * will crash upon reaching VOP_STRATEGY below... see further
+        * analysis on tech-kern.
+        */
+       KASSERTMSG(vp != NULL, "bwrite given buffer with null vnode");
+
        if (vp != NULL) {
                KASSERT(bp->b_objlock == vp->v_interlock);
                if (vp->v_type == VBLK)



Home | Main Index | Thread Index | Old Index