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 B4C1A2D5A19; Mon, 13 Apr 2026 16:36:47 +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=1776098207; cv=none; b=GyBM6fq3zlPBU6Gjkrxq5tmgYjHUngYMFC9y/Ezc8q5JF6BnEcmF3EvMZBoot9Ez94QirTOyCXfKztNdtA3htId0XCJwoJ5m5Jff7XFhzy8oMk0fgvKcY3xaaTvPUC1QvZsPPJVCuy2xshmMCgtjKixn5qwgOErDw1DepSt9hqg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776098207; c=relaxed/simple; bh=umOb7iyZo5TEuQW1j8NfaVnqPrkeHIEFCQ0b+T8fuFA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=oceKC+CgsolyPq5wxCHid8PC6oi/5cKzvFlOpwQOYRk2Z+jvpHZkCRNsO9GF9GPxuN5FvP3hkW+nDOUyt1SDx3uzXIMQkKrLMiCJ/XFoUhsgeQl2tghQKHKhv12JytI/gC4ZEcwZ9LK873JVhAX7fmpcXvF1OSmYiMWe76O2rW4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=k1sBMQcx; 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="k1sBMQcx" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 49910C2BCAF; Mon, 13 Apr 2026 16:36:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1776098207; bh=umOb7iyZo5TEuQW1j8NfaVnqPrkeHIEFCQ0b+T8fuFA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=k1sBMQcxA4LPvBmreoMcz1UB/djq2T8hIT7xOOxg2f7XvlG4rE5CPv5sJVBROGIO3 4RAYFj0HFU4nVDCWu+P6l4iZLy4AJmPFfK10y5/D4qch39+GzmL1/tpO0SaztBlwyn ub4MrCo/LnIyHxzgcAn9OF4coceJ0Gbc/aNMQicg= 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 5.15 434/570] net/sched: cls_fw: fix NULL pointer dereference on shared blocks Date: Mon, 13 Apr 2026 17:59:25 +0200 Message-ID: <20260413155846.731321606@linuxfoundation.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260413155830.386096114@linuxfoundation.org> References: <20260413155830.386096114@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 5.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Xiang Mei [ Upstream commit faeea8bbf6e958bf3c00cb08263109661975987c ] The old-method path in fw_classify() calls tcf_block_q() and dereferences q->handle. Shared blocks leave block->q NULL, causing a NULL deref when an empty cls_fw filter is attached to a shared block and a packet with a nonzero major skb mark is classified. Reject the configuration in fw_change() when the old method (no TCA_OPTIONS) is used on a shared block, since fw_classify()'s old-method path needs block->q which is NULL for shared blocks. The fixed null-ptr-deref calling stack: KASAN: null-ptr-deref in range [0x0000000000000038-0x000000000000003f] RIP: 0010:fw_classify (net/sched/cls_fw.c:81) Call Trace: tcf_classify (./include/net/tc_wrapper.h:197 net/sched/cls_api.c:1764 net/sched/cls_api.c:1860) tc_run (net/core/dev.c:4401) __dev_queue_xmit (net/core/dev.c:4535 net/core/dev.c:4790) 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-1-xmei5@asu.edu Signed-off-by: Paolo Abeni Signed-off-by: Sasha Levin --- net/sched/cls_fw.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/net/sched/cls_fw.c b/net/sched/cls_fw.c index a2f53aee39097..a4ffee135c855 100644 --- a/net/sched/cls_fw.c +++ b/net/sched/cls_fw.c @@ -245,8 +245,18 @@ static int fw_change(struct net *net, struct sk_buff *in_skb, struct nlattr *tb[TCA_FW_MAX + 1]; int err; - if (!opt) - return handle ? -EINVAL : 0; /* Succeed if it is old method. */ + if (!opt) { + if (handle) + return -EINVAL; + + if (tcf_block_shared(tp->chain->block)) { + NL_SET_ERR_MSG(extack, + "Must specify mark when attaching fw filter to block"); + return -EINVAL; + } + + return 0; /* Succeed if it is old method. */ + } err = nla_parse_nested_deprecated(tb, TCA_FW_MAX, opt, fw_policy, NULL); -- 2.53.0