diff mbox series

[net-next] net: sched: tbf: don't call qdisc_put() while holding tree lock

Message ID 20220826011248.323922-1-shaozhengchao@huawei.com (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series [net-next] net: sched: tbf: don't call qdisc_put() while holding tree lock | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix success Link
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers success CCed 9 of 9 maintainers
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 22 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

shaozhengchao Aug. 26, 2022, 1:12 a.m. UTC
The issue is the same to commit c2999f7fb05b ("net: sched: multiq: don't
call qdisc_put() while holding tree lock"). Qdiscs call qdisc_put() while
holding sch tree spinlock, which results sleeping-while-atomic BUG.

Fixes: c266f64dbfa2 ("net: sched: protect block state with mutex")
Signed-off-by: Zhengchao Shao <shaozhengchao@huawei.com>
---
 net/sched/sch_tbf.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Jakub Kicinski Aug. 26, 2022, 1:13 a.m. UTC | #1
On Fri, 26 Aug 2022 09:12:48 +0800 Zhengchao Shao wrote:
> The issue is the same to commit c2999f7fb05b ("net: sched: multiq: don't
> call qdisc_put() while holding tree lock"). Qdiscs call qdisc_put() while
> holding sch tree spinlock, which results sleeping-while-atomic BUG.
> 
> Fixes: c266f64dbfa2 ("net: sched: protect block state with mutex")
> Signed-off-by: Zhengchao Shao <shaozhengchao@huawei.com>

If it's a bug fix for a commit already in Linus's main tree it should
come with [PATCH net] in the subject (i.e. without the -next).
Please repost.
shaozhengchao Aug. 26, 2022, 1:25 a.m. UTC | #2
On 2022/8/26 9:13, Jakub Kicinski wrote:
> On Fri, 26 Aug 2022 09:12:48 +0800 Zhengchao Shao wrote:
>> The issue is the same to commit c2999f7fb05b ("net: sched: multiq: don't
>> call qdisc_put() while holding tree lock"). Qdiscs call qdisc_put() while
>> holding sch tree spinlock, which results sleeping-while-atomic BUG.
>>
>> Fixes: c266f64dbfa2 ("net: sched: protect block state with mutex")
>> Signed-off-by: Zhengchao Shao <shaozhengchao@huawei.com>
> 
> If it's a bug fix for a commit already in Linus's main tree it should
> come with [PATCH net] in the subject (i.e. without the -next).
> Please repost.

Hi Jakub:
	Thank you for your reply. I will repost this patch.

Zhangchao Shao
diff mbox series

Patch

diff --git a/net/sched/sch_tbf.c b/net/sched/sch_tbf.c
index 72102277449e..36079fdde2cb 100644
--- a/net/sched/sch_tbf.c
+++ b/net/sched/sch_tbf.c
@@ -356,6 +356,7 @@  static int tbf_change(struct Qdisc *sch, struct nlattr *opt,
 	struct nlattr *tb[TCA_TBF_MAX + 1];
 	struct tc_tbf_qopt *qopt;
 	struct Qdisc *child = NULL;
+	struct Qdisc *old = NULL;
 	struct psched_ratecfg rate;
 	struct psched_ratecfg peak;
 	u64 max_size;
@@ -447,7 +448,7 @@  static int tbf_change(struct Qdisc *sch, struct nlattr *opt,
 	sch_tree_lock(sch);
 	if (child) {
 		qdisc_tree_flush_backlog(q->qdisc);
-		qdisc_put(q->qdisc);
+		old = q->qdisc;
 		q->qdisc = child;
 	}
 	q->limit = qopt->limit;
@@ -467,6 +468,7 @@  static int tbf_change(struct Qdisc *sch, struct nlattr *opt,
 	memcpy(&q->peak, &peak, sizeof(struct psched_ratecfg));
 
 	sch_tree_unlock(sch);
+	qdisc_put(old);
 	err = 0;
 
 	tbf_offload_change(sch);