netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net] devlink: Fix crash with CONFIG_NET_NS=n
@ 2023-05-15 16:29 Ido Schimmel
  2023-05-16  8:09 ` Jiri Pirko
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Ido Schimmel @ 2023-05-15 16:29 UTC (permalink / raw)
  To: netdev
  Cc: davem, kuba, pabeni, edumazet, jiri, simon.horman, m.szyprowski,
	Ido Schimmel

'__net_initdata' becomes a no-op with CONFIG_NET_NS=y, but when this
option is disabled it becomes '__initdata', which means the data can be
freed after the initialization phase. This annotation is obviously
incorrect for the devlink net device notifier block which is still
registered after the initialization phase [1].

Fix this crash by removing the '__net_initdata' annotation.

[1]
general protection fault, probably for non-canonical address 0xcccccccccccccccc: 0000 [#1] PREEMPT SMP
CPU: 3 PID: 117 Comm: (udev-worker) Not tainted 6.4.0-rc1-custom-gdf0acdc59b09 #64
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.16.2-1.fc37 04/01/2014
RIP: 0010:notifier_call_chain+0x58/0xc0
[...]
Call Trace:
 <TASK>
 dev_set_mac_address+0x85/0x120
 dev_set_mac_address_user+0x30/0x50
 do_setlink+0x219/0x1270
 rtnl_setlink+0xf7/0x1a0
 rtnetlink_rcv_msg+0x142/0x390
 netlink_rcv_skb+0x58/0x100
 netlink_unicast+0x188/0x270
 netlink_sendmsg+0x214/0x470
 __sys_sendto+0x12f/0x1a0
 __x64_sys_sendto+0x24/0x30
 do_syscall_64+0x38/0x80
 entry_SYSCALL_64_after_hwframe+0x63/0xcd

Fixes: e93c9378e33f ("devlink: change per-devlink netdev notifier to static one")
Reported-by: Marek Szyprowski <m.szyprowski@samsung.com>
Closes: https://lore.kernel.org/netdev/600ddf9e-589a-2aa0-7b69-a438f833ca10@samsung.com/
Tested-by: Marek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
---
 net/devlink/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/devlink/core.c b/net/devlink/core.c
index 0e58eee44bdb..c23ebabadc52 100644
--- a/net/devlink/core.c
+++ b/net/devlink/core.c
@@ -294,7 +294,7 @@ static struct pernet_operations devlink_pernet_ops __net_initdata = {
 	.pre_exit = devlink_pernet_pre_exit,
 };
 
-static struct notifier_block devlink_port_netdevice_nb __net_initdata = {
+static struct notifier_block devlink_port_netdevice_nb = {
 	.notifier_call = devlink_port_netdevice_event,
 };
 
-- 
2.40.1


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

* Re: [PATCH net] devlink: Fix crash with CONFIG_NET_NS=n
  2023-05-15 16:29 [PATCH net] devlink: Fix crash with CONFIG_NET_NS=n Ido Schimmel
@ 2023-05-16  8:09 ` Jiri Pirko
  2023-05-16  8:27 ` Simon Horman
  2023-05-17  3:20 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: Jiri Pirko @ 2023-05-16  8:09 UTC (permalink / raw)
  To: Ido Schimmel
  Cc: netdev, davem, kuba, pabeni, edumazet, simon.horman, m.szyprowski

Mon, May 15, 2023 at 06:29:25PM CEST, idosch@nvidia.com wrote:
>'__net_initdata' becomes a no-op with CONFIG_NET_NS=y, but when this
>option is disabled it becomes '__initdata', which means the data can be
>freed after the initialization phase. This annotation is obviously
>incorrect for the devlink net device notifier block which is still
>registered after the initialization phase [1].
>
>Fix this crash by removing the '__net_initdata' annotation.
>
>[1]
>general protection fault, probably for non-canonical address 0xcccccccccccccccc: 0000 [#1] PREEMPT SMP
>CPU: 3 PID: 117 Comm: (udev-worker) Not tainted 6.4.0-rc1-custom-gdf0acdc59b09 #64
>Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.16.2-1.fc37 04/01/2014
>RIP: 0010:notifier_call_chain+0x58/0xc0
>[...]
>Call Trace:
> <TASK>
> dev_set_mac_address+0x85/0x120
> dev_set_mac_address_user+0x30/0x50
> do_setlink+0x219/0x1270
> rtnl_setlink+0xf7/0x1a0
> rtnetlink_rcv_msg+0x142/0x390
> netlink_rcv_skb+0x58/0x100
> netlink_unicast+0x188/0x270
> netlink_sendmsg+0x214/0x470
> __sys_sendto+0x12f/0x1a0
> __x64_sys_sendto+0x24/0x30
> do_syscall_64+0x38/0x80
> entry_SYSCALL_64_after_hwframe+0x63/0xcd
>
>Fixes: e93c9378e33f ("devlink: change per-devlink netdev notifier to static one")
>Reported-by: Marek Szyprowski <m.szyprowski@samsung.com>
>Closes: https://lore.kernel.org/netdev/600ddf9e-589a-2aa0-7b69-a438f833ca10@samsung.com/
>Tested-by: Marek Szyprowski <m.szyprowski@samsung.com>
>Signed-off-by: Ido Schimmel <idosch@nvidia.com>

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

Thanks!

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

* Re: [PATCH net] devlink: Fix crash with CONFIG_NET_NS=n
  2023-05-15 16:29 [PATCH net] devlink: Fix crash with CONFIG_NET_NS=n Ido Schimmel
  2023-05-16  8:09 ` Jiri Pirko
@ 2023-05-16  8:27 ` Simon Horman
  2023-05-17  3:20 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: Simon Horman @ 2023-05-16  8:27 UTC (permalink / raw)
  To: Ido Schimmel; +Cc: netdev, davem, kuba, pabeni, edumazet, jiri, m.szyprowski

On Mon, May 15, 2023 at 07:29:25PM +0300, Ido Schimmel wrote:
> '__net_initdata' becomes a no-op with CONFIG_NET_NS=y, but when this
> option is disabled it becomes '__initdata', which means the data can be
> freed after the initialization phase. This annotation is obviously
> incorrect for the devlink net device notifier block which is still
> registered after the initialization phase [1].
> 
> Fix this crash by removing the '__net_initdata' annotation.
> 
> [1]
> general protection fault, probably for non-canonical address 0xcccccccccccccccc: 0000 [#1] PREEMPT SMP
> CPU: 3 PID: 117 Comm: (udev-worker) Not tainted 6.4.0-rc1-custom-gdf0acdc59b09 #64
> Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.16.2-1.fc37 04/01/2014
> RIP: 0010:notifier_call_chain+0x58/0xc0
> [...]
> Call Trace:
>  <TASK>
>  dev_set_mac_address+0x85/0x120
>  dev_set_mac_address_user+0x30/0x50
>  do_setlink+0x219/0x1270
>  rtnl_setlink+0xf7/0x1a0
>  rtnetlink_rcv_msg+0x142/0x390
>  netlink_rcv_skb+0x58/0x100
>  netlink_unicast+0x188/0x270
>  netlink_sendmsg+0x214/0x470
>  __sys_sendto+0x12f/0x1a0
>  __x64_sys_sendto+0x24/0x30
>  do_syscall_64+0x38/0x80
>  entry_SYSCALL_64_after_hwframe+0x63/0xcd
> 
> Fixes: e93c9378e33f ("devlink: change per-devlink netdev notifier to static one")
> Reported-by: Marek Szyprowski <m.szyprowski@samsung.com>
> Closes: https://lore.kernel.org/netdev/600ddf9e-589a-2aa0-7b69-a438f833ca10@samsung.com/
> Tested-by: Marek Szyprowski <m.szyprowski@samsung.com>
> Signed-off-by: Ido Schimmel <idosch@nvidia.com>

Reviewed-by: Simon Horman <simon.horman@corigine.com>


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

* Re: [PATCH net] devlink: Fix crash with CONFIG_NET_NS=n
  2023-05-15 16:29 [PATCH net] devlink: Fix crash with CONFIG_NET_NS=n Ido Schimmel
  2023-05-16  8:09 ` Jiri Pirko
  2023-05-16  8:27 ` Simon Horman
@ 2023-05-17  3:20 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2023-05-17  3:20 UTC (permalink / raw)
  To: Ido Schimmel
  Cc: netdev, davem, kuba, pabeni, edumazet, jiri, simon.horman,
	m.szyprowski

Hello:

This patch was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Mon, 15 May 2023 19:29:25 +0300 you wrote:
> '__net_initdata' becomes a no-op with CONFIG_NET_NS=y, but when this
> option is disabled it becomes '__initdata', which means the data can be
> freed after the initialization phase. This annotation is obviously
> incorrect for the devlink net device notifier block which is still
> registered after the initialization phase [1].
> 
> Fix this crash by removing the '__net_initdata' annotation.
> 
> [...]

Here is the summary with links:
  - [net] devlink: Fix crash with CONFIG_NET_NS=n
    https://git.kernel.org/netdev/net/c/d6352dae0903

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

end of thread, other threads:[~2023-05-17  3:20 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-15 16:29 [PATCH net] devlink: Fix crash with CONFIG_NET_NS=n Ido Schimmel
2023-05-16  8:09 ` Jiri Pirko
2023-05-16  8:27 ` Simon Horman
2023-05-17  3:20 ` patchwork-bot+netdevbpf

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