linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ipc: don't allocate with GFP_KERNEL inside rcu read lock
@ 2013-06-10 16:14 Sasha Levin
  2013-06-10 17:23 ` Davidlohr Bueso
  0 siblings, 1 reply; 3+ messages in thread
From: Sasha Levin @ 2013-06-10 16:14 UTC (permalink / raw)
  To: akpm; +Cc: davidlohr.bueso, riel, walken, linux-kernel, Sasha Levin

ipc_addid() is protected by a rcu read lock, which means we can't allocate
using GFP_KERNEL inside it.

Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
---

Another option would be to call idr_preload from outside the read lock,
but that complicates the code much more than this fix. If that's the
preferred method to fix it I can resend that solution instead.

 ipc/util.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ipc/util.c b/ipc/util.c
index a746abb..00aca85 100644
--- a/ipc/util.c
+++ b/ipc/util.c
@@ -261,7 +261,7 @@ int ipc_addid(struct ipc_ids* ids, struct kern_ipc_perm* new, int size)
 	if (ids->in_use >= size)
 		return -ENOSPC;
 
-	idr_preload(GFP_KERNEL);
+	idr_preload(GFP_ATOMIC);
 
 	spin_lock_init(&new->lock);
 	new->deleted = 0;
-- 
1.8.1.2


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] ipc: don't allocate with GFP_KERNEL inside rcu read lock
  2013-06-10 16:14 [PATCH] ipc: don't allocate with GFP_KERNEL inside rcu read lock Sasha Levin
@ 2013-06-10 17:23 ` Davidlohr Bueso
  2013-06-11 22:00   ` Andrew Morton
  0 siblings, 1 reply; 3+ messages in thread
From: Davidlohr Bueso @ 2013-06-10 17:23 UTC (permalink / raw)
  To: Sasha Levin; +Cc: akpm, riel, walken, linux-kernel, Fengguang Wu

On Mon, 2013-06-10 at 12:14 -0400, Sasha Levin wrote:
> ipc_addid() is protected by a rcu read lock, which means we can't allocate
> using GFP_KERNEL inside it.
> 
> Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
> ---
> 
> Another option would be to call idr_preload from outside the read lock,
> but that complicates the code much more than this fix. If that's the
> preferred method to fix it I can resend that solution instead.
> 

This issue was reported last week by Fengguang
(http://www.spinics.net/lists/kernel/msg1545633.html#.UbYI9qqdmV8)

Your fix looks the simplest approach, but I'm not sure if doing the
atomic allocation would trigger some other problem, as a side effect.
Andrew?

A third option would be to simply revert the offending commit, leaving
the rcu locking as it originally was.

Thanks,
Davidlohr


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] ipc: don't allocate with GFP_KERNEL inside rcu read lock
  2013-06-10 17:23 ` Davidlohr Bueso
@ 2013-06-11 22:00   ` Andrew Morton
  0 siblings, 0 replies; 3+ messages in thread
From: Andrew Morton @ 2013-06-11 22:00 UTC (permalink / raw)
  To: Davidlohr Bueso; +Cc: Sasha Levin, riel, walken, linux-kernel, Fengguang Wu

On Mon, 10 Jun 2013 10:23:49 -0700 Davidlohr Bueso <davidlohr.bueso@hp.com> wrote:

> On Mon, 2013-06-10 at 12:14 -0400, Sasha Levin wrote:
> > ipc_addid() is protected by a rcu read lock, which means we can't allocate
> > using GFP_KERNEL inside it.
> > 
> > Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
> > ---
> > 
> > Another option would be to call idr_preload from outside the read lock,
> > but that complicates the code much more than this fix. If that's the
> > preferred method to fix it I can resend that solution instead.
> > 
> 
> This issue was reported last week by Fengguang
> (http://www.spinics.net/lists/kernel/msg1545633.html#.UbYI9qqdmV8)
> 
> Your fix looks the simplest approach, but I'm not sure if doing the
> atomic allocation would trigger some other problem, as a side effect.
> Andrew?

It will fix the issue.  But GFP_ATOMIC is much less reliable than
GFP_KERNEL and such a switch should be viewed as a lame act of last
resort.

> A third option would be to simply revert the offending commit, leaving
> the rcu locking as it originally was.

That patch has other issues, as I described yesterday.  But there are
ten follow-on patches to that one and I assume that dropping
ipc-move-rcu-lock-out-of-ipc_addid.patch will create a mess.  It will
also create a combination which hasn't been tested by anyone.


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-06-11 22:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-06-10 16:14 [PATCH] ipc: don't allocate with GFP_KERNEL inside rcu read lock Sasha Levin
2013-06-10 17:23 ` Davidlohr Bueso
2013-06-11 22:00   ` Andrew Morton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).