Skip to contentSkip to conversation

ipv6: Fix crash when IPv6 is administratively disabled

PATCH Applied Ido Schimmel 3 participants 3 messages Sep 16, 2022 – Sep 20, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ipv6: Fix crash when IPv6 is administratively disabled

The global 'raw_v6_hashinfo' variable can be accessed even when IPv6 is administratively disabled via the 'ipv6.disable=1' kernel command line option, leading to a crash [1].

Fix by restoring the original behavior and always initializing the variable, regardless of IPv6 support being administratively disabled or not.

[1]

 BUG: unable to handle page fault for address: ffffffffffffffc8
 #PF: supervisor read access in kernel mode
 #PF: error_code(0x0000) - not-present page
 PGD 173e18067 P4D 173e18067 PUD 173e1a067 PMD 0
 Oops: 0000 [#1] PREEMPT SMP KASAN
 CPU: 3 PID: 271 Comm: ss Not tainted 6.0.0-rc4-custom-00136-g0727a9a5fbc1 #1396
 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.16.0-1.fc36 04/01/2014
 RIP: 0010:raw_diag_dump+0x310/0x7f0
 [...]
 Call Trace:
  <TASK>
  __inet_diag_dump+0x10f/0x2e0
  netlink_dump+0x575/0xfd0
  __netlink_dump_start+0x67b/0x940
  inet_diag_handler_cmd+0x273/0x2d0
  sock_diag_rcv_msg+0x317/0x440
  netlink_rcv_skb+0x15e/0x430
  sock_diag_rcv+0x2b/0x40
  netlink_unicast+0x53b/0x800
  netlink_sendmsg+0x945/0xe60
  ____sys_sendmsg+0x747/0x960
  ___sys_sendmsg+0x13a/0x1e0
  __sys_sendmsg+0x118/0x1e0
  do_syscall_64+0x34/0x80
  entry_SYSCALL_64_after_hwframe+0x63/0xcd
Fixes 1da177e4c3f4 ("Linux-2.6.12-rc2")
Fixes 0daf07e52709 ("raw: convert raw sockets to RCU")
---
 net/ipv6/af_inet6.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
net/ipv6/af_inet6.c +2 -2
index 2ce0c44d0081..dbb1430d6cc2 100644
@@ -1070,13 +1070,13 @@ static int __init inet6_init(void)
 	for (r = &inetsw6[0]; r < &inetsw6[SOCK_MAX]; ++r)
 		INIT_LIST_HEAD(r);
 
+	raw_hashinfo_init(&raw_v6_hashinfo);
+
 	if (disable_ipv6_mod) {
 		pr_info("Loaded, but administratively disabled, reboot required to enable\n");
 		goto out;
 	}
 
-	raw_hashinfo_init(&raw_v6_hashinfo);
-
 	err = proto_register(&tcpv6_prot, 1);
 	if (err)
 		goto out;
Signature · 1 line
2.37.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 8 lines · Ido Schimmel

The global 'raw_v6_hashinfo' variable can be accessed even when IPv6 is administratively disabled via the 'ipv6.disable=1' kernel command line option, leading to a crash [1].

Fix by restoring the original behavior and always initializing the variable, regardless of IPv6 support being administratively disabled or not.

...

Quoted 9 lines
Fixes 1da177e4c3f4 ("Linux-2.6.12-rc2")
Fixes 0daf07e52709 ("raw: convert raw sockets to RCU")
---
 net/ipv6/af_inet6.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
#2 lore raw
In reply to Ido Schimmel
This patch was applied to netdev/net.git (master) by Jakub Kicinski <[email protected]>:

Hello:

This patch was applied to netdev/net.git (master)
by Jakub Kicinski <[email protected]>:

Quoted 9 lines · On Fri, 16 Sep 2022 11:48:21 +0300 you wrote:

The global 'raw_v6_hashinfo' variable can be accessed even when IPv6 is administratively disabled via the 'ipv6.disable=1' kernel command line option, leading to a crash [1].

Fix by restoring the original behavior and always initializing the variable, regardless of IPv6 support being administratively disabled or not.

[...]

Here is the summary with links:
- [net] ipv6: Fix crash when IPv6 is administratively disabled

    https://git.kernel.org/netdev/net/c/76dd07281338

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html