All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Paris <eparis@redhat.com>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>,
	LKML <linux-kernel@vger.kernel.org>,
	Stephen Smalley <sds@tycho.nsa.gov>,
	James Morris <james.l.morris@oracle.com>,
	Paul Moore <paul@paul-moore.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	"Paul E. McKenney" <paulmck@linux.vnet.ibm.com>,
	stable <stable@vger.kernel.org>,
	selinux@tycho.nsa.gov, linux-security-module@vger.kernel.org
Subject: Re: [PATCH] SELinux: Fix possible NULL pointer dereference in selinux_inode_permission()
Date: Thu, 09 Jan 2014 11:05:45 -0500	[thread overview]
Message-ID: <1389283545.15209.59.camel@localhost> (raw)
In-Reply-To: <1389283030.15209.56.camel@localhost>

[adding lsm and selinux]

Am I just crazy, or was this bug discussed (and obviously not fixed)
some time ago?

VFS can still use inodes after security_inode_free_security() was
called...

On Thu, 2014-01-09 at 10:57 -0500, Eric Paris wrote:
> On Thu, 2014-01-09 at 10:51 -0500, Steven Rostedt wrote:
> > On Thu, 9 Jan 2014 10:31:55 -0500
> > Eric Paris <eparis@parisplace.org> wrote:
> > 
> > > Didn't Al find this/something very similar.  I really hate this
> > 
> > I'm not involved with the vfs, so I'm unaware of other solutions
> > presented. I just hit this now and solving bugs is where I get a chance
> > to learn about other aspects of the kernel. ;-)
> > 
> > > solution.  Why should every LSM try to understand the intimate
> > > lifetime rules of the parent subsystems?  The real problem is that
> > > inode_free_security() is being called while the inode is still in use.
> > >  While I agree with the assessment, I disagree with the solution.  Let
> > > me try to find where Al and Christoph talked about this....
> > > 
> > 
> > The other obvious solution (but not as trivial to implement) is to call
> > the security_inode_free() and friends (probably __destroy_inode()
> > itself) after a synchronize_rcu().
> > 
> > Perhaps something like this?
> 
> I can't for the life of me find that conversation!  Maybe I'm just
> making it all up...  Usually I forget conversations, not remember ones
> that didn't happen...
> 
> Assuming the VFS guys say that delaying __destroy_inode() is safe like
> that, I like it better.  It also means that this is fixed for all LSMs,
> not just SELinux...
> 
> -Eric
> 
> > 
> > -- Steve
> > 
> > diff --git a/fs/inode.c b/fs/inode.c
> > index 4bcdad3..a8f3b88 100644
> > --- a/fs/inode.c
> > +++ b/fs/inode.c
> > @@ -252,16 +252,17 @@ EXPORT_SYMBOL(__destroy_inode);
> >  static void i_callback(struct rcu_head *head)
> >  {
> >  	struct inode *inode = container_of(head, struct inode, i_rcu);
> > +	__destroy_inode(inode);
> >  	kmem_cache_free(inode_cachep, inode);
> >  }
> >  
> >  static void destroy_inode(struct inode *inode)
> >  {
> >  	BUG_ON(!list_empty(&inode->i_lru));
> > -	__destroy_inode(inode);
> > -	if (inode->i_sb->s_op->destroy_inode)
> > +	if (inode->i_sb->s_op->destroy_inode) {
> > +		__destroy_inode(inode);
> >  		inode->i_sb->s_op->destroy_inode(inode);
> > -	else
> > +	} else
> >  		call_rcu(&inode->i_rcu, i_callback);
> >  }
> >  
> 



WARNING: multiple messages have this Message-ID (diff)
From: Eric Paris <eparis@redhat.com>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
	stable <stable@vger.kernel.org>,
	linux-security-module@vger.kernel.org,
	Alexander Viro <viro@zeniv.linux.org.uk>,
	James Morris <james.l.morris@oracle.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	"Paul E. McKenney" <paulmck@linux.vnet.ibm.com>,
	Stephen Smalley <sds@tycho.nsa.gov>,
	selinux@tycho.nsa.gov
Subject: Re: [PATCH] SELinux: Fix possible NULL pointer dereference in selinux_inode_permission()
Date: Thu, 09 Jan 2014 11:05:45 -0500	[thread overview]
Message-ID: <1389283545.15209.59.camel@localhost> (raw)
In-Reply-To: <1389283030.15209.56.camel@localhost>

[adding lsm and selinux]

Am I just crazy, or was this bug discussed (and obviously not fixed)
some time ago?

VFS can still use inodes after security_inode_free_security() was
called...

On Thu, 2014-01-09 at 10:57 -0500, Eric Paris wrote:
> On Thu, 2014-01-09 at 10:51 -0500, Steven Rostedt wrote:
> > On Thu, 9 Jan 2014 10:31:55 -0500
> > Eric Paris <eparis@parisplace.org> wrote:
> > 
> > > Didn't Al find this/something very similar.  I really hate this
> > 
> > I'm not involved with the vfs, so I'm unaware of other solutions
> > presented. I just hit this now and solving bugs is where I get a chance
> > to learn about other aspects of the kernel. ;-)
> > 
> > > solution.  Why should every LSM try to understand the intimate
> > > lifetime rules of the parent subsystems?  The real problem is that
> > > inode_free_security() is being called while the inode is still in use.
> > >  While I agree with the assessment, I disagree with the solution.  Let
> > > me try to find where Al and Christoph talked about this....
> > > 
> > 
> > The other obvious solution (but not as trivial to implement) is to call
> > the security_inode_free() and friends (probably __destroy_inode()
> > itself) after a synchronize_rcu().
> > 
> > Perhaps something like this?
> 
> I can't for the life of me find that conversation!  Maybe I'm just
> making it all up...  Usually I forget conversations, not remember ones
> that didn't happen...
> 
> Assuming the VFS guys say that delaying __destroy_inode() is safe like
> that, I like it better.  It also means that this is fixed for all LSMs,
> not just SELinux...
> 
> -Eric
> 
> > 
> > -- Steve
> > 
> > diff --git a/fs/inode.c b/fs/inode.c
> > index 4bcdad3..a8f3b88 100644
> > --- a/fs/inode.c
> > +++ b/fs/inode.c
> > @@ -252,16 +252,17 @@ EXPORT_SYMBOL(__destroy_inode);
> >  static void i_callback(struct rcu_head *head)
> >  {
> >  	struct inode *inode = container_of(head, struct inode, i_rcu);
> > +	__destroy_inode(inode);
> >  	kmem_cache_free(inode_cachep, inode);
> >  }
> >  
> >  static void destroy_inode(struct inode *inode)
> >  {
> >  	BUG_ON(!list_empty(&inode->i_lru));
> > -	__destroy_inode(inode);
> > -	if (inode->i_sb->s_op->destroy_inode)
> > +	if (inode->i_sb->s_op->destroy_inode) {
> > +		__destroy_inode(inode);
> >  		inode->i_sb->s_op->destroy_inode(inode);
> > -	else
> > +	} else
> >  		call_rcu(&inode->i_rcu, i_callback);
> >  }
> >  
> 

  reply	other threads:[~2014-01-09 16:06 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-09 15:19 [PATCH] SELinux: Fix possible NULL pointer dereference in selinux_inode_permission() Steven Rostedt
2014-01-09 15:31 ` Eric Paris
2014-01-09 15:51   ` Steven Rostedt
2014-01-09 15:57     ` Eric Paris
2014-01-09 16:05       ` Eric Paris [this message]
2014-01-09 16:05         ` Eric Paris
2014-01-09 16:10         ` Stephen Smalley
2014-01-09 16:10           ` Stephen Smalley
2014-01-09 16:22           ` Steven Rostedt
2014-01-09 16:22             ` Steven Rostedt
2014-01-09 16:25             ` Eric Paris
2014-01-09 16:25               ` Eric Paris
2014-01-09 20:20           ` Mimi Zohar
2014-01-09 20:20             ` Mimi Zohar
2014-01-09 20:24             ` Eric Paris
2014-01-09 20:24               ` Eric Paris
2014-01-09 22:28         ` Al Viro
2014-01-09 22:28           ` Al Viro
2014-01-09 22:17     ` Al Viro
2014-01-09 22:13   ` Al Viro
2014-01-09 22:18     ` Eric Paris
2014-01-09 22:25       ` Al Viro
2014-01-09 22:45     ` Eric Paris

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=1389283545.15209.59.camel@localhost \
    --to=eparis@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=james.l.morris@oracle.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=paul@paul-moore.com \
    --cc=paulmck@linux.vnet.ibm.com \
    --cc=rostedt@goodmis.org \
    --cc=sds@tycho.nsa.gov \
    --cc=selinux@tycho.nsa.gov \
    --cc=stable@vger.kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    /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.