Openwall GNU/*/Linux - a small security-enhanced Linux distro for servers
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Sat, 28 Sep 2013 15:57:26 +0100
From: Djalal Harouni <tixxdz@...ndz.org>
To: Al Viro <viro@...IV.linux.org.uk>
Cc: Linus Torvalds <torvalds@...ux-foundation.org>,
	"Eric W. Biederman" <ebiederm@...ssion.com>,
	Kees Cook <keescook@...omium.org>,
	Andrew Morton <akpm@...ux-foundation.org>,
	Ingo Molnar <mingo@...nel.org>,
	"Serge E. Hallyn" <serge.hallyn@...ntu.com>,
	Cyrill Gorcunov <gorcunov@...nvz.org>,
	LKML <linux-kernel@...r.kernel.org>,
	linux-fsdevel <linux-fsdevel@...r.kernel.org>,
	"kernel-hardening@...ts.openwall.com" <kernel-hardening@...ts.openwall.com>,
	tixxdz@...il.com
Subject: Re: [PATCH 04/12] seq_file: Make seq_file able to access the file's
 opener cred

On Thu, Sep 26, 2013 at 04:02:54AM +0100, Al Viro wrote:
> On Wed, Sep 25, 2013 at 05:22:51PM -0700, Linus Torvalds wrote:
> > On Wed, Sep 25, 2013 at 1:14 PM, Djalal Harouni <tixxdz@...ndz.org> wrote:
> > >
> > > Therefor add the f_cred field to the seq_file struct and a helper
> > > seq_f_cred() to return it.
> > 
> > I hate how you've split up this patch from the next one that actually
> > _initializes_ the new field.
> > 
> > The two patches should have been one.
> > 
> > I think the patch should also remove the 'user_ns' member, since it's
> > now available as f_cred->user_ns.
> > 
> > I also suspect that it would be better to just make the the new
> > seq_file member point to the 'struct file' instead. Sure, it's an
> > extra level of indirection, but the lifetime of f_cred is not as clear
> > otherwise. You don't increment the reference count, which is correct
> > *only* because 'seq_file' has the same lifetime as 'struct file', and
> > thus the reference count from struct file for the f_cred is
> > sufficient.
> 
> That's better than f_cred (or user_ns, for that matter), but... I'm
> afraid that it'll get abused very soon.  And I don't understand the
> argument about the lifetime rules - what makes struct file ones
> different from struct cred ones in that respect?  Except that in this
> case it's really obvious that we can't grab a reference, that is...
For that reference count lifetime rule. Sorry I was trying to compare it
with other implemented solutions. /proc/pid/environ will increment the
mm->mm_count inside __mem_open(), thus mm_struct will stay in until
mem_release(). That's it.

In the proposed solution and as noted by Linus, the reference count
from 'struct file' is sufficient for f_cred.

Last, I'm happy with /proc/pid/environ as it is, will not touch it
unless there is a request for it, but this proposed file->f_cred
solution is better:
* Not *all* these /proc/<pid>/* files are interested in acquiring a
  reference to the task's mm and increment its counters.
* It can be adapted to all the /proc/<pid>/* files, we already have the
  file->f_cred
* It allow to pass file descriptors if original opener had enough
  permission. It's explained in [Patch 0/12]
* It allow referencing the correct mm of the currently running
  target task at read(),write()...

  Where other solutions will just block/restrict this behaviour.

Thanks

-- 
Djalal Harouni
http://opendz.org

Powered by blists - more mailing lists

Your e-mail address:

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.