Skip to content

Commit

Permalink
netfilter: nfnetlink: add netns refcount tracker to struct nfulnl_ins…
Browse files Browse the repository at this point in the history
…tance

If compiled with CONFIG_NET_NS_REFCNT_TRACKER=y,
using put_net_track() in nfulnl_instance_free_rcu()
and get_net_track() in instance_create()
might help us finding netns refcount imbalances.

Signed-off-by: Eric Dumazet <[email protected]>
Signed-off-by: Pablo Neira Ayuso <[email protected]>
  • Loading branch information
Eric Dumazet authored and ummakynes committed Dec 16, 2021
1 parent 604ba23 commit a9382d9
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions net/netfilter/nfnetlink_log.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ struct nfulnl_instance {
struct sk_buff *skb; /* pre-allocatd skb */
struct timer_list timer;
struct net *net;
netns_tracker ns_tracker;
struct user_namespace *peer_user_ns; /* User namespace of the peer process */
u32 peer_portid; /* PORTID of the peer process */

Expand Down Expand Up @@ -140,7 +141,7 @@ static void nfulnl_instance_free_rcu(struct rcu_head *head)
struct nfulnl_instance *inst =
container_of(head, struct nfulnl_instance, rcu);

put_net(inst->net);
put_net_track(inst->net, &inst->ns_tracker);
kfree(inst);
module_put(THIS_MODULE);
}
Expand Down Expand Up @@ -187,7 +188,7 @@ instance_create(struct net *net, u_int16_t group_num,

timer_setup(&inst->timer, nfulnl_timer, 0);

inst->net = get_net(net);
inst->net = get_net_track(net, &inst->ns_tracker, GFP_ATOMIC);
inst->peer_user_ns = user_ns;
inst->peer_portid = portid;
inst->group_num = group_num;
Expand Down

0 comments on commit a9382d9

Please sign in to comment.