All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Serge E. Hallyn" <serge.hallyn@canonical.com>
To: Chris Mason <chris.mason@oracle.com>,
	linux-fsdevel@vger.kernel.org, serge.hallyn@canonical.com,
	Andrew Morgan <morgan@kernel.org>
Subject: Re: remove_suid bangs on xattrs
Date: Tue, 17 Aug 2010 21:41:39 -0500	[thread overview]
Message-ID: <20100818024139.GA16578@hallyn.com> (raw)
In-Reply-To: <20100816194439.GG993@think>

Quoting Chris Mason (chris.mason@oracle.com):
> [ sorry, corrected cc list ]

Thanks - sorry for the inconvenience.  I'm also cc:ing Andrew Morgan
for another opinion.

> On Mon, Aug 16, 2010 at 03:38:12PM -0400, Chris Mason wrote:
> > Hi everyone,
> > 
> > I'm looking into a 2.6.35 btrfs performance regression, and perf tells
> > me that I'm spending a lot of time hammering on xattrs inside
> > remove_suid.  This is pretty surprising because I'm running as root, and
> > my files are not suid.  Looking back to this commit:
> > http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=b53767719b6cd8789392ea3e7e2eb7b8906898f0
> > 
> > We've changed remove_suid's semantics from
> > 
> > if (file_is_suid)
> >     try to remove it

(but only if not capable(CAP_FSETID))

> > To something that always checks to see if we have removal permissions.

(not really - security_inode_need_killpriv() shoudl return <0 only if
there was an actual error, and the write needs to be cancelled altogether.
It returns 0 if privs don't need to be removed, and >0 if they do.

> > Was this intentional?  It didn't cause my 2.6.35 regression (that's all
> > my fault) but it does look wrong to me:

If I'm thinking right, I think the key change we should make is to have
CAP_FSETID be honored for maintaining file capabilities.

That would have two (good) results:

1. we should be able to re-arrange the code to check for CAP_FSETID
before bothering to check for file capabilities, so we can save the
getxattrs which I assume were what you were finding?  Even if it
wasn't the cause of your performance regression, it should be an
improvement.

2. I think it can be seen as a semantic fix.  We mostly try to
respect suid behavior for file caps, so it will be more consistent
to honor CAP_FSETID for file capabilities.

Andrew, what do you think?

> > diff --git a/mm/filemap.c b/mm/filemap.c
> > index 4fb1546..79f24a9 100644
> > --- a/mm/filemap.c
> > +++ b/mm/filemap.c
> > @@ -1627,12 +1627,18 @@ int __remove_suid(struct dentry *dentry, int kill)
> >  
> >  int remove_suid(struct dentry *dentry)
> >  {
> > -       int kill = should_remove_suid(dentry);
> > +       int killsuid = should_remove_suid(dentry);
> > +       int killpriv = security_inode_need_killpriv(dentry);
> > +       int error = 0;
> >  
> > -       if (unlikely(kill))
> > -               return __remove_suid(dentry, kill);
> > +       if (killpriv < 0)
> > +               return killpriv;
> > +       if (killpriv)
> > +               error = security_inode_killpriv(dentry);
> > +       if (!error && killsuid)
> > +               error = __remove_suid(dentry, killsuid);
> >  
> > -       return 0;
> > +       return error;
> >  }
> >  EXPORT_SYMBOL(remove_suid);
> > 
> > -chris

thanks,
-serge

  reply	other threads:[~2010-08-18  2:41 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-16 19:38 remove_suid bangs on xattrs Chris Mason
2010-08-16 19:44 ` Chris Mason
2010-08-18  2:41   ` Serge E. Hallyn [this message]
2010-08-20  5:31     ` Andrew G. Morgan
2010-08-20 12:25       ` Serge E. Hallyn
     [not found]       ` <5E83F6C3-2B1E-4FBF-960C-27364528813C@dilger.ca>
2010-09-02 16:02         ` Serge E. Hallyn
2010-09-02 21:01           ` Andreas Dilger

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=20100818024139.GA16578@hallyn.com \
    --to=serge.hallyn@canonical.com \
    --cc=chris.mason@oracle.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=morgan@kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.