[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230926182625.72475-1-dg573847474@gmail.com>
Date: Tue, 26 Sep 2023 18:26:25 +0000
From: Chengfeng Ye <dg573847474@...il.com>
To: jhs@...atatu.com, xiyou.wangcong@...il.com, jiri@...nulli.us,
davem@...emloft.net, edumazet@...gle.com, kuba@...nel.org,
pabeni@...hat.com
Cc: netdev@...r.kernel.org, linux-kernel@...r.kernel.org,
Chengfeng Ye <dg573847474@...il.com>
Subject: [PATCH] net/sched: use spin_lock_bh() on &gact->tcf_lock
I find tcf_gate_act() acquires &gact->tcf_lock without disable
bh explicitly, as gact->tcf_lock is acquired inside timer under
softirq context, if tcf_gate_act() is not called with bh disable
by default or under softirq context(which I am not sure as I cannot
find corresponding documentation), then it could be the following
deadlocks.
tcf_gate_act()
--> spin_loc(&gact->tcf_lock)
<interrupt>
--> gate_timer_func()
--> spin_lock(&gact->tcf_lock)
Signed-off-by: Chengfeng Ye <dg573847474@...il.com>
---
net/sched/act_gate.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/net/sched/act_gate.c b/net/sched/act_gate.c
index c9a811f4c7ee..b82daf7401a5 100644
--- a/net/sched/act_gate.c
+++ b/net/sched/act_gate.c
@@ -124,25 +124,25 @@ TC_INDIRECT_SCOPE int tcf_gate_act(struct sk_buff *skb,
tcf_lastuse_update(&gact->tcf_tm);
tcf_action_update_bstats(&gact->common, skb);
- spin_lock(&gact->tcf_lock);
+ spin_lock_bh(&gact->tcf_lock);
if (unlikely(gact->current_gate_status & GATE_ACT_PENDING)) {
- spin_unlock(&gact->tcf_lock);
+ spin_unlock_bh(&gact->tcf_lock);
return action;
}
if (!(gact->current_gate_status & GATE_ACT_GATE_OPEN)) {
- spin_unlock(&gact->tcf_lock);
+ spin_unlock_bh(&gact->tcf_lock);
goto drop;
}
if (gact->current_max_octets >= 0) {
gact->current_entry_octets += qdisc_pkt_len(skb);
if (gact->current_entry_octets > gact->current_max_octets) {
- spin_unlock(&gact->tcf_lock);
+ spin_unlock_bh(&gact->tcf_lock);
goto overlimit;
}
}
- spin_unlock(&gact->tcf_lock);
+ spin_unlock_bh(&gact->tcf_lock);
return action;
--
2.17.1
Powered by blists - more mailing lists