]> git.baikalelectronics.ru Git - kernel.git/commit
net: rtnl: return early from rtnl_unregister_all when protocol isn't registered
authorSabrina Dubroca <sd@queasysnail.net>
Tue, 28 Aug 2018 11:40:53 +0000 (13:40 +0200)
committerDavid S. Miller <davem@davemloft.net>
Thu, 30 Aug 2018 02:28:55 +0000 (19:28 -0700)
commitb1a3b83f4f0f8e92df75e044f06e88d89bbcd516
tree45c00ac0e6e8a7daaf4f47761d6f6f355271d815
parent1b2dc3b1a115c31fcfc331b24c4caa92311f2055
net: rtnl: return early from rtnl_unregister_all when protocol isn't registered

rtnl_unregister_all(PF_INET6) gets called from inet6_init in cases when
no handler has been registered for PF_INET6 yet, for example if
ip6_mr_init() fails. Abort and avoid a NULL pointer deref in that case.

Example of panic (triggered by faking a failure of
 register_pernet_subsys):

    general protection fault: 0000 [#1] PREEMPT SMP KASAN PTI
    [...]
    RIP: 0010:rtnl_unregister_all+0x17e/0x2a0
    [...]
    Call Trace:
     ? rtnetlink_net_init+0x250/0x250
     ? sock_unregister+0x103/0x160
     ? kernel_getsockopt+0x200/0x200
     inet6_init+0x197/0x20d

Fixes: 1d7414ab6605 ("[IPV6]: Make af_inet6 to check ip6_route_init return value.")
Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/core/rtnetlink.c