Skip to contentSkip to conversation

net_sched: check error pointer in tcf_dump_walker()

PATCH In review Cong Wang 2 participants 2 messages Oct 2, 2020 – Oct 4, 2020

Subsystems (3)
lore
Share & tools
lore

Cong Wang

author
#0 lore raw

PATCH 1/1 net_sched: check error pointer in tcf_dump_walker()

Although we take RTNL on dump path, it is possible to skip RTNL on insertion path. So the following race condition is possible:

rtnl_lock() // no rtnl lock

			mutex_lock(&idrinfo->lock);
			// insert ERR_PTR(-EBUSY)
			mutex_unlock(&idrinfo->lock);

tc_dump_action()
rtnl_unlock()

So we have to skip those temporary -EBUSY entries on dump path too.

Reported-and-tested-by [email protected]
Fixes 0fedc63fadf0 ("net_sched: commit action insertions together")
Cc Vlad Buslov <[email protected]>
Cc Jamal Hadi Salim <[email protected]>
Cc Jiri Pirko <[email protected]>
---
 net/sched/act_api.c | 2 ++
 1 file changed, 2 insertions(+)
net/sched/act_api.c +2 -0
index 5612b336e18e..798430e1a79f 100644
@@ -235,6 +235,8 @@ static int tcf_dump_walker(struct tcf_idrinfo *idrinfo, struct sk_buff *skb,
 		index++;
 		if (index < s_i)
 			continue;
+		if (IS_ERR(p))
+			continue;
 
 		if (jiffy_since &&
 		    time_after(jiffy_since,
Signature · 1 line
2.28.0
maintainer
#1 lore raw

From: Cong Wang <[email protected]>
Date: Fri, 2 Oct 2020 12:13:34 -0700

Quoted 14 lines

Although we take RTNL on dump path, it is possible to skip RTNL on insertion path. So the following race condition is possible:

rtnl_lock() // no rtnl lock

			mutex_lock(&idrinfo->lock);
			// insert ERR_PTR(-EBUSY)
			mutex_unlock(&idrinfo->lock);

tc_dump_action()
rtnl_unlock()

So we have to skip those temporary -EBUSY entries on dump path too.

Quoted 6 lines
Reported-and-tested-by [email protected]
Fixes 0fedc63fadf0 ("net_sched: commit action insertions together")
Cc Vlad Buslov <[email protected]>
Cc Jamal Hadi Salim <[email protected]>
Cc Jiri Pirko <[email protected]>

Applied and queued up for -stable.