netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net] net: set default network namespace in init_dummy_netdev()
@ 2019-01-26 22:38 Josh Elsasser
  2019-01-29 19:30 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Josh Elsasser @ 2019-01-26 22:38 UTC (permalink / raw)
  To: David S. Miller
  Cc: josh, Josh Elsasser, Edward Cree, Kirill Tkhai, Jiri Pirko,
	Petr Machata, Eric Dumazet, Amritha Nambiar, Alexander Duyck,
	Li RongQing, netdev, linux-kernel

Assign a default net namespace to netdevs created by init_dummy_netdev().
Fixes a NULL pointer dereference caused by busy-polling a socket bound to
an iwlwifi wireless device, which bumps the per-net BUSYPOLLRXPACKETS stat
if napi_poll() received packets:

  BUG: unable to handle kernel NULL pointer dereference at 0000000000000190
  IP: napi_busy_loop+0xd6/0x200
  Call Trace:
    sock_poll+0x5e/0x80
    do_sys_poll+0x324/0x5a0
    SyS_poll+0x6c/0xf0
    do_syscall_64+0x6b/0x1f0
    entry_SYSCALL_64_after_hwframe+0x3d/0xa2

Fixes: 7db6b048da3b ("net: Commonize busy polling code to focus on napi_id instead of socket")
Signed-off-by: Josh Elsasser <jelsasser@appneta.com>
---
 net/core/dev.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/net/core/dev.c b/net/core/dev.c
index 82f20022259d..d1043d49979c 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -8712,7 +8712,9 @@ int init_dummy_netdev(struct net_device *dev)
 	set_bit(__LINK_STATE_PRESENT, &dev->state);
 	set_bit(__LINK_STATE_START, &dev->state);
 
+	/* napi_busy_loop stats accounting wants this */
+	dev_net_set(dev, &init_net);
+
 	/* Note : We dont allocate pcpu_refcnt for dummy devices,
 	 * because users of this 'device' dont need to change
 	 * its refcount.
-- 
2.19.1


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

* Re: [PATCH net] net: set default network namespace in init_dummy_netdev()
  2019-01-26 22:38 [PATCH net] net: set default network namespace in init_dummy_netdev() Josh Elsasser
@ 2019-01-29 19:30 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2019-01-29 19:30 UTC (permalink / raw)
  To: jelsasser
  Cc: josh, ecree, ktkhai, jiri, petrm, edumazet, amritha.nambiar,
	alexander.h.duyck, lirongqing, netdev, linux-kernel

From: Josh Elsasser <jelsasser@appneta.com>
Date: Sat, 26 Jan 2019 14:38:33 -0800

> Assign a default net namespace to netdevs created by init_dummy_netdev().
> Fixes a NULL pointer dereference caused by busy-polling a socket bound to
> an iwlwifi wireless device, which bumps the per-net BUSYPOLLRXPACKETS stat
> if napi_poll() received packets:
> 
>   BUG: unable to handle kernel NULL pointer dereference at 0000000000000190
>   IP: napi_busy_loop+0xd6/0x200
>   Call Trace:
>     sock_poll+0x5e/0x80
>     do_sys_poll+0x324/0x5a0
>     SyS_poll+0x6c/0xf0
>     do_syscall_64+0x6b/0x1f0
>     entry_SYSCALL_64_after_hwframe+0x3d/0xa2
> 
> Fixes: 7db6b048da3b ("net: Commonize busy polling code to focus on napi_id instead of socket")
> Signed-off-by: Josh Elsasser <jelsasser@appneta.com>

Applied and queued up for -stable.

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

end of thread, other threads:[~2019-01-29 19:31 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-26 22:38 [PATCH net] net: set default network namespace in init_dummy_netdev() Josh Elsasser
2019-01-29 19:30 ` David Miller

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).