🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #3961

Re: [PATCH net v2 1/2] ionic: fix port_info use-after-free on firmware recovery

#3961
From: Vadim Fedorenko
Date: Fri, 16 Oct 2026 11:17
63 lines
8188 bytes
On 16/10/2026 00:03, Eric Joyner wrote:
> From: "Nikhil P. Rao" <nikhil.rao@amd.com>
> 
> ionic_port_init() allocates port_info when the pointer is NULL, but its
> error path frees it without checking whether this call allocated it.
> Before commit ddc5911b9bd2 ("ionic: call ionic_port_init after
> fw-upgrade") the function returned early when the buffer already
> existed, so the two were symmetric.
> 
> Since then a failed PORT_INIT on either recovery path - fw_up or
> reset_done - frees a buffer an earlier init owns, while the netdev is
> registered and the ethtool ops are reading it.
> 
> Free only what this call allocated.
> 
> Fixes: ddc5911b9bd2 ("ionic: call ionic_port_init after fw-upgrade")
> Signed-off-by: Nikhil P. Rao <nikhil.rao@amd.com>
> Signed-off-by: Eric Joyner <eric.joyner@amd.com>
> ---
>   drivers/net/ethernet/pensando/ionic/ionic_main.c | 13 +++++++++----
>   1 file changed, 9 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/net/ethernet/pensando/ionic/ionic_main.c b/drivers/net/ethernet/pensando/ionic/ionic_main.c
> index 10501be9ef95..38b47b959a11 100644
> --- a/drivers/net/ethernet/pensando/ionic/ionic_main.c
> +++ b/drivers/net/ethernet/pensando/ionic/ionic_main.c
> @@ -722,6 +722,7 @@ int ionic_port_init(struct ionic *ionic)
>   {
>   	struct ionic_identity *ident = &ionic->ident;
>   	struct ionic_dev *idev = &ionic->idev;
> +	bool allocated = false;
>   	size_t sz;
>   	int err;
>   
> @@ -733,6 +734,8 @@ int ionic_port_init(struct ionic *ionic)
>   						     GFP_KERNEL);
>   		if (!idev->port_info)
>   			return -ENOMEM;
> +
> +		allocated = true;
>   	}
>   
>   	/* If the driver knows about more "extra stats" than the firmware,
> @@ -757,10 +760,12 @@ int ionic_port_init(struct ionic *ionic)
>   	mutex_unlock(&ionic->dev_cmd_lock);
>   	if (err) {
>   		dev_err(ionic->dev, "Failed to init port\n");
> -		dma_free_coherent(ionic->dev, idev->port_info_sz,
> -				  idev->port_info, idev->port_info_pa);
> -		idev->port_info = NULL;
> -		idev->port_info_pa = 0;
> +		if (allocated) {
> +			dma_free_coherent(ionic->dev, idev->port_info_sz,
> +					  idev->port_info, idev->port_info_pa);
> +			idev->port_info = NULL;
> +			idev->port_info_pa = 0;
> +		}
>   	}
>   
>   	return err;
> 
Reviewed-by: Vadim Fedorenko <vadim.fedorenko@linux.dev>
Technical Details
Message-ID: <6383302a-4605-460a-b57b-e90a8bd85235@linux.dev>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-347300-linux-kernel-netdev=dewy.ru
References: <20261015-ionic-port-info-lifetime-v2-0-57232013fd79@amd.com> <20261015-ionic-port-info-lifetime-v2-1-57232013fd79@amd.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-347300-linux-kernel-netdev=dewy.ru
From: vadim.fedorenko@linux.dev (Vadim Fedorenko)
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net v2 1/2] ionic: fix port_info use-after-free on
 firmware recovery
Date: Fri, 16 Oct 2026 12:17:08 +0100
Organization: Usenet Network
Message-ID: <6383302a-4605-460a-b57b-e90a8bd85235@linux.dev>
References: <20261015-ionic-port-info-lifetime-v2-0-57232013fd79@amd.com>
 <20261015-ionic-port-info-lifetime-v2-1-57232013fd79@amd.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: usenet.network;
	logging-data="2749122"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:jIVRy16JPaTGolLIouZlXLz8jHE= sha256:TCj9Id68tY8uCnZ5xcWBq7S5oJb7yLEoANx3gbKNhao=
	sha1:r1O4w+0w+bu9XAPCfTBm4+3JkpU= sha256:yBaDAdQF7PzWgZQvJ/6TR9SsuC8FOecnW6EdrwEblnY=
Content-Language: en-US
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 A5D5611050A; Fri, 16 Oct 2026 14:20:59 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -0.75
X-Spam-Status: No, score=-0.75 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
	DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.25,
	MAILING_LIST_MULTI=-1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001]
	autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (1024-bit key)
	header.d=linux.dev
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 ZLWZKF0yielY;
	Fri, 16 Oct 2026 14:20:57 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-347300-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=linux.dev
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id F2242110506; Fri, 16 Oct 2026 14:20:48 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.90.174.1])
	by sea.lore.kernel.org (Postfix) with ESMTP id 8C38D29628; Fri, 16 Oct 2026 11:17:21 +0000 (UTC)
X-Received: from localhost.localdomain (localhost.localdomain [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id EEF7347CA69;
	Fri, 16 Oct 2026 11:17:18 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="qno71NrC"
X-Received: from mta0.migadu.com (out-71.mta0.migadu.com [91.218.175.71])
	(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 63C1B4772AD
	for <netdev@vger.kernel.org>; Fri, 16 Oct 2026 11:17:12 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.71
X-ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;
	t=1792149438; cv=none; b=qsdsHlbQI1rjD+CZ9kvWn70VsZn0OLT2O3DJ8DKkwSBIs38gHh8qjE4ZgZU0vVgPVjHuNl+FuQum+jSdSjQaXHr/icjkR9qd5z5bIKGMOFo6OJNcu3UdJpu02nNfYMTHj2v3mObLErcN2Pm7fZInsuQz2tCE1jeC7uqu7cx0Upc=
X-ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org;
	s=arc-20240116; t=1792149438; c=relaxed/simple;
	bh=hTgQEMfpwyZOQZzZcZQI8UvRBKCiyj+u2NSj5kyeUfs=;
	h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From:
	 In-Reply-To:Content-Type; b=cZGroMAXSNHLq0idAN6zPGzfRORRg0nI/o3NyepQsg52X5+QMaZC2jZiratJpx4qSFsgaRvrI1qRJDNaQw4Z8+ulvpQPm9DbJW6pAQDW1LcQBo4SEiHlFM6lgeukiSEnC5x7Um82RM5SyvkLve5lJAo4X/ESnf8EtjtY0uTtBfk=
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=qno71NrC; arc=none smtp.client-ip=91.218.175.71
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev
X-Envelope-To: netdev@vger.kernel.org
X-DKIM-Signature: a=rsa-sha256; bh=hTgQEMfpwyZOQZzZcZQI8UvRBKCiyj+u2NSj5kyeUfs=;
 c=simple/simple; d=linux.dev;
 h=from:to:subject:date:message-id:mime-version:content-type; s=key1;
 t=1792149431; v=1; x=1792754231;
 b=qno71NrCkWn5SwjEBMDQ590u5v6WQw/N+XTc9A3buGj7lkzzRySZ5LvOnq/p91bLBQ8K4bvg
 2mv5Ri32qNILAcibEVwGYF/uHf/FBTFPj76yh6CeY8FtX2du5zw44cIQbr85xpdCTuyhYBW45gh
 GM1kv6h/wId4twFatrQY5+6E=
X-Envelope-To: netdev@vger.kernel.org
X-Received: by smtp.migadu.com with ESMTPS id d37c0f3850b60ceb;
	Fri, 16 Oct 2026 11:17:11 +0000
X-Mizu-Trace-ID: d37c0f3850b60ceb
X-Migadu-Flow: FLOW_OUT
X-Precedence: bulk
X-Mailing-List: netdev@vger.kernel.org
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-User-Agent: Mozilla Thunderbird
X-Cc: Brett Creeley <brett.creeley@amd.com>, Andrew Lunn
 <andrew+netdev@lunn.ch>, "David S. Miller" <davem@davemloft.net>,
 Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
 Simon Horman <horms@kernel.org>, "Nikhil P. Rao" <nikhil.rao@amd.com>,
 Eric Dumazet <edumazet@kernel.org>
X-In-Reply-To: <20261015-ionic-port-info-lifetime-v2-1-57232013fd79@amd.com>