netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] net: propagate errors correctly in register_netdevice()
@ 2019-10-03 15:59 Eric Dumazet
  2019-10-03 19:01 ` Willem de Bruijn
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Eric Dumazet @ 2019-10-03 15:59 UTC (permalink / raw)
  To: David S . Miller; +Cc: netdev, Eric Dumazet, Eric Dumazet, Jiri Pirko, syzbot

If netdev_name_node_head_alloc() fails to allocate
memory, we absolutely want register_netdevice() to return
-ENOMEM instead of zero :/

One of the syzbot report looked like :

general protection fault: 0000 [#1] PREEMPT SMP KASAN
CPU: 1 PID: 8760 Comm: syz-executor839 Not tainted 5.3.0+ #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
RIP: 0010:ovs_vport_add+0x185/0x500 net/openvswitch/vport.c:205
Code: 89 c6 e8 3e b6 3a fa 49 81 fc 00 f0 ff ff 0f 87 6d 02 00 00 e8 8c b4 3a fa 4c 89 e2 48 b8 00 00 00 00 00 fc ff df 48 c1 ea 03 <80> 3c 02 00 0f 85 d3 02 00 00 49 8d 7c 24 08 49 8b 34 24 48 b8 00
RSP: 0018:ffff88808fe5f4e0 EFLAGS: 00010247
RAX: dffffc0000000000 RBX: ffffffff89be8820 RCX: ffffffff87385162
RDX: 0000000000000000 RSI: ffffffff87385174 RDI: 0000000000000007
RBP: ffff88808fe5f510 R08: ffff8880933c6600 R09: fffffbfff14ee13c
R10: fffffbfff14ee13b R11: ffffffff8a7709df R12: 0000000000000004
R13: ffffffff89be8850 R14: ffff88808fe5f5e0 R15: 0000000000000002
FS:  0000000001d71880(0000) GS:ffff8880ae900000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000000020000280 CR3: 0000000096e4c000 CR4: 00000000001406e0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
 new_vport+0x1b/0x1d0 net/openvswitch/datapath.c:194
 ovs_dp_cmd_new+0x5e5/0xe30 net/openvswitch/datapath.c:1644
 genl_family_rcv_msg+0x74b/0xf90 net/netlink/genetlink.c:629
 genl_rcv_msg+0xca/0x170 net/netlink/genetlink.c:654
 netlink_rcv_skb+0x177/0x450 net/netlink/af_netlink.c:2477
 genl_rcv+0x29/0x40 net/netlink/genetlink.c:665
 netlink_unicast_kernel net/netlink/af_netlink.c:1302 [inline]
 netlink_unicast+0x531/0x710 net/netlink/af_netlink.c:1328
 netlink_sendmsg+0x8a5/0xd60 net/netlink/af_netlink.c:1917
 sock_sendmsg_nosec net/socket.c:637 [inline]
 sock_sendmsg+0xd7/0x130 net/socket.c:657
 ___sys_sendmsg+0x803/0x920 net/socket.c:2311
 __sys_sendmsg+0x105/0x1d0 net/socket.c:2356
 __do_sys_sendmsg net/socket.c:2365 [inline]
 __se_sys_sendmsg net/socket.c:2363 [inline]
 __x64_sys_sendmsg+0x78/0xb0 net/socket.c:2363

Fixes: ff92741270bf ("net: introduce name_node struct to be used in hashlist")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Jiri Pirko <jiri@mellanox.com>
Reported-by: syzbot <syzkaller@googlegroups.com>
---
 net/core/dev.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/net/core/dev.c b/net/core/dev.c
index c680225e0da844bbbd66c9044851880fa7885117..944de67ee95d621a1cde98d3fadfdab392b5aa98 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -8935,6 +8935,7 @@ int register_netdevice(struct net_device *dev)
 	if (ret < 0)
 		goto out;
 
+	ret = -ENOMEM;
 	dev->name_node = netdev_name_node_head_alloc(dev);
 	if (!dev->name_node)
 		goto out;
-- 
2.23.0.581.g78d2f28ef7-goog


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

* Re: [PATCH net-next] net: propagate errors correctly in register_netdevice()
  2019-10-03 15:59 [PATCH net-next] net: propagate errors correctly in register_netdevice() Eric Dumazet
@ 2019-10-03 19:01 ` Willem de Bruijn
  2019-10-03 19:18 ` Jiri Pirko
  2019-10-03 19:31 ` David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: Willem de Bruijn @ 2019-10-03 19:01 UTC (permalink / raw)
  To: Eric Dumazet; +Cc: David S . Miller, netdev, Eric Dumazet, Jiri Pirko, syzbot

On Thu, Oct 3, 2019 at 1:43 PM Eric Dumazet <edumazet@google.com> wrote:
>
> If netdev_name_node_head_alloc() fails to allocate
> memory, we absolutely want register_netdevice() to return
> -ENOMEM instead of zero :/
>
> One of the syzbot report looked like :
>
> general protection fault: 0000 [#1] PREEMPT SMP KASAN
> CPU: 1 PID: 8760 Comm: syz-executor839 Not tainted 5.3.0+ #0
> Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
> RIP: 0010:ovs_vport_add+0x185/0x500 net/openvswitch/vport.c:205
> Code: 89 c6 e8 3e b6 3a fa 49 81 fc 00 f0 ff ff 0f 87 6d 02 00 00 e8 8c b4 3a fa 4c 89 e2 48 b8 00 00 00 00 00 fc ff df 48 c1 ea 03 <80> 3c 02 00 0f 85 d3 02 00 00 49 8d 7c 24 08 49 8b 34 24 48 b8 00
> RSP: 0018:ffff88808fe5f4e0 EFLAGS: 00010247
> RAX: dffffc0000000000 RBX: ffffffff89be8820 RCX: ffffffff87385162
> RDX: 0000000000000000 RSI: ffffffff87385174 RDI: 0000000000000007
> RBP: ffff88808fe5f510 R08: ffff8880933c6600 R09: fffffbfff14ee13c
> R10: fffffbfff14ee13b R11: ffffffff8a7709df R12: 0000000000000004
> R13: ffffffff89be8850 R14: ffff88808fe5f5e0 R15: 0000000000000002
> FS:  0000000001d71880(0000) GS:ffff8880ae900000(0000) knlGS:0000000000000000
> CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
> CR2: 0000000020000280 CR3: 0000000096e4c000 CR4: 00000000001406e0
> DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
> DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
> Call Trace:
>  new_vport+0x1b/0x1d0 net/openvswitch/datapath.c:194
>  ovs_dp_cmd_new+0x5e5/0xe30 net/openvswitch/datapath.c:1644
>  genl_family_rcv_msg+0x74b/0xf90 net/netlink/genetlink.c:629
>  genl_rcv_msg+0xca/0x170 net/netlink/genetlink.c:654
>  netlink_rcv_skb+0x177/0x450 net/netlink/af_netlink.c:2477
>  genl_rcv+0x29/0x40 net/netlink/genetlink.c:665
>  netlink_unicast_kernel net/netlink/af_netlink.c:1302 [inline]
>  netlink_unicast+0x531/0x710 net/netlink/af_netlink.c:1328
>  netlink_sendmsg+0x8a5/0xd60 net/netlink/af_netlink.c:1917
>  sock_sendmsg_nosec net/socket.c:637 [inline]
>  sock_sendmsg+0xd7/0x130 net/socket.c:657
>  ___sys_sendmsg+0x803/0x920 net/socket.c:2311
>  __sys_sendmsg+0x105/0x1d0 net/socket.c:2356
>  __do_sys_sendmsg net/socket.c:2365 [inline]
>  __se_sys_sendmsg net/socket.c:2363 [inline]
>  __x64_sys_sendmsg+0x78/0xb0 net/socket.c:2363
>
> Fixes: ff92741270bf ("net: introduce name_node struct to be used in hashlist")
> Signed-off-by: Eric Dumazet <edumazet@google.com>
> Cc: Jiri Pirko <jiri@mellanox.com>
> Reported-by: syzbot <syzkaller@googlegroups.com>

Tested-by: Willem de Bruijn <willemb@google.com>

Thanks Eric. This also fixes the veth_get_stats64 syzbot report.

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

* Re: [PATCH net-next] net: propagate errors correctly in register_netdevice()
  2019-10-03 15:59 [PATCH net-next] net: propagate errors correctly in register_netdevice() Eric Dumazet
  2019-10-03 19:01 ` Willem de Bruijn
@ 2019-10-03 19:18 ` Jiri Pirko
  2019-10-03 19:31 ` David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: Jiri Pirko @ 2019-10-03 19:18 UTC (permalink / raw)
  To: Eric Dumazet; +Cc: David S . Miller, netdev, Eric Dumazet, Jiri Pirko, syzbot

Thu, Oct 03, 2019 at 05:59:24PM CEST, edumazet@google.com wrote:
>If netdev_name_node_head_alloc() fails to allocate
>memory, we absolutely want register_netdevice() to return
>-ENOMEM instead of zero :/

oops.


>
>One of the syzbot report looked like :
>
>general protection fault: 0000 [#1] PREEMPT SMP KASAN
>CPU: 1 PID: 8760 Comm: syz-executor839 Not tainted 5.3.0+ #0
>Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
>RIP: 0010:ovs_vport_add+0x185/0x500 net/openvswitch/vport.c:205
>Code: 89 c6 e8 3e b6 3a fa 49 81 fc 00 f0 ff ff 0f 87 6d 02 00 00 e8 8c b4 3a fa 4c 89 e2 48 b8 00 00 00 00 00 fc ff df 48 c1 ea 03 <80> 3c 02 00 0f 85 d3 02 00 00 49 8d 7c 24 08 49 8b 34 24 48 b8 00
>RSP: 0018:ffff88808fe5f4e0 EFLAGS: 00010247
>RAX: dffffc0000000000 RBX: ffffffff89be8820 RCX: ffffffff87385162
>RDX: 0000000000000000 RSI: ffffffff87385174 RDI: 0000000000000007
>RBP: ffff88808fe5f510 R08: ffff8880933c6600 R09: fffffbfff14ee13c
>R10: fffffbfff14ee13b R11: ffffffff8a7709df R12: 0000000000000004
>R13: ffffffff89be8850 R14: ffff88808fe5f5e0 R15: 0000000000000002
>FS:  0000000001d71880(0000) GS:ffff8880ae900000(0000) knlGS:0000000000000000
>CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
>CR2: 0000000020000280 CR3: 0000000096e4c000 CR4: 00000000001406e0
>DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
>DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
>Call Trace:
> new_vport+0x1b/0x1d0 net/openvswitch/datapath.c:194
> ovs_dp_cmd_new+0x5e5/0xe30 net/openvswitch/datapath.c:1644
> genl_family_rcv_msg+0x74b/0xf90 net/netlink/genetlink.c:629
> genl_rcv_msg+0xca/0x170 net/netlink/genetlink.c:654
> netlink_rcv_skb+0x177/0x450 net/netlink/af_netlink.c:2477
> genl_rcv+0x29/0x40 net/netlink/genetlink.c:665
> netlink_unicast_kernel net/netlink/af_netlink.c:1302 [inline]
> netlink_unicast+0x531/0x710 net/netlink/af_netlink.c:1328
> netlink_sendmsg+0x8a5/0xd60 net/netlink/af_netlink.c:1917
> sock_sendmsg_nosec net/socket.c:637 [inline]
> sock_sendmsg+0xd7/0x130 net/socket.c:657
> ___sys_sendmsg+0x803/0x920 net/socket.c:2311
> __sys_sendmsg+0x105/0x1d0 net/socket.c:2356
> __do_sys_sendmsg net/socket.c:2365 [inline]
> __se_sys_sendmsg net/socket.c:2363 [inline]
> __x64_sys_sendmsg+0x78/0xb0 net/socket.c:2363
>
>Fixes: ff92741270bf ("net: introduce name_node struct to be used in hashlist")
>Signed-off-by: Eric Dumazet <edumazet@google.com>
>Cc: Jiri Pirko <jiri@mellanox.com>
>Reported-by: syzbot <syzkaller@googlegroups.com>

Reviewed-by: Jiri Pirko <jiri@mellanox.com>

Thanks!

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

* Re: [PATCH net-next] net: propagate errors correctly in register_netdevice()
  2019-10-03 15:59 [PATCH net-next] net: propagate errors correctly in register_netdevice() Eric Dumazet
  2019-10-03 19:01 ` Willem de Bruijn
  2019-10-03 19:18 ` Jiri Pirko
@ 2019-10-03 19:31 ` David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2019-10-03 19:31 UTC (permalink / raw)
  To: edumazet; +Cc: netdev, eric.dumazet, jiri, syzkaller

From: Eric Dumazet <edumazet@google.com>
Date: Thu,  3 Oct 2019 08:59:24 -0700

> If netdev_name_node_head_alloc() fails to allocate
> memory, we absolutely want register_netdevice() to return
> -ENOMEM instead of zero :/
> 
> One of the syzbot report looked like :
> 
> general protection fault: 0000 [#1] PREEMPT SMP KASAN
 ...
> Fixes: ff92741270bf ("net: introduce name_node struct to be used in hashlist")
> Signed-off-by: Eric Dumazet <edumazet@google.com>
> Cc: Jiri Pirko <jiri@mellanox.com>
> Reported-by: syzbot <syzkaller@googlegroups.com>

Applied.

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

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

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-03 15:59 [PATCH net-next] net: propagate errors correctly in register_netdevice() Eric Dumazet
2019-10-03 19:01 ` Willem de Bruijn
2019-10-03 19:18 ` Jiri Pirko
2019-10-03 19:31 ` 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).