Commit 5559cea2 authored by Vasiliy Kovalev's avatar Vasiliy Kovalev Committed by Paolo Abeni

ipv6: sr: fix possible use-after-free and null-ptr-deref

The pernet operations structure for the subsystem must be registered
before registering the generic netlink family.

Fixes: 915d7e5e ("ipv6: sr: add code base for control plane support of SR-IPv6")
Signed-off-by: default avatarVasiliy Kovalev <kovalev@altlinux.org>
Link: https://lore.kernel.org/r/20240215202717.29815-1-kovalev@altlinux.orgSigned-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
parent 40b9385d
...@@ -512,22 +512,24 @@ int __init seg6_init(void) ...@@ -512,22 +512,24 @@ int __init seg6_init(void)
{ {
int err; int err;
err = genl_register_family(&seg6_genl_family); err = register_pernet_subsys(&ip6_segments_ops);
if (err) if (err)
goto out; goto out;
err = register_pernet_subsys(&ip6_segments_ops); err = genl_register_family(&seg6_genl_family);
if (err) if (err)
goto out_unregister_genl; goto out_unregister_pernet;
#ifdef CONFIG_IPV6_SEG6_LWTUNNEL #ifdef CONFIG_IPV6_SEG6_LWTUNNEL
err = seg6_iptunnel_init(); err = seg6_iptunnel_init();
if (err) if (err)
goto out_unregister_pernet; goto out_unregister_genl;
err = seg6_local_init(); err = seg6_local_init();
if (err) if (err) {
goto out_unregister_pernet; seg6_iptunnel_exit();
goto out_unregister_genl;
}
#endif #endif
#ifdef CONFIG_IPV6_SEG6_HMAC #ifdef CONFIG_IPV6_SEG6_HMAC
...@@ -548,11 +550,11 @@ int __init seg6_init(void) ...@@ -548,11 +550,11 @@ int __init seg6_init(void)
#endif #endif
#endif #endif
#ifdef CONFIG_IPV6_SEG6_LWTUNNEL #ifdef CONFIG_IPV6_SEG6_LWTUNNEL
out_unregister_pernet:
unregister_pernet_subsys(&ip6_segments_ops);
#endif
out_unregister_genl: out_unregister_genl:
genl_unregister_family(&seg6_genl_family); genl_unregister_family(&seg6_genl_family);
#endif
out_unregister_pernet:
unregister_pernet_subsys(&ip6_segments_ops);
goto out; goto out;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment