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 A656034753A; Wed, 8 Apr 2026 18:15:00 +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=1775672100; cv=none; b=Et4XOno8mU14EU53WBWPWLhKpwYVebz4BZp+zHOsMsXpJsEjul3w9SyRJghR9Vui0j4X9tuFty1Tp/AMkBMRjnSpHangCzhxV5+J2dIcIoNyhNkncEynDYkpoAWr70bUa0K43BdVxVvEx+vrRIj5z1xO3sR3nHz6k51/F3lkKtU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775672100; c=relaxed/simple; bh=heKPtkJs/c8K5Ffq6eD+neXYW4Skt/AWq2YJUmipmhQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=PDns+61WQgVi+bGmdRxJ0gqdcPMQu5nH4aHavY4QLbnb1qLURsByklOho1RJ3eXTozM2RGdd2rV9jbbJ2Am0xnLdRrcsBzMOMy2Qa2LxGhHdijcotK0NCkE20YPG8XYQbx/olbKBB5ZaUqn+BwCAw3VR30z5teU0LqYdj6k+yX0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=M0NOwkTU; 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="M0NOwkTU" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 17EBBC19421; Wed, 8 Apr 2026 18:14:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1775672100; bh=heKPtkJs/c8K5Ffq6eD+neXYW4Skt/AWq2YJUmipmhQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=M0NOwkTUKg0LKrRDE1dYuQnDDViKBhDUuMg0ssq1D+48uy3LEhY7UW1KVrWSy9Mzu /AbRq89Q/QRpaGdsV0X7hiMHGLciNcY7Na1ZAh0qXCwO5QHRTz43vKj7XpYdSLTKzI 6uojreIKJhzL+ciaTzHCa4Ph0LoCt5rKC6ozyfJA= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Weiming Shi , Xiang Mei , Jamal Hadi Salim , Paolo Abeni , Sasha Levin Subject: [PATCH 6.1 188/312] net/sched: cls_flow: fix NULL pointer dereference on shared blocks Date: Wed, 8 Apr 2026 20:01:45 +0200 Message-ID: <20260408175940.782403692@linuxfoundation.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260408175933.715315542@linuxfoundation.org> References: <20260408175933.715315542@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org 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 1a280dd4bd1d616a01d6ffe0de284c907b555504 ] flow_change() calls tcf_block_q() and dereferences q->handle to derive a default baseclass. Shared blocks leave block->q NULL, causing a NULL deref when a flow filter without a fully qualified baseclass is created on a shared block. Check tcf_block_shared() before accessing block->q and return -EINVAL for shared blocks. This avoids the null-deref shown below: ======================================================================= KASAN: null-ptr-deref in range [0x0000000000000038-0x000000000000003f] RIP: 0010:flow_change (net/sched/cls_flow.c:508) Call Trace: tc_new_tfilter (net/sched/cls_api.c:2432) rtnetlink_rcv_msg (net/core/rtnetlink.c:6980) [...] ======================================================================= Fixes: 1abf272022cf ("net: sched: tcindex, fw, flow: use tcf_block_q helper to get struct Qdisc") Reported-by: Weiming Shi Signed-off-by: Xiang Mei Acked-by: Jamal Hadi Salim Link: https://patch.msgid.link/20260331050217.504278-2-xmei5@asu.edu Signed-off-by: Paolo Abeni Signed-off-by: Sasha Levin --- net/sched/cls_flow.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/net/sched/cls_flow.c b/net/sched/cls_flow.c index 7657d86ad1427..64b281cca6ae7 100644 --- a/net/sched/cls_flow.c +++ b/net/sched/cls_flow.c @@ -501,8 +501,16 @@ static int flow_change(struct net *net, struct sk_buff *in_skb, } if (TC_H_MAJ(baseclass) == 0) { - struct Qdisc *q = tcf_block_q(tp->chain->block); + struct tcf_block *block = tp->chain->block; + struct Qdisc *q; + if (tcf_block_shared(block)) { + NL_SET_ERR_MSG(extack, + "Must specify baseclass when attaching flow filter to block"); + goto err2; + } + + q = tcf_block_q(block); baseclass = TC_H_MAKE(q->handle, baseclass); } if (TC_H_MIN(baseclass) == 0) -- 2.53.0