Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 981471bd authored by Cong Wang's avatar Cong Wang Committed by David S. Miller
Browse files

net_sched: fix a NULL pointer deref in ipt action



The net pointer in struct xt_tgdtor_param is not explicitly
initialized therefore is still NULL when dereferencing it.
So we have to find a way to pass the correct net pointer to
ipt_destroy_target().

The best way I find is just saving the net pointer inside the per
netns struct tcf_idrinfo, which could make this patch smaller.

Fixes: 0c66dc1e ("netfilter: conntrack: register hooks in netns when needed by ruleset")
Reported-and-tested-by: default avatar <itugrok@yahoo.com>
Cc: Jamal Hadi Salim <jhs@mojatatu.com>
Cc: Jiri Pirko <jiri@resnulli.us>
Signed-off-by: default avatarCong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 9e8312f5
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -15,6 +15,7 @@
struct tcf_idrinfo {
	struct mutex	lock;
	struct idr	action_idr;
	struct net	*net;
};

struct tc_action_ops;
@@ -108,7 +109,7 @@ struct tc_action_net {
};

static inline
int tc_action_net_init(struct tc_action_net *tn,
int tc_action_net_init(struct net *net, struct tc_action_net *tn,
		       const struct tc_action_ops *ops)
{
	int err = 0;
@@ -117,6 +118,7 @@ int tc_action_net_init(struct tc_action_net *tn,
	if (!tn->idrinfo)
		return -ENOMEM;
	tn->ops = ops;
	tn->idrinfo->net = net;
	mutex_init(&tn->idrinfo->lock);
	idr_init(&tn->idrinfo->action_idr);
	return err;
+1 −1
Original line number Diff line number Diff line
@@ -422,7 +422,7 @@ static __net_init int bpf_init_net(struct net *net)
{
	struct tc_action_net *tn = net_generic(net, bpf_net_id);

	return tc_action_net_init(tn, &act_bpf_ops);
	return tc_action_net_init(net, tn, &act_bpf_ops);
}

static void __net_exit bpf_exit_net(struct list_head *net_list)
+1 −1
Original line number Diff line number Diff line
@@ -231,7 +231,7 @@ static __net_init int connmark_init_net(struct net *net)
{
	struct tc_action_net *tn = net_generic(net, connmark_net_id);

	return tc_action_net_init(tn, &act_connmark_ops);
	return tc_action_net_init(net, tn, &act_connmark_ops);
}

static void __net_exit connmark_exit_net(struct list_head *net_list)
+1 −1
Original line number Diff line number Diff line
@@ -714,7 +714,7 @@ static __net_init int csum_init_net(struct net *net)
{
	struct tc_action_net *tn = net_generic(net, csum_net_id);

	return tc_action_net_init(tn, &act_csum_ops);
	return tc_action_net_init(net, tn, &act_csum_ops);
}

static void __net_exit csum_exit_net(struct list_head *net_list)
+1 −1
Original line number Diff line number Diff line
@@ -939,7 +939,7 @@ static __net_init int ct_init_net(struct net *net)
		tn->labels = true;
	}

	return tc_action_net_init(&tn->tn, &act_ct_ops);
	return tc_action_net_init(net, &tn->tn, &act_ct_ops);
}

static void __net_exit ct_exit_net(struct list_head *net_list)
Loading