2017-11-05 10:03:01

by Vasily Averin

[permalink] [raw]
Subject: [PATCH 21/21] sunrpc: exit_net cleanup check added

Be sure that all_clients list initialized in net_init hook was return
to initial state.

Signed-off-by: Vasily Averin <[email protected]>
---
net/sunrpc/sunrpc_syms.c | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/net/sunrpc/sunrpc_syms.c b/net/sunrpc/sunrpc_syms.c
index c73de18..0c5a90f 100644
--- a/net/sunrpc/sunrpc_syms.c
+++ b/net/sunrpc/sunrpc_syms.c
@@ -65,10 +65,14 @@ static __net_init int sunrpc_init_net(struct net *net)

static __net_exit void sunrpc_exit_net(struct net *net)
{
+ struct sunrpc_net *sn = net_generic(net, sunrpc_net_id);
+
rpc_pipefs_exit_net(net);
unix_gid_cache_destroy(net);
ip_map_cache_destroy(net);
rpc_proc_exit(net);
+ WARN(!list_empty(&sn->all_clients),
+ "net %p exit: sunrpc all_clients list is not empty\n", net);
}

static struct pernet_operations sunrpc_net_ops = {
--
2.7.4



2017-11-08 01:22:49

by Stephen Hemminger

[permalink] [raw]
Subject: Re: [PATCH 21/21] sunrpc: exit_net cleanup check added

On Sun, 5 Nov 2017 13:02:44 +0300
Vasily Averin <[email protected]> wrote:

> Be sure that all_clients list initialized in net_init hook was return
> to initial state.
>
> Signed-off-by: Vasily Averin <[email protected]>
> ---
> net/sunrpc/sunrpc_syms.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/net/sunrpc/sunrpc_syms.c b/net/sunrpc/sunrpc_syms.c
> index c73de18..0c5a90f 100644
> --- a/net/sunrpc/sunrpc_syms.c
> +++ b/net/sunrpc/sunrpc_syms.c
> @@ -65,10 +65,14 @@ static __net_init int sunrpc_init_net(struct net *net)
>
> static __net_exit void sunrpc_exit_net(struct net *net)
> {
> + struct sunrpc_net *sn = net_generic(net, sunrpc_net_id);
> +
> rpc_pipefs_exit_net(net);
> unix_gid_cache_destroy(net);
> ip_map_cache_destroy(net);
> rpc_proc_exit(net);
> + WARN(!list_empty(&sn->all_clients),
> + "net %p exit: sunrpc all_clients list is not empty\n", net);
> }

Don't print a kernel pointer, this is a security leak.

2017-11-08 04:50:41

by Vasily Averin

[permalink] [raw]
Subject: Re: [PATCH 21/21] sunrpc: exit_net cleanup check added

On 2017-11-08 04:22, Stephen Hemminger wrote:
> On Sun, 5 Nov 2017 13:02:44 +0300
> Vasily Averin <[email protected]> wrote:
>> + WARN(!list_empty(&sn->all_clients),
>> + "net %p exit: sunrpc all_clients list is not empty\n", net);
>
> Don't print a kernel pointer, this is a security leak.

Yes, you're right, I've submitted fixed patch in v3 already,
but seems will prepare v4 with simple WARN_ON_ONCE(!list_empty())