🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #9618

Re: [PATCH net] net: skbuff: reject zero MPLS TTL before decrementing

#9618
From: Simon Horman
Date: Mon, 02 Nov 2026 12:37
35 lines
9596 bytes
On Sat, Oct 31, 2026 at 08:48:41PM +0800, Xia Yan wrote:
> On 10/31/26 11:41, Avi Weiss wrote:
> > skb_mpls_dec_ttl() decrements the u8 TTL before checking whether it
> > expired. An incoming TTL of zero wraps to 255, causing the TC MPLS
> > dec_ttl action to pass an expired packet instead of dropping it.
> >
> > Reject a zero TTL before the decrement while preserving the existing
> > behavior for TTL one and valid TTL values.
> 
> Nice catch. I checked the wraparound against the C promotion and
> conversion rules: with ttl being a u8, a zero TTL on the old path
> decrements to 255 and the packet passes with a revived TTL. The new
> check catches exactly that case, TTL one still returns -EINVAL, and
> values of two and above are unchanged bit for bit.
> 
> The only in-tree caller I see is the TC dec_ttl action in
> tcf_mpls_act(), which maps the error to TC_ACT_SHOT, so the rejected
> packet is dropped. mpls_forward() already rejects TTL zero and one
> (`dec.ttl <= 1`), so the two MPLS decrement paths now agree.
> 
> One minor observation, no change requested: `!ttl || !--ttl` is
> equivalent to `ttl <= 1`, the form mpls_forward() uses. Stylistic
> only; the patch is correct as posted.

Let's not get bogged down on this one. But FWIIW I think the decrement
is needed for the happy-path to work correctly. In particular, this line
which appears after the condition under discussion:

	lse |= ttl << MPLS_LS_TTL_SHIFT;

> 
> Reviewed-by: Xia Yan <yanxia@cmss.chinamobile.com>

Reviewed-by: Simon Horman <horms@kernel.org>
Technical Details
Message-ID: <20261102123727.GE257209@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-354663-linux-kernel-netdev=dewy.ru
References: <20261031114135.3784868-2-thnkslprpt@gmail.com> <179345092130.132560.5590780813492711780@cmss.chinamobile.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-354663-linux-kernel-netdev=dewy.ru
From: horms@kernel.org (Simon Horman)
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net] net: skbuff: reject zero MPLS TTL before decrementing
Date: Mon, 2 Nov 2026 12:37:27 +0000
Organization: Usenet Network
Message-ID: <20261102123727.GE257209@horms.kernel.org>
References: <20261031114135.3784868-2-thnkslprpt@gmail.com>
 <179345092130.132560.5590780813492711780@cmss.chinamobile.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: usenet.network;
	logging-data="2922063"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:dCRx19w3WunOoml17hnNUTbPP3Y= sha256:BVf9RrFVhpfyuFPM2ZR26Pjy3FCOgkFi2WIVSDAdNy0=
	sha1:2HoMGeLBPrl/RjbXeRWrIJzurFI= sha256:engyhUrUAjx9Ih6I6iQnC0B74EHa32f+QzDHuECrpTA=
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 07E681124F2; Mon,  2 Nov 2026 15:41:54 +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 mG0bH68Zcpm5;
	Mon,  2 Nov 2026 15:41:51 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-354663-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 tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])
	by mail.dewy.ru (Postfix) with ESMTPS id 624621124DC; Mon,  2 Nov 2026 15:41:40 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by tor.lore.kernel.org (Postfix) with ESMTP id B990D2EDFF; Mon,  2 Nov 2026 12:37:35 +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=1793623053;
	b=sDNJu6XdcPJwrZMTYNArNkG92h1xh806CiGxZJ9RhbKE+Jx3xaLOsYweamiH81P/OVz8
	 Jetc1/8cjEM7b/L9xNCc9pd8+8UWun/gEtAp1iBW11WWxqCeh9fxhlYEvq3RS/GAIjm1K
	 5eUGnIbma1zB+au1nOB3VWeA3V35VSlm3u83JiC7zz986F/qpm9+PVWzpcQq1CagYl1tf
	 OcYEoLDoapiiwEKOe78SK0kdWb0zzNFD615MgS0ZBpBjI7AioNOP7fHL/AHMxGMJsGd+o
	 aoaruloxyjQxRulV1nyuqhDb/KBIwxbVYBv+qfehJuVAFCs62OUkrfyo9cUV8TWfoKQ==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793623053;
	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=gccdM5SBnItmENUj+sFwUbujK/STGRaKcAgii696SPA=;
	b=G0JQGJd7pARQEj6QzwyY9mbH91D4xs9SdVyEIPaKn+r7vTts3s4qTyJlKPTM+xcHMhbY
	 +5J4Yow+t3ikp78XJLHBh1ih4GjL9DEZ5pI4y3OCSLk/JDh32vurXLIRXc/XmgH+f947x
	 ppqteMOcVKJeyLeC3O2osO+h1BfQ2ZPZiDmg0guEQ8ndnLc4uSRXP8ihV4Y0e+Z/Z+/pL
	 fXWSDjI8h6wWaF9cBAuVQ320gE1530pY/OoIAPxSn3nh9Q2TP4GY18gzuM+0qqyk+O/FV
	 0ItyYIQ/xoFcGw3YTv1ZVIYsDIDUzLE8kaIhVcdCUwskrD3JfP2gT7lyirvm2K4B4FA==
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=XaY6mEUI;
	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 AB3FE60A2610;
	Mon,  2 Nov 2026 12:37:33 +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=XaY6mEUI
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=1793623052;
	b=kqGjmLizEdYVWxpoyCRiWP/0j/4dMihYuHto1wAbsATCNQCQBrNCEDlJOXsFJX99K94z
	 51yzYvk/83u7ybRgx71oNE34kEmv0D2/GFAr5b1HV7CXENolNKV7fiP/HiLAA9dKMsYrV
	 hkAf85UWtJg2v+JfA7hZGeEHBsC3aF+oCWJ/ecHPbe+BmgC32gslY6IQnLJpatOi8oSBN
	 oy2ppmkyjuJEFXunNwpyRWb4Vqkxubhvh4J2QAbTjJWb8+2VrID1waMXooAAZM6BluJma
	 HddH4yC3yYv4LGsRfs1xyo3stRsdS/gEWeJeIZsTpI301rKDpDCvcxR6H+FH0t/tQrA==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793623052;
	h=Received:DKIM-Signature:Date:From:To:Cc:Subject:Message-ID:
	 References:MIME-Version:Content-Type:Content-Disposition:In-Reply-To;
	bh=gccdM5SBnItmENUj+sFwUbujK/STGRaKcAgii696SPA=;
	b=0c4eTB6NCyL2LI44Vr3M+EtbMDjow6NNI9pYtYaWBmH4xN1wPP9/7oOlLGLlSKBp9Jqa
	 /jlsf6a9tCVKTjPFIMpYTxAqu5zF9ON49G62XkvWOIEOecwHpC+UgpcIExUXb28K9lVfs
	 CXF1WubBL0PtNniL3cdT6NCn9T18kAtdTHwufFWvI2A5lGAQ6NyNCsE4sbyP9gGIXBbrx
	 k0ii+fFDIEU0mF47X6nIccn95ctvq7Du7rTdEBq7YtOW/m/XYeFRqx4XyPTAeF6mplvlH
	 c4eTc4HGXPbg9TAT8+eusd72lxmAojnUYh3GYJG2hyxwCcButNUJyGW2AvP901efXdQ==
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=XaY6mEUI;
	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 8D4BA606A329;
	Mon,  2 Nov 2026 12:37:32 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5E2FA1F00A16;
	Mon,  2 Nov 2026 12:37:29 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1793623052;
	bh=gccdM5SBnItmENUj+sFwUbujK/STGRaKcAgii696SPA=;
	h=Date:From:To:Cc:Subject:References:In-Reply-To;
	b=XaY6mEUI2EnsGplIHGQHYLYYSyovQZcWYsvh25JSMtIAwk7jMiMVn+ns8JI2KkRjE
	 yAfY99ATBWhu96/o2OAs5F6t1XA9UHUP9GfXf02AKOUoNy/z3enc0zHwijTPJO1SEU
	 vSceFqceyBRGhS+bU271Yi0jHcmIVJDcxxOltgMviyy4MG5UseJjvPzoYMncGblNAr
	 RWVOtauquYjLeSmAaMOsmmmg4M24mG5vLwuMkHliEuJHgkXI4Pot6+LsTENYW4p0y5
	 RtCLxV20iZTbuNCTf3YmwUVWQhMWH3gmDlujzR+RnGcQzAztldQQLnh0WF23s8sFbo
	 rj+dtWM6/ctvw==
X-Cc: Avi Weiss <thnkslprpt@gmail.com>, netdev@vger.kernel.org,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@kernel.org>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Jason Xing <kerneljasonxing@gmail.com>,
	Willem de Bruijn <willemb@google.com>,
	Mina Almasry <almasrymina@google.com>,
	Josef Bacik <josef@toxicpanda.com>,
	Jiayuan Chen <jiayuan.chen@linux.dev>,
	John Hurley <john.hurley@netronome.com>,
	Cong Wang <xiyou.wangcong@gmail.com>, linux-kernel@vger.kernel.org,
	yana06070@163.com
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: <179345092130.132560.5590780813492711780@cmss.chinamobile.com>