On Sun, 2006-06-18 at 19:33 +0100, Al Viro wrote:
> On Fri, Jun 16, 2006 at 04:12:15PM -0700, Dave Hansen wrote:
> > +/*
> > + * Must be called under write lock on mnt->mnt_sb->s_umount,
> > + * this prevents concurrent decrements which could make the
> > + * value -1, and test in mnt_want_write() wrongly succeed
> > + */
> > +static inline int mnt_make_readonly(struct vfsmount *mnt)
> > +{
> > + if (!atomic_dec_and_test(&mnt->mnt_writers)) {
> > + atomic_inc(&mnt->mnt_writers);
> > + return -EBUSY;
> > + }
> > + return 0;
> > +}
>
> Check in faccessat() could get screwed by that, if you just lose the
> race with final writer going away. Then mnt_make_readonly() will
> fail (as it should) and access(2) give -EROFS.
Very true. How about this to fix it?
--- lxc/fs//open.c~C8.1-fix-faccesat 2006-06-19 09:59:41.000000000 -0700
+++ lxc-dave/fs//open.c 2006-06-19 10:01:25.000000000 -0700
@@ -546,8 +546,12 @@ asmlinkage long sys_faccessat(int dfd, c
special_file(nd.dentry->d_inode->i_mode))
goto out_path_release;
- if(__mnt_is_readonly(nd.mnt) || IS_RDONLY(nd.dentry->d_inode))
- res = -EROFS;
+ res = mnt_want_write(nd.mnt);
+ if (!res) {
+ mnt_drop_write(nd.mnt);
+ if(IS_RDONLY(nd.dentry->d_inode))
+ res = -EROFS;
+ }
out_path_release:
path_release(&nd);
-- Dave
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[Index of Archives]
[Kernel Newbies]
[Netfilter]
[Bugtraq]
[Photo]
[Stuff]
[Gimp]
[Yosemite News]
[MIPS Linux]
[ARM Linux]
[Linux Security]
[Linux RAID]
[Video 4 Linux]
[Linux for the blind]
[Linux Resources]