Skip to content

Commit a03dc36

Browse files
qsndavem330
authored andcommitted
ipv6: fix cleanup ordering for pingv6 registration
Commit 6d0bfe2 ("net: ipv6: Add IPv6 support to the ping socket.") contains an error in the cleanup path of inet6_init(): when proto_register(&pingv6_prot, 1) fails, we try to unregister &pingv6_prot. When rawv6_init() fails, we skip unregistering &pingv6_prot. Example of panic (triggered by faking a failure of proto_register(&pingv6_prot, 1)): general protection fault: 0000 [#1] PREEMPT SMP KASAN PTI [...] RIP: 0010:__list_del_entry_valid+0x79/0x160 [...] Call Trace: proto_unregister+0xbb/0x550 ? trace_preempt_on+0x6f0/0x6f0 ? sock_no_shutdown+0x10/0x10 inet6_init+0x153/0x1b8 Fixes: 6d0bfe2 ("net: ipv6: Add IPv6 support to the ping socket.") Signed-off-by: Sabrina Dubroca <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent afe49de commit a03dc36

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

net/ipv6/af_inet6.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -938,14 +938,14 @@ static int __init inet6_init(void)
938938

939939
err = proto_register(&pingv6_prot, 1);
940940
if (err)
941-
goto out_unregister_ping_proto;
941+
goto out_unregister_raw_proto;
942942

943943
/* We MUST register RAW sockets before we create the ICMP6,
944944
* IGMP6, or NDISC control sockets.
945945
*/
946946
err = rawv6_init();
947947
if (err)
948-
goto out_unregister_raw_proto;
948+
goto out_unregister_ping_proto;
949949

950950
/* Register the family here so that the init calls below will
951951
* be able to create sockets. (?? is this dangerous ??)

0 commit comments

Comments
 (0)