Allow for us to do a CREATE style lookup on a read only filesystem
authorbeck <beck@openbsd.org>
Mon, 30 Jul 2018 00:16:59 +0000 (00:16 +0000)
committerbeck <beck@openbsd.org>
Mon, 30 Jul 2018 00:16:59 +0000 (00:16 +0000)
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

index 484889c..efda601 100644 (file)
@@ -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