All of lore.kernel.org
 help / color / mirror / Atom feed
* [Patch net] net_sched: check error pointer in tcf_dump_walker()
@ 2020-10-02 19:13 Cong Wang
  2020-10-04 21:54 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Cong Wang @ 2020-10-02 19:13 UTC (permalink / raw)
  To: netdev
  Cc: Cong Wang, syzbot+b47bc4f247856fb4d9e1, Vlad Buslov,
	Jamal Hadi Salim, Jiri Pirko

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: syzbot+b47bc4f247856fb4d9e1@syzkaller.appspotmail.com
Fixes: 0fedc63fadf0 ("net_sched: commit action insertions together")
Cc: Vlad Buslov <vladbu@mellanox.com>
Cc: Jamal Hadi Salim <jhs@mojatatu.com>
Cc: Jiri Pirko <jiri@resnulli.us>
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
---
 net/sched/act_api.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/net/sched/act_api.c b/net/sched/act_api.c
index 5612b336e18e..798430e1a79f 100644
--- a/net/sched/act_api.c
+++ b/net/sched/act_api.c
@@ -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,
-- 
2.28.0


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

* Re: [Patch net] net_sched: check error pointer in tcf_dump_walker()
  2020-10-02 19:13 [Patch net] net_sched: check error pointer in tcf_dump_walker() Cong Wang
@ 2020-10-04 21:54 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2020-10-04 21:54 UTC (permalink / raw)
  To: xiyou.wangcong; +Cc: netdev, syzbot+b47bc4f247856fb4d9e1, vladbu, jhs, jiri

From: Cong Wang <xiyou.wangcong@gmail.com>
Date: Fri,  2 Oct 2020 12:13:34 -0700

> 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: syzbot+b47bc4f247856fb4d9e1@syzkaller.appspotmail.com
> Fixes: 0fedc63fadf0 ("net_sched: commit action insertions together")
> Cc: Vlad Buslov <vladbu@mellanox.com>
> Cc: Jamal Hadi Salim <jhs@mojatatu.com>
> Cc: Jiri Pirko <jiri@resnulli.us>
> Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>

Applied and queued up for -stable.

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

end of thread, other threads:[~2020-10-04 21:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-02 19:13 [Patch net] net_sched: check error pointer in tcf_dump_walker() Cong Wang
2020-10-04 21:54 ` David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.