From mboxrd@z Thu Jan 1 00:00:00 1970 From: Christoph Hellwig Subject: Re: [PATCH 09/26] make access() use mnt check Date: Sat, 30 Jun 2007 10:37:24 +0100 Message-ID: <20070630093724.GG22354@infradead.org> References: <20070622200303.82D9CC3A@kernel> <20070622200314.1310BD44@kernel> <20070623074519.GI27954@infradead.org> <1182796045.1387.7.camel@localhost> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Christoph Hellwig , akpm@osdl.org, linux-fsdevel@vger.kernel.org, viro@ftp.linux.org.uk To: Dave Hansen Return-path: Received: from pentafluge.infradead.org ([213.146.154.40]:40121 "EHLO pentafluge.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753604AbXF3Jh1 (ORCPT ); Sat, 30 Jun 2007 05:37:27 -0400 Content-Disposition: inline In-Reply-To: <1182796045.1387.7.camel@localhost> Sender: linux-fsdevel-owner@vger.kernel.org List-Id: linux-fsdevel.vger.kernel.org On Mon, Jun 25, 2007 at 11:27:25AM -0700, Dave Hansen wrote: > I've got this in the next set: > > - > - if(IS_RDONLY(nd.dentry->d_inode)) > + /* > + * This is a rare case where using __mnt_is_readonly() > + * is OK without a mnt_want/drop_write() pair. Since > + * not actual write to the fs is performed here, we do > + * not need to telegraph to that to anyone. Also, we > + * accept that access is inherently racy, and know that > + * the fs might be remounted between this syscall, and > + * any action taken because of its result. > + */ > + if (__mnt_is_readonly(nd.mnt)) > res = -EROFS; Looks good. > diff -puN fs/namei.c~numa_mnt_want_write fs/namei.c > --- lxc/fs/namei.c~numa_mnt_want_write 2007-06-25 11:05:50.000000000 -0700 > +++ lxc-dave/fs/namei.c 2007-06-25 11:05:50.000000000 -0700 > @@ -230,10 +230,12 @@ int permission(struct inode *inode, int > int retval, submask; > > if (mask & MAY_WRITE) { > - > /* > - * Nobody gets write access to a read-only fs. > + * If this WARN_ON() is hit, it likely means that > + * there was a missed mnt_want_write() on the path > + * leading here. > */ > + WARN_ON(__mnt_is_readonly(nd->mnt)); > if (IS_RDONLY(inode) && I might be missing something, but wouldn't this trip an access("/foo/bar", W_OK); On a readonly filesystem?