From owner-freebsd-bugs@FreeBSD.ORG Wed Sep 1 22:50:02 2010 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E173B10656B3 for ; Wed, 1 Sep 2010 22:50:01 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id A409A8FC17 for ; Wed, 1 Sep 2010 22:50:01 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.4/8.14.4) with ESMTP id o81Mo1NA024793 for ; Wed, 1 Sep 2010 22:50:01 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.4/8.14.4/Submit) id o81Mo1YW024792; Wed, 1 Sep 2010 22:50:01 GMT (envelope-from gnats) Resent-Date: Wed, 1 Sep 2010 22:50:01 GMT Resent-Message-Id: <201009012250.o81Mo1YW024792@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Aurelien Jarno Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id DE043106566C for ; Wed, 1 Sep 2010 22:40:35 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21]) by mx1.freebsd.org (Postfix) with ESMTP id CC9578FC12 for ; Wed, 1 Sep 2010 22:40:35 +0000 (UTC) Received: from www.freebsd.org (localhost [127.0.0.1]) by www.freebsd.org (8.14.3/8.14.3) with ESMTP id o81MeZNt051128 for ; Wed, 1 Sep 2010 22:40:35 GMT (envelope-from nobody@www.freebsd.org) Received: (from nobody@localhost) by www.freebsd.org (8.14.3/8.14.3/Submit) id o81MeZ9L051127; Wed, 1 Sep 2010 22:40:35 GMT (envelope-from nobody) Message-Id: <201009012240.o81MeZ9L051127@www.freebsd.org> Date: Wed, 1 Sep 2010 22:40:35 GMT From: Aurelien Jarno To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Cc: Subject: kern/150206: nmount(2): can't switch root partition to rw using mount flags X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 01 Sep 2010 22:50:02 -0000 >Number: 150206 >Category: kern >Synopsis: nmount(2): can't switch root partition to rw using mount flags >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Wed Sep 01 22:50:01 UTC 2010 >Closed-Date: >Last-Modified: >Originator: Aurelien Jarno >Release: 8.1 >Organization: >Environment: FreeBSD freebsd.aurel32.net 8.1-RELEASE FreeBSD 8.1-RELEASE #0: Mon Jul 19 02:55:53 UTC 2010 root@almeida.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC i386 >Description: The nmount(2) syscall can take filesystem options in two different ways: either via the mount flags or via iovec. When trying to switch a root partition from ro to rw using mount flags only (this is done for example by busybox to avoid diverging to much from the Linux code), that is using MNT_UPDATE but not MNT_RDONLY, this operation is ignored. This work correctly on a non-root filesystem though. >How-To-Repeat: >Fix: Patch is attached. Patch attached with submission follows: --- a/sys/kern/vfs_mount.c +++ b/sys/kern/vfs_mount.c @@ -559,10 +559,10 @@ struct vfsopt *opt, *noro_opt, *tmp_opt; char *fstype, *fspath, *errmsg; int error, fstypelen, fspathlen, errmsg_len, errmsg_pos; - int has_rw, has_noro; + int has_noro; errmsg = fspath = NULL; - errmsg_len = has_noro = has_rw = fspathlen = 0; + errmsg_len = has_noro = fspathlen = 0; errmsg_pos = -1; error = vfs_buildopts(fsoptions, &optlist); @@ -659,10 +659,8 @@ fsflags &= ~MNT_RDONLY; has_noro = 1; } - else if (strcmp(opt->name, "rw") == 0) { + else if (strcmp(opt->name, "rw") == 0) fsflags &= ~MNT_RDONLY; - has_rw = 1; - } else if (strcmp(opt->name, "ro") == 0) fsflags |= MNT_RDONLY; else if (strcmp(opt->name, "rdonly") == 0) { @@ -684,7 +682,7 @@ * we need a mount option "noro", since in vfs_mergeopts(), * "noro" will cancel "ro", but "rw" will not do anything. */ - if (has_rw && !has_noro) { + if (!(fsflags & MNT_RDONLY) && !has_noro) { noro_opt = malloc(sizeof(struct vfsopt), M_MOUNT, M_WAITOK); noro_opt->name = strdup("noro", M_MOUNT); noro_opt->value = NULL; >Release-Note: >Audit-Trail: >Unformatted: