🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #27502

Re: [PATCH net v2 5/6] idpf: fix use-after-free in the PTP auxiliary worker

#27502
From: netdev-bot+sashiko
Date: Sat, 05 Dec 2026 20:47
181 lines
14503 bytes
Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.

Low priority / nit picks for your consideration:

- [Low] The commit message describes the change in
  idpf_ptp_update_phctime_rxq_grp()…
- [Low] The patch puts rxq_grps_lock just after link_up in struct
  idpf_vport (idpf.h) with the comment "Must be past the point…

Pre-existing issues:
- [High] This problem wasn't introduced by this patch, but the patch only
  fixes part of it.

--

idpf: fix use-after-free in the PTP auxiliary worker

This patch adds a per-vport rxq_grps_lock. The lock serializes publishing
and clearing of rsrc->rxq_grps against the PTP auxiliary worker in
idpf_ptp_update_cached_phctime(). The rxq_grps array is now built
privately and published only once it is complete, the soft reset path
clears the stale rxq_grps pointer in the cloned vport, and the split
queue NULL check in idpf_ptp_update_phctime_rxq_grp() is changed.

> diff --git a/drivers/net/ethernet/intel/idpf/idpf.h b/drivers/net/ethernet/intel/idpf/idpf.h
> index 533b069d97f94..c2631ac35a8b4 100644
> --- a/drivers/net/ethernet/intel/idpf/idpf.h
> +++ b/drivers/net/ethernet/intel/idpf/idpf.h

[ ... ]

> @@ -406,6 +408,9 @@ struct idpf_vport {
>  	bool crc_enable;
>  	bool link_up;
>  
> +	/* Must be past the point idpf_initiate_soft_reset() memcpy()s */
> +	spinlock_t rxq_grps_lock;
> +
>  	struct idpf_ptp_vport_tx_tstamp_caps *tx_tstamp_caps;
>  	struct kernel_hwtstamp_config tstamp_config;
>  	struct work_struct tstamp_task;

[Severity: Low]
This isn't a bug, but the commit message gives this reason for the
placement:

  The lock sits past the offsetof(struct idpf_vport, link_up) boundary
  that idpf_initiate_soft_reset() stops its memcpy() at, next to the wait
  queues and mutexes that are already kept out of the copy

Are there any wait queues or mutexes past link_up in struct idpf_vport?
After this patch the end of the struct holds rxq_grps_lock,
tx_tstamp_caps, tstamp_config, tstamp_task and tstamp_stats.

The existing comments in idpf_initiate_soft_reset() describe the same
fields:

	/* This purposely avoids copying the end of the struct because it
	 * contains wait_queues and mutexes and other stuff we don't want to
	 * mess with. ...

and:

	/* Avoid copying the wait_queues and mutexes. We do not want to mess
	 * with those if possible.
	 */

rxq_grps_lock is now only correct while it stays past
offsetof(struct idpf_vport, link_up). Could the commit message and these
comments be updated to describe the actual boundary?

> diff --git a/drivers/net/ethernet/intel/idpf/idpf_lib.c b/drivers/net/ethernet/intel/idpf/idpf_lib.c
> index 062d2f540254a..38cb91beacd07 100644
> --- a/drivers/net/ethernet/intel/idpf/idpf_lib.c
> +++ b/drivers/net/ethernet/intel/idpf/idpf_lib.c

[ ... ]

> @@ -2097,6 +2098,11 @@ int idpf_initiate_soft_reset(struct idpf_vport *vport,
>  	} else {
>  		set_bit(IDPF_VPORT_DEL_QUEUES, vport->flags);
>  		idpf_vport_stop(vport, false);
> +
> +		/* Drop the stale pointer in the clone, as rxq_grps was freed
> +		 * by idpf_vport_stop().
> +		 */
> +		new_rsrc->rxq_grps = NULL;

[Severity: High]
This is a pre-existing issue and was not introduced by this patch, but
is clearing only rxq_grps in the clone enough?

idpf_vport_stop() also frees and NULLs rsrc->txq_grps, rsrc->q_vectors
and vport->txqs in the live vport. new_vport still holds the old values
from the first memcpy(), and the later copy writes them back:

	memcpy(vport, new_vport, offsetof(struct idpf_vport, link_up));

q_vectors and txq_grps are overwritten at the start of
idpf_vport_intr_alloc() and idpf_txq_group_alloc(). vport->txqs is only
reassigned in idpf_vport_init_fast_path_txqs(), which runs after
idpf_vport_queue_grp_alloc_all():

idpf_vport_queues_alloc() {
	err = idpf_vport_queue_grp_alloc_all(vport, rsrc);
	if (err)
		goto err_out;

	err = idpf_vport_init_fast_path_txqs(vport, rsrc);
	...
err_out:
	idpf_vport_queues_rel(vport, rsrc);
}

Take a soft reset on an up interface, for example from ethtool -L/-G or
an MTU change. If idpf_vport_open()->idpf_vport_queues_alloc()->
idpf_vport_queue_grp_alloc_all() fails with -ENOMEM, does
idpf_vport_queues_rel() then work on the stale vport->txqs?

idpf_vport_queues_rel() {
	...
	idpf_xdpsqs_put(vport);
	idpf_vport_queue_grp_rel_all(vport, rsrc);

	kfree(vport->txqs);
	vport->txqs = NULL;
}

With an XDP program attached, idpf_xdpsqs_put() would read the freed
vport->txqs[i]. Then kfree(vport->txqs) would free the same pointer a
second time.

Should the clone drop txqs as well, and possibly txq_grps and q_vectors,
in the same way as rxq_grps?

> diff --git a/drivers/net/ethernet/intel/idpf/idpf_ptp.c b/drivers/net/ethernet/intel/idpf/idpf_ptp.c
> index 71fe8b2a8b4e4..9b15973d2f7ec 100644
> --- a/drivers/net/ethernet/intel/idpf/idpf_ptp.c
> +++ b/drivers/net/ethernet/intel/idpf/idpf_ptp.c
> @@ -348,9 +348,11 @@ idpf_ptp_update_phctime_rxq_grp(const struct idpf_rxq_group *grp, bool split,
>  		}
>  	} else {
>  		for (i = 0; i < grp->splitq.num_rxq_sets; i++) {
> +			if (!grp->splitq.rxq_sets[i])
> +				continue;
> +
>  			rxq = &grp->splitq.rxq_sets[i]->rxq;
> -			if (rxq)
> -				WRITE_ONCE(rxq->cached_phc_time, systime);
> +			WRITE_ONCE(rxq->cached_phc_time, systime);

[Severity: Low]
The commit message calls this change a fix:

  Also, fix the NULL check in idpf_ptp_update_phctime_rxq_grp(). The split
  queue case took the address of a member before testing it, which can never
  be NULL, so test the rxq_sets[] entry itself.

Is that description accurate? rxq is the first member of struct
idpf_rxq_set:

struct idpf_rxq_set {
	struct idpf_rx_queue rxq;
	struct idpf_sw_queue *refillq[IDPF_MAX_BUFQS_PER_RXQ_GRP];
};

So &grp->splitq.rxq_sets[i]->rxq has the same value as
grp->splitq.rxq_sets[i]. The kernel builds with
-fno-delete-null-pointer-checks, so the old if (rxq) test did skip NULL
entries.

The new check is a reasonable cleanup. Since the array is now published
only when fully built, the worker should not see a NULL entry anyway.
Could the commit message call this a cleanup rather than a fix, so it
does not suggest there was a separate NULL dereference?

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261204194642.3048406-1-anthony.l.nguyen%40intel.com
Technical Details
Message-ID: <179650363586.3148.10898143589779159807@kernel.org>
Path: mbox-mo1.pugleaf.net!feed-us-txt.newsdeef.eu!feed-us-mo.newsdeef.eu!srv.newsdeef.eu!newsfeed.endofthelinebbs.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-378126-linux-kernel-netdev=dewy.ru
References: <20261204194642.3048406-6-anthony.l.nguyen@intel.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!feed-us-txt.newsdeef.eu!feed-us-mo.newsdeef.eu!srv.newsdeef.eu!newsfeed.endofthelinebbs.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-378126-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net v2 5/6] idpf: fix use-after-free in the PTP auxiliary worker
Date: Sat, 05 Dec 2026 20:47:15 +0000
Organization: Usenet Network
Message-ID: <179650363586.3148.10898143589779159807@kernel.org>
References: <20261204194642.3048406-6-anthony.l.nguyen@intel.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="3117298"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:0M3ata2Soflz3M8YQxFKKkUci54= sha256:PhIcg2mQVnBOqyzupb35ofFRyArePBrvykCIEoACucY=
	sha1:tElqEmMRIc/a3JtlRnGIkjhtkwQ= sha256:R8e04SmCZCd98NOjoJNm75fcNTQh2YsFza2T0vaNfnQ=
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 43343117EAD; Sat,  5 Dec 2026 23:47:40 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.539
X-Spam-Status: No, score=-3.539 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.14, 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 u_KjQPjHCzAZ;
	Sat,  5 Dec 2026 23:47:37 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-378126-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 32C2E117EAC; Sat,  5 Dec 2026 23:47:28 +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 ACB4B26180; Sat,  5 Dec 2026 20:47:18 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1796503638;
	b=L4lEpA0kmIo+cZ+fZOZVhJ3/FkKRExUJDwPAIFciuPB/VhnFyEV4lPcK7SvSmS0R2bow
	 /cAOOmahuyyK67J5IMvST2rX4+YzlnfdiC42IOt2qtuc/yqy4H+2EvIIdBp+4j221CPp7
	 3EdyjJXnigx4N7WJWoPCbtO0rbZ55FbF7nquHQI/qfVa4tOICYs8Mtl8dbnHv2gRo1Z0t
	 nsMZig1o0vXZ8VnISWesIUtSU1DJzVW1zyQrwTFHu8rUh4ciLtsGfl+LaKJBDf7PTvl7A
	 RIdGUhYhkpLMYHOR3jL9F4TpzUn9mOLMwehcw13Fnf8Masjsmkfp8gylcn5CrywcQkg==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796503638;
	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=Xh82V5s1TsdGEHY0Wt8/3iT093xFdUDoRxApbKyDXCY=;
	b=nEJB3W75Dm5DI8tNj0vsX4LLwf9ju3zFWB739mSVUjx2pKRO5GL4P1RBSiRFoq5nyjDj
	 ZuY20BHUGvyz/awL9HtFOV+glY/QtY7fXokII7Oyk5SEjlBj+R6R80y9c4sPPLYJZRT3g
	 YXo50wiWHbCmu1Fex4ZLkWblI1DDgkmRn6vppG3nq9MiU3EDUCuKOOKevhT2H2MeYoKQk
	 cxdclVNLk35grmkPlyF7kcGZhSbTxHX89l0o3x686av+TvFgeZ3WZJNc5+IZkxcNyDCWt
	 7yM1ewzhOe2uvZh5ytdRCgmAfIlIBo7D/iC9/PbSNBmCS5d9lGZSaM9IkwQw03NMeGw==
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=FfZ9zN0+;
	arc=pass header.oldest-pass=0 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 3A74A606A33B;
	Sat,  5 Dec 2026 20:47:18 +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=FfZ9zN0+
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=1796503637;
	b=uWvhNupai7oROOIbLCcHL7qj/gdQZYHH8g+5uUclEvH/POXGHV5mTngf9UBskSHxmS63
	 P6ucdtBSnudX+Efe01dZBvM1F7FRZBUVlAP83B/anHQQK6qogz8/GB2FN6nAuAGF7vj4A
	 +nu2ujxcu3Od9CFUxFOc3EFuol6p4o5H+dBBn4uK/lNa/uCcmNgn6T+8ZoMKSlH/+k339
	 1xl6zd+I68fPTO1FxOIWVCajwevNTHSWQ4JMApnz+S6TG5Xok5YB717E7sfyqmYjPd9eP
	 X9vDbGM1yQYbLFH3Gj5k6SFslrLmOkV3et4Z1iObwYkd3RyncjAlqobLo0yG4kTpKsA==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796503637;
	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=Xh82V5s1TsdGEHY0Wt8/3iT093xFdUDoRxApbKyDXCY=;
	b=FBzIad2u+UL8SHCDJ/A1j03bEHCecUpWLNhRsMxau1jRKWGE+5VGVTlw+wd6TJ7LyMfT
	 nxtf/JQMHMtxZR2oAPWucEwq2tR+9B4Vu5G1nIWZR+Q6S6QPB5L548d4TK8V1r3l1mvxI
	 oujqyf9rRKJhZYBguuJ5lzgcXk9gVKifjz3BkzD/zHhXrfqhpf+Dxkj0WauhQSMGygUNG
	 tuq3FeaytbNbcrVyF73h8xivrekQAOO0B6T/dnu19qKy02v4/J07X/MGBjS/VJkRRr12q
	 RvgRsCRqlJkanIaSPSE9tqoEzbdWyTI0nlU3eg4HfLS9iUI5DmHNHrCu922flXpwmyw==
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=FfZ9zN0+;
	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 59019606A330;
	Sat,  5 Dec 2026 20:47:17 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4E0621F00A07;
	Sat,  5 Dec 2026 20:47:16 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1796503637;
	bh=Xh82V5s1TsdGEHY0Wt8/3iT093xFdUDoRxApbKyDXCY=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=FfZ9zN0+777kXCHriVrBKWtMseMQX0BX40jIXVpQHpRiagAuWfOdY1ku2zMgQ8LMk
	 36b+A7mkbWRDzGUxkw+FmxurtqiU14rOUBh35ITFsnr2wG7MqdDFRAriNwZH2DQwFz
	 +bKlHCscQlb39QXmnLZhZjnXy7Yta7yzDXNabgIBTnsD2YgTaSEhjsxGN7FCzDDYW3
	 zo5Lo1EdVoKLlmN96w2R1nxxg14/LxHhoaHeHqPK12+Dnf0U+8f9vWbZErL9YpbIx5
	 6IEj0zxvKY75fT/c4m+qniXasxKCSF9UBeABhGSWVFO6hvGE9vC90AUwN8ULMY3ojh
	 2bRSvaKpbbgjg==
X-Cc: davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com,
 edumazet@kernel.org, andrew+netdev@lunn.ch, willemb@google.com,
 netdev@vger.kernel.org, tianxun.ng@bytedance.com, oss.patchbox@gmail.com,
 luckilystar08@gmail.com, emil.s.tantilov@intel.com, richardcochran@gmail.com,
 milena.olech@intel.com, konstantin.ilichev@intel.com, stable@vger.kernel.org,
 Samuel.salin@intel.com
X-In-Reply-To: <20261204194642.3048406-6-anthony.l.nguyen@intel.com>
X-sashiko-severity: Low
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