From: Trond Myklebust <trond.myklebust@fys.uio.no>
To: "Serge E. Hallyn" <sergeh@us.ibm.com>
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>,
James Morris <jmorris@namei.org>,
linux-security-module@vger.kernel.org,
lkml <linux-kernel@vger.kernel.org>
Subject: Re: file capabilities: clear fcaps on inode change (v3)
Date: Tue, 07 Aug 2007 18:38:05 -0400 [thread overview]
Message-ID: <1186526285.6625.41.camel@heimdal.trondhjem.org> (raw)
In-Reply-To: <20070807221727.GA12211@sergelap.austin.ibm.com>
On Tue, 2007-08-07 at 17:17 -0500, Serge E. Hallyn wrote:
> diff --git a/fs/splice.c b/fs/splice.c
> index e36c003..2df95f3 100644
> --- a/fs/splice.c
> +++ b/fs/splice.c
> @@ -827,6 +827,12 @@ generic_file_splice_write(struct pipe_inode_info *pipe, struct file *out,
> ssize_t ret;
> int err;
>
> + mutex_lock(&inode->i_mutex);
> + err = security_inode_killpriv(out->f_path.dentry);
> + mutex_unlock(&inode->i_mutex);
> + if (err)
> + return err;
You are unconditionally taking the i_mutex whether or not you actually
have any capabilities to remove. Normally, removing capabilities due to
a write is something which occurs once every blue moon. Can't you
introduce a heuristic along the lines of should_remove_suid() in order
to optimise away the common case?
In addition, if you need to remove both the capabilities and the suid
bits, then it should be unnecessary to take the i_mutex twice.
> +
> err = should_remove_suid(out->f_path.dentry);
> if (unlikely(err)) {
> mutex_lock(&inode->i_mutex);
Trond
next prev parent reply other threads:[~2007-08-07 22:38 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-08-07 22:17 file capabilities: clear fcaps on inode change (v3) Serge E. Hallyn
2007-08-07 22:38 ` Trond Myklebust [this message]
2007-08-07 23:14 ` Serge E. Hallyn
2007-08-08 1:21 ` James Morris
2007-08-08 13:30 ` Serge E. Hallyn
2007-08-08 14:08 ` James Morris
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=1186526285.6625.41.camel@heimdal.trondhjem.org \
--to=trond.myklebust@fys.uio.no \
--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 \
--cc=sergeh@us.ibm.com \
/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