mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Herbert Poetzl <herbert@13thfloor.at>
To: viro@parcelfarce.linux.theplanet.co.uk
Cc: Andrew Morton <akpm@osdl.org>,
	torvalds@osdl.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] Bind Mount Extensions 0.04.1 3/5
Date: Fri, 19 Mar 2004 14:40:28 +0100	[thread overview]
Message-ID: <20040319134028.GA5297@MAIL.13thfloor.at> (raw)
In-Reply-To: <20040319111117.GP31500@parcelfarce.linux.theplanet.co.uk>

On Fri, Mar 19, 2004 at 11:11:17AM +0000, viro@parcelfarce.linux.theplanet.co.uk wrote:
> On Fri, Mar 19, 2004 at 03:52:36AM +0100, Herbert Poetzl wrote:
> > @@ -846,6 +846,16 @@ int presto_permission(struct inode *inod
> >  
> >          cache = presto_get_cache(inode);
> >  
> > +        /* Nobody gets write access to a read-only fs */
> > +        if ((mask & MAY_WRITE) &&
> > +                (S_ISREG(mode) || S_ISDIR(mode) || S_ISLNK(mode)) &&
> > +                (IS_RDONLY(inode) || (nd && MNT_IS_RDONLY(nd->mnt))))
> > +                return -EROFS;
> > +
> > +        /* Nobody gets write access to an immutable file */
> > +        if ((mask & MAY_WRITE) && IS_IMMUTABLE(inode))
> > +                return -EACCES;
> > +
> 
> That is gratitious, since the only way presto_setattr() 
> is ever called is as ->permission().

you mean presto_permission(), and yes, so that can be removed

> > --- linux-2.6.5-rc1-bk3-bme0.04.2-atime/fs/jfs/acl.c	2004-03-11 03:55:21.000000000 +0100
> > +++ linux-2.6.5-rc1-bk3-bme0.04.2-permission/fs/jfs/acl.c	2004-03-19 03:18:12.000000000 +0100
> > @@ -132,21 +132,6 @@ int jfs_permission(struct inode * inode,
> >  	umode_t mode = inode->i_mode;
> >  	struct jfs_inode_info *ji = JFS_IP(inode);
> >  
> > -	if (mask & MAY_WRITE) {
> > -		/*
> 
> ... and that is broken, since jfs_permission() can be called directly.

incomplete, not broken ...

	 -· jfs_permission()
	  ¦-· can_get_xattr()
	  ¦ '-· __jfs_getxattr()
	  ¦   ¦-· jfs_get_acl()
	  ¦   ¦ ¦-· jfs_acl_chmod()
	  ¦   ¦ ¦ '-· jfs_setattr()
	  ¦   ¦ ¦ 
	  ¦   ¦ ¦-· jfs_init_acl()
	  ¦   ¦ ¦ ¦-· jfs_create()
	  ¦   ¦ ¦ ¦-· jfs_mkdir()
	  ¦   ¦ ¦ ¦-· jfs_mknod()
	  ¦   ¦ ¦ '-· jfs_symlink()
	  ¦   ¦ ¦ 
	  ¦   ¦ '-= jfs_permission()
	  ¦   ¦ 
	  ¦   '-· jfs_getxattr()
	  ¦   
	  '-· can_set_xattr()
	    '-· __jfs_setxattr()
	      ¦-· jfs_removexattr()
	      ¦-· jfs_set_acl()
	      ¦ ¦-= jfs_acl_chmod()
	      ¦ '-= jfs_init_acl()
	      ¦ 
	      '-· jfs_setxattr()


the xattr struff needs attention anyway, and many
of the functions calling jfs_permission() directly or
indirectly will have the check at a higher layer ...

> FWIW, I would start with
> 	1) split out simple_permission() - vfs_permission() sans the
> r/o checks; vfs_permission() would call it and all in-tree calls of
> vfs_permission() would get expanded.

	 -· vfs_permission()
	  ¦-· hfs_permission()
	  ¦-· hfsplus_permission()
	  ¦-· nfs_permission()
	  ¦-* permission()
	  ¦-· presto_permission()
	  '-· proc_permission()

please elaborate ...

> 	2) prove that all instances of ->permission() honour r/o checks.
> Fix the broken ones (and yes, we do have them - e.g. hfs_permission()
> or bogus return values in proc_permission()), after we'd shown that
> it's safe.  Note that it's not obvious - e.g. anything around ACLs or
> <barf> XFS ioctls is not just fscking ugly - it's brittle as hell and
> will require very careful treatment.

okay, but why not do it in permission(), and make
the few callers of vfs_permission use that one instead?

except for jfs_permission() and nfsd_permission()
(which is hell enough) there are no direct calls
of *_permission() ...

> 	3) once that is done, put r/o checks into the beginning of
> permission(9)

hmm, obviously you didn't read the patch at all, as that 
is exactly what I did, so please have a look at it ...

> 	4) for all instances of ->permission(), move r/o checks in
> the places that call that instance directly.  Remove them from method
> itself.
> 
> 	And yes, #2 will hurt.  Badly.

I don't see why, please enlighten me ...

> BTW, IS_RDONLY() part of that stuff will really hit the fan when you start
> touching the FPOS in fs/ext2/xattr.c and around it.  Have fun...
> 
> Note that it's not enough to bring relevant vfsmount to every caller of
> IS_RDONLY() - if we are calling it to make sure that fs is not r/o,
> we _really_ want to make sure that it doesn't get remounted r/o just as
> IS_RDONLY() returns.  And yes, there are real bugs in that area.

hmm, well but how would moving the ro checks around
or adding them for the vfs mounts influence that?

I agree that this _is_ an issue but why should this _not_
happen with mount -o remount,ro /xy ?

best,
Herbert


  reply	other threads:[~2004-03-19 13:40 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-03-15  3:55 [PATCH] Bind Mount Extensions 0.04 (linux-2.6.4) Herbert Poetzl
2004-03-15  4:14 ` Andrew Morton
2004-03-15  4:25   ` Herbert Poetzl
2004-03-15  4:34     ` Andrew Morton
2004-03-15  7:55       ` Herbert Poetzl
2004-03-15  7:56       ` [PATCH] Bind Mount Extensions 0.04.1 1/5 Herbert Poetzl
2004-03-15  7:57       ` [PATCH] Bind Mount Extensions 0.04.1 2/5 Herbert Poetzl
2004-03-18 12:16         ` viro
2004-03-19  1:57           ` Herbert Poetzl
2004-04-02  1:23           ` Herbert Poetzl
2004-03-15  7:58       ` [PATCH] Bind Mount Extensions 0.04.1 3/5 Herbert Poetzl
2004-03-15 22:10         ` Andrew Morton
2004-03-15 23:04           ` Herbert Poetzl
2004-03-15 23:31             ` Andrew Morton
2004-03-16  6:30               ` Herbert Poetzl
2004-03-18 12:26         ` viro
2004-03-19  2:52           ` Herbert Poetzl
2004-03-19 11:11             ` viro
2004-03-19 13:40               ` Herbert Poetzl [this message]
2004-03-19 14:52                 ` viro
2004-03-15  7:58       ` [PATCH] Bind Mount Extensions 0.04.1 4/5 Herbert Poetzl
2004-03-15  7:59       ` [PATCH] Bind Mount Extensions 0.04.1 5/5 Herbert Poetzl
2004-03-15 13:25   ` [PATCH] Bind Mount Extensions 0.04 (linux-2.6.4) Marc-Christian Petersen
2004-03-15 18:25     ` Dariush Pietrzak

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20040319134028.GA5297@MAIL.13thfloor.at \
    --to=herbert@13thfloor.at \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@osdl.org \
    --cc=viro@parcelfarce.linux.theplanet.co.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®