mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Serge E. Hallyn" <serue@us.ibm.com>
To: James Morris <jmorris@namei.org>
Cc: Andrew Morgan <morgan@kernel.org>,
	Chris Wright <chrisw@sous-sol.org>,
	Andrew Morgan <agm@google.com>,
	casey@schaufler-ca.com, Andrew Morton <akpm@google.com>,
	Stephen Smalley <sds@tycho.nsa.gov>,
	KaiGai Kohei <kaigai@kaigai.gr.jp>,
	linux-security-module@vger.kernel.org,
	lkml <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 1/1] file capabilities: clear fcaps on inode change (v2)
Date: Tue, 7 Aug 2007 09:08:27 -0500	[thread overview]
Message-ID: <20070807140827.GB8286@sergelap.austin.ibm.com> (raw)
In-Reply-To: <Pine.LNX.4.64.0708070640160.31104@us.intercode.com.au>

Quoting James Morris (jmorris@namei.org):
> On Mon, 6 Aug 2007, Serge E. Hallyn wrote:
> 
> > +	err = security_inode_killpriv(out->f_path.dentry, LSM_NEED_LOCK);
> > +	if (err)
> > +		return err;
> > +
> >  	err = should_remove_suid(out->f_path.dentry);
> >  	if (unlikely(err)) {
> >  		mutex_lock(&inode->i_mutex);
> 
> It seems hackish to pass a needlock arg to an API, and that that we'll end 
> up with some conceptually similar call-outs for both caps and setuid.
> 
> How about encapsulating this stuff so that there's something like:
> 
> 
> 	err = should_remove_privs();
> 	if (err)
> 		remove_privs();
> 
> with
> 
> void remove_privs()
> {
> 	mutex_lock();
> 	__remove_privs();
> 	mutex_unlock();
> }
> 
> and then __remove_privs() handles the logic for all file privileges, 
> including at this stage suid and the LSM call for file caps ?

The problem is that the suid bit is not removed in all cases
when the file caps need to be removed.  In particular, if
capable(CAP_FSETID), then the suid bit is retained.

I suppose we could change those semantics, but then we'd the code still
doesn't flow quite right for what you suggest - should_remove_suid()
just checks whether the suid bit is set (and the process is !capable(CAP_FSETID),
not whether a change has happened requiring suid change.  That is
already assumed to be the case.

If your main objection is to the LSM_NEED_LOCK argument, we could of
course just grab the mutex around security_inode_killpriv(out->f_path.dentry)
in fs/splice.c:generic_file_splice_write().

And I suppose we can in fact get rid of ATTR_KILL_PRIV.  I had just
put it there to split up the code a bit to make it clearer - which I
do think it does.

Shall I resend without the LSM_NEED_LOCK, or do you still want a more
fundamental change?

thanks,
-serge

  reply	other threads:[~2007-08-07 14:08 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-08-06 18:52 Serge E. Hallyn
2007-08-07  6:50 ` Andrew Morgan
2007-08-07 13:47 ` James Morris
2007-08-07 14:08   ` Serge E. Hallyn [this message]
2007-08-07 14:17     ` James Morris
2007-08-07 15:19       ` Serge E. Hallyn
2007-08-07 13:57 ` Stephen Smalley
2007-08-07 14:11   ` Serge E. Hallyn

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=20070807140827.GB8286@sergelap.austin.ibm.com \
    --to=serue@us.ibm.com \
    --cc=agm@google.com \
    --cc=akpm@google.com \
    --cc=casey@schaufler-ca.com \
    --cc=chrisw@sous-sol.org \
    --cc=jmorris@namei.org \
    --cc=kaigai@kaigai.gr.jp \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=morgan@kernel.org \
    --cc=sds@tycho.nsa.gov \
    /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®