In nsim_fib_init(),if register_fib_notifier failed,nsim_fib_net_ops should be unregistered before return;
In nsim_fib_exit(),unregister_fib_notifier should be called before nsim_fib_net_ops be unregistered, otherwise may cause use-after-free
More detailed information can refer to: https://lkml.org/lkml/2019/10/11/216 kernel inclusion from:kernel-4.19 commit:2dca76fa95bf03c15bdcacd7cfa8f974c1a799f6 category:bugfix bugzilla:NA CVE:NA
Signed-off-by: liaichun 513565428@qq.com DESC:fix netdevsim resource leak
--- drivers/net/netdevsim/fib.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/net/netdevsim/fib.c b/drivers/net/netdevsim/fib.c index f61d094..d5c01b8 100644 --- a/drivers/net/netdevsim/fib.c +++ b/drivers/net/netdevsim/fib.c @@ -241,8 +241,8 @@ static int __net_init nsim_fib_netns_init(struct net *net)
void nsim_fib_exit(void) { - unregister_pernet_subsys(&nsim_fib_net_ops); unregister_fib_notifier(&nsim_fib_nb); + unregister_pernet_subsys(&nsim_fib_net_ops); }
int nsim_fib_init(void) @@ -257,6 +257,7 @@ int nsim_fib_init(void)
err = register_fib_notifier(&nsim_fib_nb, nsim_fib_dump_inconsistent); if (err < 0) { + unregister_pernet_subsys(&nsim_fib_net_ops); pr_err("Failed to register fib notifier\n"); goto err_out; }
Hi,
Thank you for the patch! Perhaps something to improve:
1) patch 标题使用原 Patch 标题。 2) patch 作者等信息也保留原 patch 的信息。
On 2020/6/8 22:58, liaichun wrote:
In nsim_fib_init(),if register_fib_notifier failed,nsim_fib_net_ops should be unregistered before return;
In nsim_fib_exit(),unregister_fib_notifier should be called before nsim_fib_net_ops be unregistered, otherwise may cause use-after-free
More detailed information can refer to: https://lkml.org/lkml/2019/10/11/216 kernel inclusion
如果是主线补丁的话,使用 mainline inclusion
from:kernel-4.19
from 是主线对应的版本
commit:2dca76fa95bf03c15bdcacd7cfa8f974c1a799f6
这个 commit 也是主线对应的commit,你这个 commit 我没找到。
category:bugfix bugzilla:NA CVE:NA
你的签名签名要有保留原patch的签名和 review 信息。
Signed-off-by: liaichun 513565428@qq.com DESC:fix netdevsim resource leak
drivers/net/netdevsim/fib.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/net/netdevsim/fib.c b/drivers/net/netdevsim/fib.c index f61d094..d5c01b8 100644 --- a/drivers/net/netdevsim/fib.c +++ b/drivers/net/netdevsim/fib.c @@ -241,8 +241,8 @@ static int __net_init nsim_fib_netns_init(struct net *net)
void nsim_fib_exit(void) {
- unregister_pernet_subsys(&nsim_fib_net_ops); unregister_fib_notifier(&nsim_fib_nb);
- unregister_pernet_subsys(&nsim_fib_net_ops);
}
int nsim_fib_init(void) @@ -257,6 +257,7 @@ int nsim_fib_init(void)
err = register_fib_notifier(&nsim_fib_nb, nsim_fib_dump_inconsistent); if (err < 0) {
pr_err("Failed to register fib notifier\n"); goto err_out; }unregister_pernet_subsys(&nsim_fib_net_ops);