summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authoranton <anton@cvs.openbsd.org>2019-08-05 08:46:47 +0000
committeranton <anton@cvs.openbsd.org>2019-08-05 08:46:47 +0000
commitd4bf2e261eb4d86f50acdc7a40fc250d7e756370 (patch)
treecb5a01c0b1b2250ab2695b5e03707ab07bbbb0a1 /sys
parentcc2844b7bc7b5fbb8d9aa42d7aad949f62fef7ec (diff)
Favor vn_close() in the error path of diskmapioctl() since side-effects
caused by calling vn_open() with write permissions must be reverted. Otherwise, the vfs subsystem could panic while releasing the last vnode reference if the writecount is still positive. ok visa@ Reported-by: syzbot+4724df09d9ab0fdca28a@syzkaller.appspotmail.com Reported-by: syzbot+a430606fd528645559db@syzkaller.appspotmail.com
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/diskmap.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/sys/dev/diskmap.c b/sys/dev/diskmap.c
index 33a533f0a19..e035ee36466 100644
--- a/sys/dev/diskmap.c
+++ b/sys/dev/diskmap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: diskmap.c,v 1.24 2018/08/20 14:59:02 visa Exp $ */
+/* $OpenBSD: diskmap.c,v 1.25 2019/08/05 08:46:46 anton Exp $ */
/*
* Copyright (c) 2009, 2010 Joel Sing <jsing@openbsd.org>
@@ -135,9 +135,7 @@ diskmapioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct proc *p)
bad:
fdpunlock(fdp);
-
- if (vp)
- vrele(vp);
+ (void)vn_close(vp, fp0->f_flag, p->p_ucred, p);
invalid:
if (fp0)
FRELE(fp0, p);