Message ID | 20220325165021.570708-1-eric.dumazet@gmail.com (mailing list archive) |
---|---|
State | Accepted |
Commit | 5ae6acf1d00be462d7b08b4a8748798ef595ae5a |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | [net] net/smc: fix a memory leak in smc_sysctl_net_exit() | expand |
Hello: This patch was applied to netdev/net.git (master) by David S. Miller <davem@davemloft.net>: On Fri, 25 Mar 2022 09:50:21 -0700 you wrote: > From: Eric Dumazet <edumazet@google.com> > > Recently added smc_sysctl_net_exit() forgot to free > the memory allocated from smc_sysctl_net_init() > for non initial network namespace. > > Fixes: 462791bbfa35 ("net/smc: add sysctl interface for SMC") > Signed-off-by: Eric Dumazet <edumazet@google.com> > Reported-by: syzbot <syzkaller@googlegroups.com> > Cc: Tony Lu <tonylu@linux.alibaba.com> > Cc: Dust Li <dust.li@linux.alibaba.com> > > [...] Here is the summary with links: - [net] net/smc: fix a memory leak in smc_sysctl_net_exit() https://git.kernel.org/netdev/net/c/5ae6acf1d00b You are awesome, thank you!
On Fri, Mar 25, 2022 at 09:50:21AM -0700, Eric Dumazet wrote: > From: Eric Dumazet <edumazet@google.com> > > Recently added smc_sysctl_net_exit() forgot to free > the memory allocated from smc_sysctl_net_init() > for non initial network namespace. > > Fixes: 462791bbfa35 ("net/smc: add sysctl interface for SMC") > Signed-off-by: Eric Dumazet <edumazet@google.com> > Reported-by: syzbot <syzkaller@googlegroups.com> > Cc: Tony Lu <tonylu@linux.alibaba.com> > Cc: Dust Li <dust.li@linux.alibaba.com> > --- > net/smc/smc_sysctl.c | 5 +++++ > 1 file changed, 5 insertions(+) > > diff --git a/net/smc/smc_sysctl.c b/net/smc/smc_sysctl.c > index bae19419e7553222d74c2ae178fd5a2b6116679b..cf3ab1334c009a1a0539b2c228c4503ae391d89b 100644 > --- a/net/smc/smc_sysctl.c > +++ b/net/smc/smc_sysctl.c > @@ -61,5 +61,10 @@ int __net_init smc_sysctl_net_init(struct net *net) > > void __net_exit smc_sysctl_net_exit(struct net *net) > { > + struct ctl_table *table; > + > + table = net->smc.smc_hdr->ctl_table_arg; > unregister_net_sysctl_table(net->smc.smc_hdr); > + if (!net_eq(net, &init_net)) > + kfree(table); > } Thanks a lot for fixing this issue, this is my fault. Tony Lu
diff --git a/net/smc/smc_sysctl.c b/net/smc/smc_sysctl.c index bae19419e7553222d74c2ae178fd5a2b6116679b..cf3ab1334c009a1a0539b2c228c4503ae391d89b 100644 --- a/net/smc/smc_sysctl.c +++ b/net/smc/smc_sysctl.c @@ -61,5 +61,10 @@ int __net_init smc_sysctl_net_init(struct net *net) void __net_exit smc_sysctl_net_exit(struct net *net) { + struct ctl_table *table; + + table = net->smc.smc_hdr->ctl_table_arg; unregister_net_sysctl_table(net->smc.smc_hdr); + if (!net_eq(net, &init_net)) + kfree(table); }