netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net] net: sched: fix NULL pointer dereference when action calls some targets
@ 2017-08-05 11:35 Xin Long
  2017-08-07 21:15 ` Cong Wang
  0 siblings, 1 reply; 11+ messages in thread
From: Xin Long @ 2017-08-05 11:35 UTC (permalink / raw)
  To: network dev; +Cc: davem

As we know in some target's checkentry it may dereference par.entryinfo
to check entry stuff inside. But when sched action calls xt_check_target,
par.entryinfo is set with NULL. It would cause kernel panic when calling
some targets.

It can be reproduce with:
  # tc qd add dev eth1 ingress handle ffff:
  # tc filter add dev eth1 parent ffff: u32 match u32 0 0 action xt \
    -j ECN --ecn-tcp-remove

It could also crash kernel when using target CLUSTERIP or TPROXY.

By now there's no proper value for par.entryinfo in ipt_init_target,
but it can not be set with NULL. This patch is to void all these
panics by setting it with an ipt_entry obj with all members 0.

Signed-off-by: Xin Long <lucien.xin@gmail.com>
---
 net/sched/act_ipt.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/net/sched/act_ipt.c b/net/sched/act_ipt.c
index 7c4816b..0f09f70 100644
--- a/net/sched/act_ipt.c
+++ b/net/sched/act_ipt.c
@@ -41,6 +41,7 @@ static int ipt_init_target(struct net *net, struct xt_entry_target *t,
 {
 	struct xt_tgchk_param par;
 	struct xt_target *target;
+	struct ipt_entry e;
 	int ret = 0;
 
 	target = xt_request_find_target(AF_INET, t->u.user.name,
@@ -48,10 +49,11 @@ static int ipt_init_target(struct net *net, struct xt_entry_target *t,
 	if (IS_ERR(target))
 		return PTR_ERR(target);
 
+	memset(&e, 0, sizeof(e));
 	t->u.kernel.target = target;
 	par.net       = net;
 	par.table     = table;
-	par.entryinfo = NULL;
+	par.entryinfo = &e;
 	par.target    = target;
 	par.targinfo  = t->data;
 	par.hook_mask = hook;
-- 
2.1.0

^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2017-08-17 12:45 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-08-05 11:35 [PATCH net] net: sched: fix NULL pointer dereference when action calls some targets Xin Long
2017-08-07 21:15 ` Cong Wang
2017-08-08  2:33   ` Xin Long
2017-08-08 19:33     ` Cong Wang
2017-08-16  8:39       ` Xin Long
2017-08-17  5:57         ` Cong Wang
2017-08-17  7:45           ` Xin Long
2017-08-17 10:02         ` Pablo Neira Ayuso
2017-08-17 10:33           ` Pablo Neira Ayuso
2017-08-17 11:24             ` Xin Long
2017-08-17 12:44               ` Pablo Neira Ayuso

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).