Messages in this thread | | | Date | Tue, 7 Aug 2007 09:08:27 -0500 | From | "Serge E. Hallyn" <> | Subject | Re: [PATCH 1/1] file capabilities: clear fcaps on inode change (v2) |
| |
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 - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
| |