All of lore.kernel.org
 help / color / mirror / Atom feed
* [Patch net] net: saving irq context for peernet2id()
@ 2016-10-20  6:52 Cong Wang
  2016-10-20 10:17 ` Nicolas Dichtel
  2016-10-20 14:58 ` Stephen Smalley
  0 siblings, 2 replies; 22+ messages in thread
From: Cong Wang @ 2016-10-20  6:52 UTC (permalink / raw)
  To: netdev; +Cc: sds, e, paul, Cong Wang

A kernel warning inside __local_bh_enable_ip() was reported by people
running SELinux, this is caused due to some SELinux functions
(indirectly) call peernet2id() with IRQ disabled in process context,
when we re-enable BH with IRQ disabled kernel complains. Shut up this
warning by saving IRQ context in peernet2id(), BH is still implicitly
disabled.

Fixes: bc51dddf98c9 ("netns: avoid disabling irq for netns id")
Reported-by: Stephen Smalley <sds@tycho.nsa.gov>
Reported-by: Elad Raz <e@eladraz.com>
Tested-by: Paul Moore <paul@paul-moore.com>
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
---
 net/core/net_namespace.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c
index 989434f..17b52a2 100644
--- a/net/core/net_namespace.c
+++ b/net/core/net_namespace.c
@@ -230,11 +230,16 @@ int peernet2id_alloc(struct net *net, struct net *peer)
 /* This function returns, if assigned, the id of a peer netns. */
 int peernet2id(struct net *net, struct net *peer)
 {
+	unsigned long flags;
 	int id;
 
-	spin_lock_bh(&net->nsid_lock);
+	/* This is ugly, technically we only need to disable BH, however some
+	 * callers (indirectly) call this with IRQ disabled, which implies
+	 * that we should save the IRQ context here.
+	 */
+	spin_lock_irqsave(&net->nsid_lock, flags);
 	id = __peernet2id(net, peer);
-	spin_unlock_bh(&net->nsid_lock);
+	spin_unlock_irqrestore(&net->nsid_lock, flags);
 	return id;
 }
 EXPORT_SYMBOL(peernet2id);
-- 
2.1.0

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

end of thread, other threads:[~2016-10-22 19:02 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-20  6:52 [Patch net] net: saving irq context for peernet2id() Cong Wang
2016-10-20 10:17 ` Nicolas Dichtel
2016-10-20 17:17   ` Cong Wang
2016-10-20 14:58 ` Stephen Smalley
2016-10-20 18:29   ` Cong Wang
2016-10-20 19:04     ` Cong Wang
2016-10-20 19:07     ` Paul Moore
2016-10-20 23:35       ` Cong Wang
2016-10-21  4:47         ` Cong Wang
2016-10-21 13:51           ` Stephen Smalley
2016-10-21 16:19         ` Paul Moore
2016-10-21 18:02           ` Cong Wang
2016-10-21 19:39             ` Richard Guy Briggs
2016-10-21 20:15               ` Paul Moore
2016-10-21 20:33                 ` David Miller
2016-10-21 20:53                   ` Paul Moore
2016-10-22  1:55                     ` Paul Moore
2016-10-22  3:34                       ` Cong Wang
2016-10-22  3:53                   ` Cong Wang
2016-10-21 20:03             ` Paul Moore
2016-10-22  3:26               ` Cong Wang
2016-10-22 19:02                 ` Paul Moore

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.