summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoranton <anton@openbsd.org>2018-07-03 12:58:18 +0000
committeranton <anton@openbsd.org>2018-07-03 12:58:18 +0000
commitc0699e5ad0a715e2ac33136d290401755f533f7d (patch)
tree4b6bb846def9a7ec3834d0fa68f803ab278883d9
parentTighten up description of echo-client-id statement (diff)
downloadwireguard-openbsd-c0699e5ad0a715e2ac33136d290401755f533f7d.tar.xz
wireguard-openbsd-c0699e5ad0a715e2ac33136d290401755f533f7d.zip
Avoid NULL pointer deref in vn_writechk() when calling ftruncate() on a file
descriptor belonging to a cloned device. ok kettenis@
-rw-r--r--sys/kern/vfs_vnops.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/sys/kern/vfs_vnops.c b/sys/kern/vfs_vnops.c
index 03fe499734c..2dbc93adba4 100644
--- a/sys/kern/vfs_vnops.c
+++ b/sys/kern/vfs_vnops.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vfs_vnops.c,v 1.93 2018/06/07 13:37:27 visa Exp $ */
+/* $OpenBSD: vfs_vnops.c,v 1.94 2018/07/03 12:58:18 anton Exp $ */
/* $NetBSD: vfs_vnops.c,v 1.20 1996/02/04 02:18:41 christos Exp $ */
/*
@@ -205,7 +205,7 @@ vn_writechk(struct vnode *vp)
* unless the file is a socket or a block or character
* device resident on the file system.
*/
- if (vp->v_mount->mnt_flag & MNT_RDONLY) {
+ if (vp->v_mount && (vp->v_mount->mnt_flag & MNT_RDONLY)) {
switch (vp->v_type) {
case VREG:
case VDIR: