From 31d4eb94b0ffbfdd02141dc2a7527f2d61926589 Mon Sep 17 00:00:00 2001 From: beck Date: Mon, 30 Jul 2018 00:16:59 +0000 Subject: [PATCH] Allow for us to do a CREATE style lookup on a read only filesystem if and only if we are unveil doing it. Fixes an issue noticed by kn@ where unveil would fail with EROFS on a read only filesystem --- sys/kern/vfs_lookup.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/sys/kern/vfs_lookup.c b/sys/kern/vfs_lookup.c index 484889c7cd2..efda601ea0d 100644 --- a/sys/kern/vfs_lookup.c +++ b/sys/kern/vfs_lookup.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vfs_lookup.c,v 1.71 2018/07/13 09:25:23 beck Exp $ */ +/* $OpenBSD: vfs_lookup.c,v 1.72 2018/07/30 00:16:59 beck Exp $ */ /* $NetBSD: vfs_lookup.c,v 1.17 1996/02/09 19:00:59 christos Exp $ */ /* @@ -558,11 +558,13 @@ dirloop: } /* * If creating and at end of pathname, then can consider - * allowing file to be created. + * allowing file to be created. Check for a read only + * filesystem and disallow this unless we are unveil'ing */ - if (rdonly || (ndp->ni_dvp->v_mount->mnt_flag & MNT_RDONLY)) { - error = EROFS; - goto bad; + if (ndp->ni_pledge != PLEDGE_UNVEIL && (rdonly || + (ndp->ni_dvp->v_mount->mnt_flag & MNT_RDONLY))) { + error = EROFS; + goto bad; } /* * We return with ni_vp NULL to indicate that the entry -- 2.20.1