mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Simon Horman <horms@kernel.org>
To: Xia Yan <yanxia@cmss.chinamobile.com>
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
Subject: Re: [PATCH net] net: skbuff: reject zero MPLS TTL before decrementing
Date: Mon, 2 Nov 2026 12:37:27 +0000	[thread overview]
Message-ID: <20261102123727.GE257209@horms.kernel.org> (raw)
In-Reply-To: <179345092130.132560.5590780813492711780@cmss.chinamobile.com>

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>


      reply	other threads:[~2026-11-02 12:37 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-31 11:41 Avi Weiss
2026-10-31 11:43 ` netdev-bot+sinfo
2026-10-31 12:48 ` Xia Yan
2026-11-02 12:37   ` Simon Horman [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261102123727.GE257209@horms.kernel.org \
    --to=horms@kernel.org \
    --cc=almasrymina@google.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=jiayuan.chen@linux.dev \
    --cc=john.hurley@netronome.com \
    --cc=josef@toxicpanda.com \
    --cc=kerneljasonxing@gmail.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=thnkslprpt@gmail.com \
    --cc=willemb@google.com \
    --cc=xiyou.wangcong@gmail.com \
    --cc=yana06070@163.com \
    --cc=yanxia@cmss.chinamobile.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®