aboutsummaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorSuleiman Souhlal <ssouhlal@FreeBSD.org>2005-08-06 01:42:04 +0000
committerSuleiman Souhlal <ssouhlal@FreeBSD.org>2005-08-06 01:42:04 +0000
commit34cc826ae8999f454dd6cb9c77d17ce83b169f92 (patch)
tree2c62ba83632019391b20d5a85bd35d5065c6f434 /sys
parent1446d11a9b6d4387bccad67611ca94fd795605ba (diff)
downloadsrc-34cc826ae8999f454dd6cb9c77d17ce83b169f92.tar.gz
src-34cc826ae8999f454dd6cb9c77d17ce83b169f92.zip
Holding a vnode doesn't prevent v_mount from disappearing (when the
vnode is inactivated), possibly leading to a NULL dereference when checking if the mount wants knotes to be activated in the VOP hooks. So, we add a new vnode flag VV_NOKNOTE that is only set in getnewvnode(), if necessary, and check it when activating knotes. Since the flags are not erased when a vnode is being held, we can safely read them. Reviewed by: kris@ MFC after: 3 days
Notes
Notes: svn path=/head/; revision=148768
Diffstat (limited to 'sys')
-rw-r--r--sys/kern/vfs_subr.c2
-rw-r--r--sys/sys/mount.h6
-rw-r--r--sys/sys/vnode.h1
3 files changed, 5 insertions, 4 deletions
diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c
index fd2dd20c4ece..af6cbb092820 100644
--- a/sys/kern/vfs_subr.c
+++ b/sys/kern/vfs_subr.c
@@ -896,6 +896,8 @@ getnewvnode(tag, mp, vops, vpp)
if (mp != NULL) {
insmntque(vp, mp);
bo->bo_bsize = mp->mnt_stat.f_iosize;
+ if ((mp->mnt_kern_flag & MNTK_NOKNOTE) != 0)
+ vp->v_vflag |= VV_NOKNOTE;
}
CTR2(KTR_VFS, "getnewvnode: mp %p vp %p", mp, vp);
diff --git a/sys/sys/mount.h b/sys/sys/mount.h
index c70347cf9871..6cc890986e8c 100644
--- a/sys/sys/mount.h
+++ b/sys/sys/mount.h
@@ -552,15 +552,13 @@ extern int mpsafe_vfs;
#define VFS_KNOTE_LOCKED(vp, hint) do \
{ \
- if ((vp)->v_mount && \
- ((vp)->v_mount->mnt_kern_flag & MNTK_NOKNOTE) == 0) \
+ if (((vp)->v_vflag & VV_NOKNOTE) == 0) \
VN_KNOTE((vp), (hint), 1); \
} while (0)
#define VFS_KNOTE_UNLOCKED(vp, hint) do \
{ \
- if ((vp)->v_mount && \
- ((vp)->v_mount->mnt_kern_flag & MNTK_NOKNOTE) == 0) \
+ if (((vp)->v_vflag & VV_NOKNOTE) == 0) \
VN_KNOTE((vp), (hint), 0); \
} while (0)
diff --git a/sys/sys/vnode.h b/sys/sys/vnode.h
index f27be249cf29..98b234879129 100644
--- a/sys/sys/vnode.h
+++ b/sys/sys/vnode.h
@@ -251,6 +251,7 @@ struct xvnode {
#define VV_COPYONWRITE 0x0040 /* vnode is doing copy-on-write */
#define VV_SYSTEM 0x0080 /* vnode being used by kernel */
#define VV_PROCDEP 0x0100 /* vnode is process dependent */
+#define VV_NOKNOTE 0x0200 /* don't activate knotes on this vnode */
/*
* Vnode attributes. A field value of VNOVAL represents a field whose value