]> git.baikalelectronics.ru Git - kernel.git/commit
ipv6: fix cleanup ordering for pingv6 registration
authorSabrina Dubroca <sd@queasysnail.net>
Tue, 28 Aug 2018 11:40:52 +0000 (13:40 +0200)
committerDavid S. Miller <davem@davemloft.net>
Thu, 30 Aug 2018 02:28:55 +0000 (19:28 -0700)
commit1b2dc3b1a115c31fcfc331b24c4caa92311f2055
tree410ce268f8afce36c0bb58573f76d925bb7fb58d
parentf580848c892f0d14362e1f5f24b898d505a7364c
ipv6: fix cleanup ordering for pingv6 registration

Commit 2c41d119cad3 ("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: 2c41d119cad3 ("net: ipv6: Add IPv6 support to the ping socket.")
Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/ipv6/af_inet6.c