🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #20402

Re: [PATCH net-next v3 4/4] net: dsa: qca8k: bound the data of a management ack frame

#20402
From: netdev-bot+sashiko
Date: Sun, 22 Nov 2026 11:03
138 lines
13210 bytes
Thank you for your contribution! Sashiko AI review found 3 potential
issue(s) to consider.

Critical: 0 · High: 1 · Medium: 0 · Low: 2

If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).

- [High] Use-after-free introduced by the new pskb_may_pull() in
  qca8k_rw_reg_ack_handler() (drivers/net/dsa/qca/qca8k-8xxx.c).
- [Low] The commit message says that with the old `u32 data[4]` a frame
  "announcing more than three registers writes past the buffer".
- [Low] The new comment in qca8k_rw_reg_ack_handler(), "The tagger made
  only the tag linear", and the matching commit-message line…

--

net: dsa: qca8k: bound the data of a management ack frame

This patch resizes mgmt_eth_data->data to the largest payload a
management frame can carry. Before qca8k_rw_reg_ack_handler() copies the
announced DATA2 payload, it now pulls that payload into the linear area
with pskb_may_pull(). A frame that is too short for its announced length
is left unacknowledged.

> qca8k_rw_reg_ack_handler() answers a management read by copying the
> data that follows the Ethernet header into mgmt_eth_data->data. It
> trusts the frame for both the length and the layout: the length field
> of the frame allows up to 32 bytes while the buffer holds 16, so a
> frame announcing more than three registers writes past the buffer into
> the fields that follow it in qca8k_priv; and qca_tag_rcv() made only

[Severity: Low]
Is the threshold here off by one? With the old u32 data[4], data[0] is
filled from mdio_data, and the loop then writes data_len / 4 more words:

    for (i = sizeof(u32); i <= data_len; i += sizeof(u32)) {

For len = 16 (four registers), data_len is 12, so three more words are
written and data[0..3] is filled exactly. len = 18 also gives three
words. Only at len = 20 (five registers) does data_len = 16 reach
data[4].

So does the old overflow start at more than four registers, not more
than three?

> diff --git a/drivers/net/dsa/qca/qca8k-8xxx.c b/drivers/net/dsa/qca/qca8k-8xxx.c
> index 76c0f7c97b99d..cd3569902fcdb 100644
> --- a/drivers/net/dsa/qca/qca8k-8xxx.c
> +++ b/drivers/net/dsa/qca/qca8k-8xxx.c

[ ... ]

> @@ -190,6 +191,17 @@ static void qca8k_rw_reg_ack_handler(struct dsa_switch *ds, struct sk_buff *skb)
>  	/* We can ignore odd value, we always round up them in the alloc function. */
>  	len *= sizeof(u16);
>  
> +	if (cmd == MDIO_READ && len > QCA_HDR_MGMT_DATA1_LEN)
> +		data_len = min_t(int, QCA_HDR_MGMT_DATA2_LEN,
> +				 len - QCA_HDR_MGMT_DATA1_LEN);
> +
> +	/* The tagger made only the tag linear. Leave a frame that is too

[Severity: Low]
Is this comment accurate? qca_tag_rcv() in net/dsa/tag_qca.c does:

    if (unlikely(!pskb_may_pull(skb, QCA_HDR_LEN))) {
    ...
    phdr = dsa_etype_header_pos_rx(skb);

That pull makes QCA_HDR_LEN bytes linear starting at skb->data. For a
management ack those are the first two bytes of the DATA2 payload. The
tag itself is read at skb->data - 2, inside the MAC header, which was
already linear.

The commit message uses the same wording: "qca_tag_rcv() made only the
2 byte tag linear".

DATA2 still needs a pull, so that conclusion holds. Could the comment
and changelog say which bytes the tagger actually guarantees?

> +	 * short for the data it announces unacknowledged: the read fails
> +	 * and the caller falls back to MDIO.
> +	 */
> +	if (data_len && !pskb_may_pull(skb, data_len))
> +		goto complete;
> +
>  	/* Make sure the seq match the requested packet */
>  	if (get_unaligned_le32(&mgmt_ethhdr->seq) == mgmt_eth_data->seq)
>  		mgmt_eth_data->ack = true;

[Severity: High]
Can this new pskb_may_pull() leave mgmt_ethhdr pointing into a freed
skb head? The function caches the pointer before the pull:

    mgmt_ethhdr = (struct qca_mgmt_ethhdr *)skb_mac_header(skb);

data_len can be up to 28 bytes. If it is larger than skb_headlen(skb) and
the head lacks tailroom, the call chain is:

    pskb_may_pull()
      __pskb_pull_tail()
        pskb_expand_head()

pskb_expand_head() allocates a new head and frees the old one.
dsa_switch_rcv() has already run skb_unclone_full(), so no clone keeps
the old head alive.

mgmt_ethhdr is never reloaded after the pull. The read of
mgmt_ethhdr->seq here, and the read of mgmt_ethhdr->mdio_data below,
would then come from the freed buffer.

A garbage seq could set mgmt_eth_data->ack = true. The garbage
mdio_data would land in mgmt_eth_data->data[0], which qca8k_read_eth()
returns as the register value.

The kernel-doc for __pskb_pull_tail() says "All the pointers pointing
into skb header may change and must be reloaded after call to this
function". The sibling handler qca8k_mib_autocast_handler() in this
file reloads its pointer after the pull:

    if (!pskb_may_pull(skb, len))
        goto unlock;

    mib_ethhdr = (struct mib_ethhdr *)skb_mac_header(skb);

Should mgmt_ethhdr be re-read after a successful pull here? The other
option is to read seq and mdio_data into locals before the pull, as is
already done for command.

[ ... ]

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261118104104.26684-1-kuncy7%40gmail.com
Technical Details
Message-ID: <179534543789.3135.5831008026299550548@kernel.org>
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-368664-linux-kernel-netdev=dewy.ru
References: <20261118104104.26684-5-kuncy7@gmail.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-368664-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net-next v3 4/4] net: dsa: qca8k: bound the data of a
 management ack frame
Date: Sun, 22 Nov 2026 11:03:57 +0000
Organization: Usenet Network
Message-ID: <179534543789.3135.5831008026299550548@kernel.org>
References: <20261118104104.26684-5-kuncy7@gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="3618352"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:XwMtjCxG4Sl05lMFUYYisGOn0K8= sha256:CN7VkuiIUHiHuajZEA/N71/byYSTps1h1J6EpMCqbzk=
	sha1:a69iddhWkFLUPlp6828zqy7RqHo= sha256:EmG0qLK0IoS9I/CJQc/SQKyh9bH8gDJ7w/63462IW8A=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id 93F49125D75; Sun, 22 Nov 2026 14:04:28 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.4
X-Spam-Status: No, score=-3.4 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1,
	DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
	MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
	SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=kernel.org
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id 7YoLvp6zjpEI;
	Sun, 22 Nov 2026 14:04:20 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-368664-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id 4726E125D74; Sun, 22 Nov 2026 14:04:11 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sea.lore.kernel.org (Postfix) with ESMTP id B75542F05A; Sun, 22 Nov 2026 11:04:08 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=fail;
	t=1795345445;
	b=PRsRarAsKR7CoQn21q6ntY/kDqhF2cANVBgUXQ4MnGHjDJhh2B/Y5ZS6Wx7EAWNJfg+x
	 uhKRlS4BrDMr/fgzidBSAzTGuXzuBP2xr/2C9OvRs/V3GGL2jQHFIpfM7uVaku2TIW4/v
	 B2PJ+6tg8F/VzZd76e1Q8jz1netKrReaaRKgQDICpVgA/9OYgFepSWS8LOS4RHVD99VNt
	 nD97fQCUL9gLZna/JUfxxsOfFW6mnt++LvRVxD1vlVgaHBrRrZ/jfqa/TlkjFsnc0KMsq
	 uo7c8ASlZYQJjzUM6xhnyXkX1jA/cqI8B0wp46Y51wDW4eTaPuI3n8VLnqrf3Pop4Uw==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795345445;
	h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc:
	 Date:Message-ID:In-Reply-To:References:X-sashiko-severity:
	 Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id:
	 List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner:
	 Precedence:MIME-Version;
	bh=D8iqOKB7KV2hrQ6oaGrMj5AeFqZ86i9zrCsKQAZT9TY=;
	b=epsiSGGtc5isLv5zVFWliHCoNdWP9aGcLoqQrfBrSF9uafoRWBBU/3VgdgaCwNz1chzD
	 YSdSfv8VWRtWfmqd282zdffJ5SFDynhG1dEkHUG2BDnCYgw9C2KWSYF8ZIrrEzUEl2olU
	 3ggbIHxBlSnAu6NXub9A79Ji86Qi2Sqki+gDZNkNfDdLBoscrhAFbMVV58IFKJugtUmML
	 updVnNlvqX7NZBWEMCytKkqt9z1Cg0g//u5NywkwnZMTGv0pmc+vWiKwgVJw9ppCdJdGm
	 oseH/eF0Pv+wpJSGVImwleuFd98FQiYiSXuyGr5zFyMH3tkuJ2p+CWBw/8avI5OwVMw==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b="dtr5Tb//";
	arc=fail smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 1C14B606A32A;
	Sun, 22 Nov 2026 11:04:05 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=dtr5Tb//
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1795345439;
	b=bxETJRdMNZLXtpyGuLk1q5KeR9AuCrqIxP0FVcyy8QxBPRTCfenbUjKyAim40NBgDL6f
	 t4ZtmmE299ScXeQZRowZMSOhxVAmzQOLURkkd/+pvzNJdMUL+IFpuKGP/p3/a/lIg/Mfx
	 Q3Y+R/rhG3y8EDUnXBlr2zxevlDuvRfioNIvhOkUaEvFrFSlzHdXqrEUVseB1cLIybYXp
	 up7aRtfAUrHrTDil4ih3IQzbKrrdoD9TDP1vRbQxPc7kvxruU6adGFvbNrqXAc2ZE149T
	 4dc2ZNdhW9tw2Munzlhj7RthdJUAS1ysipfMaYGL997uTtfEmo/2aY6U3KF3ooKSY/g==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795345439;
	h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID:
	 In-Reply-To:References:X-sashiko-severity:Content-Type:
	 Content-Transfer-Encoding:MIME-Version;
	bh=D8iqOKB7KV2hrQ6oaGrMj5AeFqZ86i9zrCsKQAZT9TY=;
	b=dkxNxkS6YGcAVEfF7oeeEBoWmDCgdDjlsSwo1XVoARJuxEHg5nKt6nlFM/W8s5JzndZK
	 Gr0SUp/k0YziJ1G5vN7wlnu8EU7lTUNJPDVUeLZOmUlZ8JdzJwD0xZbsOYrPaw1C/lC8c
	 jlHN5rFOgFeTese80REm7sk2nXsAnN48Ql5S7u1YuUYOU+LtAh6aL5vxO/kGIS6d6swiB
	 QdEI0/xqdM/an/ennirGCBeNQ2nsrZQDntIM5DvdQv/pij9ui/kRPgdHCKWUjsrf4zEIM
	 cS42R8sBoEGMM05tTgYxbFK++ngIVFPlp4KyezMTqgx2mVrlMn1B13xq8GA0gNWH6AA==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b="dtr5Tb//";
	arc=none smtp.remote-ip=100.103.45.18
X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3C918606A336;
	Sun, 22 Nov 2026 11:03:59 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4DE361F000C4;
	Sun, 22 Nov 2026 11:03:58 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1795345438;
	bh=D8iqOKB7KV2hrQ6oaGrMj5AeFqZ86i9zrCsKQAZT9TY=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=dtr5Tb//e5gBlwc5yaPtZzMf0ZYqxpkcS7d6HrrvRMOnmpWuCvssibkSfRdhh4Whd
	 RzOumKxuugyimV2Jh3TJmCqbvQTiZof4UmQExpz1VvUSjnqrQwPGoiZl+8He6ohKe1
	 u7QXXKNU+mVyTkrlxG3Aps6R/VFH3ZN5VwlLeTHB/Ojmc4vJSsF3mLog8oJcD9Oo4N
	 RxV9QJKa7UXypLwMlCn2deikWyE2y5lCWJsDPbdTR6q0urpmII/H66bfIG2KihCJge
	 GZ4ZgN3A0TR/+h7ih7G2XjknS/UwCcjaezVsUnBhiLtfiY0x1XTTt2H/ojtnWvqzhX
	 nV8SYwHCPaK7Q==
X-Cc: ansuelsmth@gmail.com, andrew@lunn.ch, olteanv@gmail.com,
 davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com,
 yongzhao.derek@gmail.com, luixo-public@luixo.me, netdev@vger.kernel.org,
 linux-kernel@vger.kernel.org
X-In-Reply-To: <20261118104104.26684-5-kuncy7@gmail.com>
X-sashiko-severity: High
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list