🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #8822

Re: [PATCH net v1] net/mlx5e: kTLS, Fix missing error unwind when enabling RX offload

#8822
From: Simon Horman
Date: Fri, 30 Oct 2026 08:25
103 lines
12332 bytes
On Fri, Oct 30, 2026 at 10:08:31AM +0800, Xuanqiang Luo wrote:
> On 2026/10/29 at 21:40 Simon Horman wrote:
> > On Mon, Oct 26, 2026 at 06:53:46PM +0900, Xuanqiang Luo wrote:
> > > From: Xuanqiang Luo <luoxuanqiang@kylinos.cn>
> > > 
> > > Since commit abed42f9cd80 ("net/mlx5e: Conditionally create async
> > > ICOSQ"), the async ICOSQ is only created when an XDP program is attached
> > > or priv->ktls_rx_was_enabled is set. When TLS RX offload is enabled for
> > > the first time, mlx5e_ktls_set_feature_rx() sets the flag and reopens
> > > the channels so that they get the queue, but it ignores the return value
> > > of mlx5e_safe_reopen_channels().
> > > 
> > > If the reopen fails, mlx5e_safe_switch_params() keeps the old channels,
> > > which have no async ICOSQ, while NETIF_F_HW_TLS_RX is still reported as
> > > enabled. The next offloaded RX connection then dereferences the NULL
> > > c->async_icosq in post_rx_param_wqes(). Enabling the feature again does
> > > not help, as the flag is already set and the reopen is skipped.
> > > 
> > > Propagate the error, clear the flag and destroy the accel TCP flow
> > > tables again, so that the feature stays disabled and the next attempt
> > > retries the reopen.
> > > 
> > > Fixes: abed42f9cd80 ("net/mlx5e: Conditionally create async ICOSQ")
> > > Signed-off-by: Xuanqiang Luo <luoxuanqiang@kylinos.cn>
> > > ---
> > > Found by code inspection while backporting commit abed42f9cd80 to a
> > > downstream kernel. I do not have a crypto-enabled ConnectX NIC, so the
> > > failure has not been reproduced and the fix is only compile-tested.
> > > 
> > > The crash itself is the one described in the changelog of abed42f9cd80
> > > ("async ICOSQ allocation is not triggered, causing a NULL pointer
> > > crash"). This patch only covers the case where the reopen that should
> > > create the queue fails. ktls.c is also the only caller that ignores the
> > > return value of mlx5e_safe_reopen_channels(); the callers in health.c
> > > and reporter_tx.c check it.
> > > 
> > >   drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls.c | 6 +++++-
> > >   1 file changed, 5 insertions(+), 1 deletion(-)
> > 
> > I agree that a minimal approach to addressing this problem is appropriate
> > for net.
> > 
> > Reviewed-by: Simon Horman <horms@kernel.org>
> 
> Thanks for the review!
> 
> > 
> > However, I do think the logic of this function is becoming somewhat
> > convoluted and would benefit from:
> > 
> > 1. Handling error paths in conditionals while leaving
> >     the main thread of execution unconditional.
> > 
> > 2. Use goto for unwind.
> > 
> > This is approach is complicated by the function needing to
> > handle the enable condition. But at any rate, maybe a follow-up patch do do
> > something like this would be worthwhile?
> > 
> > diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls.c b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls.c
> > index 3cc1213c2f68..0f5dcd1b822e 100644
> > --- a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls.c
> > +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls.c
> > @@ -137,19 +137,22 @@ int mlx5e_ktls_set_feature_rx(struct net_device *netdev, bool enable)
> >   	mutex_lock(&priv->state_lock);
> >   	if (enable) {
> >   		err = mlx5e_accel_fs_tcp_create(priv->fs);
> > -		if (!err && !priv->ktls_rx_was_enabled) {
> > -			priv->ktls_rx_was_enabled = true;
> > -			err = mlx5e_safe_reopen_channels(priv);
> > -			if (err) {
> > -				priv->ktls_rx_was_enabled = false;
> > -				mlx5e_accel_fs_tcp_destroy(priv->fs);
> > -			}
> > +		if (err || priv->ktls_rx_was_enabled)
> > +			goto out_unlock;
> > +
> > +		priv->ktls_rx_was_enabled = true;
> > +		err = mlx5e_safe_reopen_channels(priv);
> > +		if (err) {
> > +			priv->ktls_rx_was_enabled = false;
> > +			enable = false;
> >   		}
> > -	} else {
> > -		mlx5e_accel_fs_tcp_destroy(priv->fs);
> >   	}
> > -	mutex_unlock(&priv->state_lock);
> > +	if (!enable)
> > +		mlx5e_accel_fs_tcp_destroy(priv->fs);
> > +
> > +out_unlock:
> > +	mutex_unlock(&priv->state_lock);
> >   	return err;
> >   }
> Thanks for the suggestion. Agreed, the nesting is getting hard to
> follow. I'll send a cleanup along these lines to net-next once this
> fix has made it there.

Likewise, thanks.

Just to be clear, the patch I provided informally in my previous email
is compile tested only.
Technical Details
Message-ID: <20261030082550.GM257209@horms.kernel.org>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-353655-linux-kernel-netdev=dewy.ru
References: <20261026095346.1212609-1-xuanqiang.luo@linux.dev> <20261029134019.GG257209@horms.kernel.org> <8a565dd0-f2a7-4d18-9df7-bcf1ed303a59@linux.dev>

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-353655-linux-kernel-netdev=dewy.ru
From: horms@kernel.org (Simon Horman)
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net v1] net/mlx5e: kTLS, Fix missing error unwind when
 enabling RX offload
Date: Fri, 30 Oct 2026 08:25:50 +0000
Organization: Usenet Network
Message-ID: <20261030082550.GM257209@horms.kernel.org>
References: <20261026095346.1212609-1-xuanqiang.luo@linux.dev>
 <20261029134019.GG257209@horms.kernel.org>
 <8a565dd0-f2a7-4d18-9df7-bcf1ed303a59@linux.dev>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: usenet.network;
	logging-data="2191260"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:iC2ov+L1NkW8Yv6IXxxhs+n5IZs= sha256:BLBfu7kS4lcsH9Y0sQV+CCmXSPqXNYghbi+IPbF2YBY=
	sha1:t0Mpys80H0jmTCdkazQDcD49oXE= sha256:4DyJ3ZUPTq3Q3S7WbfjXvRe+mvuB9MRBDxTn9SxXHNQ=
Content-Disposition: inline
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 07988125C8A; Fri, 30 Oct 2026 11:31:16 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.401
X-Spam-Status: No, score=-3.401 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] 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 Bs41V672oqVG;
	Fri, 30 Oct 2026 11:31:13 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-353655-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 DEEBC125C86; Fri, 30 Oct 2026 11:31:04 +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 1F309310DD; Fri, 30 Oct 2026 08:26:06 +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=1793348765;
	b=EvT8OlDzq8g/B1C9e/7PvorodVzEeh5mWY2EmhmeJqQVDTd353fS3Bv6uZpkv1e9xaVB
	 8De14w0F9OB4pUKmU/80h2gZF9kP3QCpiEdfixnbiymV2wjpz5yJZ2BnL4+GB0lD1cX+6
	 f7eoDyuAJBItxRbDruitR5rshh0agNxadM0NRWzt+d1owtG58Rjh1VPyQUpd8wUOyT+6D
	 xMbeJNCe0hxqqw0wiHwY47EyUfvW/JxRhf+NpBY88yl7/KtrpQcc8VXaQ/W/uZMhmPUiS
	 ABZwjE1fvUWmZi2E2Umb193wVI0xxHo2taCIHu2w7Uyp+kwGpRltBC71VmOew8glFCw==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793348765;
	h=X-Original-To:Received:Received:DKIM-Signature:Date:From:To:Cc:
	 Subject:Message-ID:References:X-Mailing-List:List-Id:List-Post:
	 List-Help:List-Subscribe:List-Unsubscribe:List-Owner:Precedence:
	 MIME-Version:Content-Type:Content-Disposition:In-Reply-To;
	bh=yyok/7kTqnmIKTiZKOdqHEMv9e2GxdKkMvuJpoDTbc4=;
	b=3q+gvaeqZTIx17Knxh7O9W2yEqbbYNwWIFh2Kz7/XQLgc2iaKljDOi3LaE5Q574xXp7k
	 a1cskyv7VjiqUSlbobNlM0pzqRtAHVlibjgeL/bInFd0EFcUpdIsDoC4fmDu1QuCbyPq2
	 WtApj7qd3c5Ga6YTLySGZ8WNv3oFThfIT2ZpffQo1OWI+meVucx2wkoY1WIbHmwPkI+Qv
	 ozRjnky9rfR9PYUux1EOqyRoWMfpLgGpLvOZHeuLHzy5upRCuRqmrxZ+WLnyFq0tNiBr6
	 3FJvCmJTyPkBOMf2fcNWhChMAZ5Fil+mjHWpwp0MskUodn0dlOJdicVBVilFUPOZoxw==
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=HTzGyBTm;
	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 666AF606A326;
	Fri, 30 Oct 2026 08:26:05 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key, unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=HTzGyBTm
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=1793348756;
	b=L0b/f/CANApkx/xAGJyHte110lq81SMZf16TU1HTi8ZxcdObh/1w+/zHvFaDbiapc2Ix
	 k1wIiPzCxLjkdxWGW4cEX49zVwA0C6fKBxPaSGKbuDrSs4szCjWNrKu/124YQgB8wVgI/
	 jeA51CpZrCJfJuMhpPCrmz44vA5diuNky3umXVTqzUZyw7fBFyYGi0kV2VOa3xtc/1yxb
	 YBGaEb4pE+5KT4PU79WEI8+juvXqknP1nwlAHUWRS+/HHNxFnweJLUN9/njWS5xqUQY8h
	 HLhfgNUJmxtfJz4r43M+h/51fvfapP4D2CEkBDaAiIVQOi+gHJpa6lKAFI1pLBy+dbw==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793348756;
	h=Received:DKIM-Signature:Date:From:To:Cc:Subject:Message-ID:
	 References:MIME-Version:Content-Type:Content-Disposition:In-Reply-To;
	bh=yyok/7kTqnmIKTiZKOdqHEMv9e2GxdKkMvuJpoDTbc4=;
	b=J/IH217G7oLua13WUZDn3LPbPA1y1HJj8kRTOeK8V5C0ibWvTvixEym+FkiwNomjZVbx
	 OMhcnlArImWDYBLjTXVFw0dd0Ik4SIhUuvXfVdCWCxVAsrvNqEkCNYwJzUf09atde4HS5
	 aOX1W6LA54Kh6+Hj/SILtDeFfHOyXUeS9qn4INi5FnSjpA8K4a2z6O5WuwGpkMbBUULDx
	 fawdAYsir7jPJsXLG9K6Yw74tCblt/yz0hL7dxFJ2tgcmK2sfv3bueRuBfnZcJl1tO2LL
	 boTPhNyblyJfLzrrIEkxearsj+1lKp5eblmowLdbNWRhO237hFMh1xOxFCE+lYQ8OwA==
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=HTzGyBTm;
	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 284B1606A31A;
	Fri, 30 Oct 2026 08:25:55 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id E7BA61F000C1;
	Fri, 30 Oct 2026 08:25:52 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1793348755;
	bh=yyok/7kTqnmIKTiZKOdqHEMv9e2GxdKkMvuJpoDTbc4=;
	h=Date:From:To:Cc:Subject:References:In-Reply-To;
	b=HTzGyBTmW80MuUJ01VRc3CawL+cBO03XtXw0+oNf9fn26Cvgrl2tGbb0lC533FKMk
	 E4uDS1yZ0yKu89xK6zU1GlR4ghOqoIBgTfbN7Hud5tKEiBUg8tfAvWM8dfRrydaKJA
	 K1oMOk3fKeWxw+BDAlsjH+sgtaqdgrWfEN8gX4/KlNCn/KTWGJB5sStZjOQ7JCuEHD
	 DX78heTEzsoK6rHr2L/OyFzrlwJ3m2xbXvd8zP7s618i/PttYuvQbKGOo92sBU1V3q
	 T8rc+8Q/8bFVAkmug8th+C9T5YtrWAet3LxOP+n80EMiOijCn3JenihPn+sMYvAB9W
	 +4sHsFO38Ly1Q==
X-Cc: netdev@vger.kernel.org, saeedm@nvidia.com, leon@kernel.org,
	tariqt@nvidia.com, mbloch@nvidia.com, borisp@nvidia.com,
	witu@nvidia.com, andrew+netdev@lunn.ch, davem@davemloft.net,
	edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com,
	linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org,
	Xuanqiang Luo <luoxuanqiang@kylinos.cn>
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
X-In-Reply-To: <8a565dd0-f2a7-4d18-9df7-bcf1ed303a59@linux.dev>