All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mimi Zohar <zohar@linux.vnet.ibm.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: a.beregalov@gmail.com, linux-kernel@vger.kernel.org,
	linux-next@vger.kernel.org, xfs@oss.sgi.com, jmorris@namei.org,
	david safford <safford@watson.ibm.com>
Subject: Re: next-20090220: XFS, IMA: BUG: sleeping function called from invalid  context at mm/slub.c:1613
Date: Sat, 21 Feb 2009 20:49:37 -0500	[thread overview]
Message-ID: <1235267377.3441.24.camel@localhost.localdomain> (raw)
In-Reply-To: <20090220142807.a28734a8.akpm@linux-foundation.org>

On Fri, 2009-02-20 at 14:28 -0800, Andrew Morton wrote: 
> On Fri, 20 Feb 2009 17:16:59 -0500
> Mimi Zohar <zohar@linux.vnet.ibm.com> wrote:
> 
> > integrity: ima iint radix_tree_lookup locking fix
> > 
> > Based on Andrew Morton's comments:
> > - add missing locks around radix_tree_lookup in ima_iint_insert()
> > 
> > Signed-off-by: Mimi Zohar <zohar@us.ibm.com>
> > 
> > Index: security-testing-2.6/security/integrity/ima/ima_iint.c
> > ===================================================================
> > --- security-testing-2.6.orig/security/integrity/ima/ima_iint.c
> > +++ security-testing-2.6/security/integrity/ima/ima_iint.c
> > @@ -73,8 +73,10 @@ out:
> >  	if (rc < 0) {
> >  		kmem_cache_free(iint_cache, iint);
> >  		if (rc == -EEXIST) {
> > +			spin_lock(&ima_iint_lock);
> >  			iint = radix_tree_lookup(&ima_iint_store,
> >  						 (unsigned long)inode);
> > +			spin_unlock(&ima_iint_lock);
> >  		} else
> >  			iint = NULL;
> >  	}
> 
> Can the -EEXIST ever actually happen?

> On the inode_init_always() path (at least), I don't think that any
> other thread of control can have access to this inode*, so there is no
> way in which a race can result in someone else adding this inode
> first?

True, but for those inodes which were allocated before IMA was enabled
and are being allocated in ima_iint_find_insert_get(), it could be an
issue.

> Also, idle question: why does the radix tree exist at all?  Would it
> have been possible to just add a `struct ima_iint_cache *' field to the
> inode instead?

Up until November the iint was defined directly in the inode. This
changed based on Christoph Hellwig's posting
http://lkml.org/lkml/2008/10/14/170 where he said, "bloating the inode
for this is not an option".

Mimi Zohar

WARNING: multiple messages have this Message-ID (diff)
From: Mimi Zohar <zohar@linux.vnet.ibm.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: david safford <safford@watson.ibm.com>,
	jmorris@namei.org, linux-kernel@vger.kernel.org,
	linux-next@vger.kernel.org, xfs@oss.sgi.com,
	a.beregalov@gmail.com
Subject: Re: next-20090220: XFS, IMA: BUG: sleeping function called from invalid  context at mm/slub.c:1613
Date: Sat, 21 Feb 2009 20:49:37 -0500	[thread overview]
Message-ID: <1235267377.3441.24.camel@localhost.localdomain> (raw)
In-Reply-To: <20090220142807.a28734a8.akpm@linux-foundation.org>

On Fri, 2009-02-20 at 14:28 -0800, Andrew Morton wrote: 
> On Fri, 20 Feb 2009 17:16:59 -0500
> Mimi Zohar <zohar@linux.vnet.ibm.com> wrote:
> 
> > integrity: ima iint radix_tree_lookup locking fix
> > 
> > Based on Andrew Morton's comments:
> > - add missing locks around radix_tree_lookup in ima_iint_insert()
> > 
> > Signed-off-by: Mimi Zohar <zohar@us.ibm.com>
> > 
> > Index: security-testing-2.6/security/integrity/ima/ima_iint.c
> > ===================================================================
> > --- security-testing-2.6.orig/security/integrity/ima/ima_iint.c
> > +++ security-testing-2.6/security/integrity/ima/ima_iint.c
> > @@ -73,8 +73,10 @@ out:
> >  	if (rc < 0) {
> >  		kmem_cache_free(iint_cache, iint);
> >  		if (rc == -EEXIST) {
> > +			spin_lock(&ima_iint_lock);
> >  			iint = radix_tree_lookup(&ima_iint_store,
> >  						 (unsigned long)inode);
> > +			spin_unlock(&ima_iint_lock);
> >  		} else
> >  			iint = NULL;
> >  	}
> 
> Can the -EEXIST ever actually happen?

> On the inode_init_always() path (at least), I don't think that any
> other thread of control can have access to this inode*, so there is no
> way in which a race can result in someone else adding this inode
> first?

True, but for those inodes which were allocated before IMA was enabled
and are being allocated in ima_iint_find_insert_get(), it could be an
issue.

> Also, idle question: why does the radix tree exist at all?  Would it
> have been possible to just add a `struct ima_iint_cache *' field to the
> inode instead?

Up until November the iint was defined directly in the inode. This
changed based on Christoph Hellwig's posting
http://lkml.org/lkml/2008/10/14/170 where he said, "bloating the inode
for this is not an option".

Mimi Zohar

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

  reply	other threads:[~2009-02-22  1:49 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-02-20 11:00 next-20090220: XFS, IMA: BUG: sleeping function called from invalid context at mm/slub.c:1613 Alexander Beregalov
2009-02-20 11:00 ` Alexander Beregalov
2009-02-20 11:00 ` Alexander Beregalov
2009-02-20 20:22 ` Andrew Morton
2009-02-20 20:22   ` Andrew Morton
2009-02-20 22:16   ` Mimi Zohar
2009-02-20 22:16     ` Mimi Zohar
2009-02-20 22:28     ` Andrew Morton
2009-02-20 22:28       ` Andrew Morton
2009-02-22  1:49       ` Mimi Zohar [this message]
2009-02-22  1:49         ` Mimi Zohar
2009-02-24 19:14   ` Christoph Hellwig
2009-02-24 22:34     ` Dave Chinner
2009-02-24 22:39   ` Mimi Zohar
2009-02-24 22:39     ` Mimi Zohar

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=1235267377.3441.24.camel@localhost.localdomain \
    --to=zohar@linux.vnet.ibm.com \
    --cc=a.beregalov@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=jmorris@namei.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-next@vger.kernel.org \
    --cc=safford@watson.ibm.com \
    --cc=xfs@oss.sgi.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 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.