summaryrefslogtreecommitdiffstats
path: root/sys/miscfs
diff options
context:
space:
mode:
authormpi <mpi@openbsd.org>2018-07-05 15:34:25 +0000
committermpi <mpi@openbsd.org>2018-07-05 15:34:25 +0000
commit63849fffc6c05fbb04077fd5cce1fbb659d2d493 (patch)
treed14b8cb5d055194e659d2bff95e62918354c4bbd /sys/miscfs
parentregen (diff)
downloadwireguard-openbsd-63849fffc6c05fbb04077fd5cce1fbb659d2d493.tar.xz
wireguard-openbsd-63849fffc6c05fbb04077fd5cce1fbb659d2d493.zip
Do not leak memory and a fp reference when !root passes `allow_other'.
Fix CID 1470236. ok helg@
Diffstat (limited to 'sys/miscfs')
-rw-r--r--sys/miscfs/fuse/fuse_vfsops.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/sys/miscfs/fuse/fuse_vfsops.c b/sys/miscfs/fuse/fuse_vfsops.c
index 486c50476ed..24bf23f4f82 100644
--- a/sys/miscfs/fuse/fuse_vfsops.c
+++ b/sys/miscfs/fuse/fuse_vfsops.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: fuse_vfsops.c,v 1.39 2018/06/25 12:03:53 helg Exp $ */
+/* $OpenBSD: fuse_vfsops.c,v 1.40 2018/07/05 15:34:25 mpi Exp $ */
/*
* Copyright (c) 2012-2013 Sylvestre Gallon <ccna.syl@gmail.com>
*
@@ -98,6 +98,10 @@ fusefs_mount(struct mount *mp, const char *path, void *data,
goto bad;
}
+ /* Only root may specify allow_other. */
+ if (args->allow_other && (error = suser_ucred(p->p_ucred)))
+ goto bad;
+
fmp = malloc(sizeof(*fmp), M_FUSEFS, M_WAITOK | M_ZERO);
fmp->mp = mp;
fmp->sess_init = PENDING;
@@ -107,9 +111,6 @@ fusefs_mount(struct mount *mp, const char *path, void *data,
else
fmp->max_read = FUSEBUFMAXSIZE;
- /* Only root may specify allow_other. */
- if (args->allow_other && (error = suser_ucred(p->p_ucred)))
- return (error);
fmp->allow_other = args->allow_other;
mp->mnt_data = fmp;