From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8AF952FABE3; Tue, 12 Aug 2025 17:37:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755020231; cv=none; b=Vbx159mUfLPrAxw7tG4F6PWVS/CTnLsTjqw+vbJ6HqI7V/yVGfut9NRJNGCTvZk8y9i5NRn0mz8pDxRwRe+bztbtX6widQo37jaA/Poox/gGEBpAexRI5I2sdgqrSxiCzKAzc1FPHDJdK/hYmwtThKxEd/SPzDjpXnLGMsl2w9o= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755020231; c=relaxed/simple; bh=vg2MetJ7lqjpaVmLceQFRRLD6lgpLYpszhftZyLHhdw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TU9+PR/k6B3Uc4bVm7+C7+ZjlUIT1T1ZF0pb5m6OjTOjaTOICC2zfCP9DUxN7AvcC/StrGEkc5EpGHm7cNqG8Yp1lvxZKVqiummql/nNYnE6d/SwDCu0KzUyHyQO1NtBKVIVUx+ws1H5lwORBaEHG0ypgpwhmzgePsaymDp4sks= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=Ks6N4Rem; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="Ks6N4Rem" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 94C19C4CEF1; Tue, 12 Aug 2025 17:37:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1755020230; bh=vg2MetJ7lqjpaVmLceQFRRLD6lgpLYpszhftZyLHhdw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ks6N4RemTriIPiSFWzSHbEhy47g0gtPuRd2OsZ9TeWsVvHpG8v0rOdrgpEpIjPxcJ itZ6kHFrSjPZi6FjaFrvMxdY8yyK6uxGtp8XU0iq2eKn80rL35bKgOxSxkZvUlO4dq Wz8LmMpq+XWvOLaNUSwAdsV5R/7TKNSoW08MyV2U= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Dan Carpenter , Xiang Mei , Cong Wang , Paolo Abeni , Sasha Levin Subject: [PATCH 6.1 018/253] net/sched: sch_qfq: Avoid triggering might_sleep in atomic context in qfq_delete_class Date: Tue, 12 Aug 2025 19:26:46 +0200 Message-ID: <20250812172949.484505142@linuxfoundation.org> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20250812172948.675299901@linuxfoundation.org> References: <20250812172948.675299901@linuxfoundation.org> User-Agent: quilt/0.68 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Xiang Mei [ Upstream commit cf074eca0065bc5142e6004ae236bb35a2687fdf ] might_sleep could be trigger in the atomic context in qfq_delete_class. qfq_destroy_class was moved into atomic context locked by sch_tree_lock to avoid a race condition bug on qfq_aggregate. However, might_sleep could be triggered by qfq_destroy_class, which introduced sleeping in atomic context (path: qfq_destroy_class->qdisc_put->__qdisc_destroy->lockdep_unregister_key ->might_sleep). Considering the race is on the qfq_aggregate objects, keeping qfq_rm_from_agg in the lock but moving the left part out can solve this issue. Fixes: 5e28d5a3f774 ("net/sched: sch_qfq: Fix race condition on qfq_aggregate") Reported-by: Dan Carpenter Signed-off-by: Xiang Mei Link: https://patch.msgid.link/4a04e0cc-a64b-44e7-9213-2880ed641d77@sabinyo.mountain Reviewed-by: Cong Wang Reviewed-by: Dan Carpenter Link: https://patch.msgid.link/20250717230128.159766-1-xmei5@asu.edu Signed-off-by: Paolo Abeni Signed-off-by: Sasha Levin --- net/sched/sch_qfq.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/net/sched/sch_qfq.c b/net/sched/sch_qfq.c index f2692c9173f79..2f2863ae18ad5 100644 --- a/net/sched/sch_qfq.c +++ b/net/sched/sch_qfq.c @@ -540,9 +540,6 @@ static int qfq_change_class(struct Qdisc *sch, u32 classid, u32 parentid, static void qfq_destroy_class(struct Qdisc *sch, struct qfq_class *cl) { - struct qfq_sched *q = qdisc_priv(sch); - - qfq_rm_from_agg(q, cl); gen_kill_estimator(&cl->rate_est); qdisc_put(cl->qdisc); kfree(cl); @@ -561,10 +558,11 @@ static int qfq_delete_class(struct Qdisc *sch, unsigned long arg, qdisc_purge_queue(cl->qdisc); qdisc_class_hash_remove(&q->clhash, &cl->common); - qfq_destroy_class(sch, cl); + qfq_rm_from_agg(q, cl); sch_tree_unlock(sch); + qfq_destroy_class(sch, cl); return 0; } @@ -1505,6 +1503,7 @@ static void qfq_destroy_qdisc(struct Qdisc *sch) for (i = 0; i < q->clhash.hashsize; i++) { hlist_for_each_entry_safe(cl, next, &q->clhash.hash[i], common.hnode) { + qfq_rm_from_agg(q, cl); qfq_destroy_class(sch, cl); } } -- 2.39.5