Netdev List
 help / color / mirror / Atom feed
From: Hangbin Liu <hangbin.liu@linux.dev>
To: Jakub Kicinski <kuba@kernel.org>
Cc: davem@davemloft.net, netdev@vger.kernel.org, edumazet@google.com,
	pabeni@redhat.com, andrew+netdev@lunn.ch, horms@kernel.org,
	donald.hunter@gmail.com
Subject: Re: [PATCH net-next 1/2] netlink: specs: tcp_metrics: fix the attribute length checks
Date: Mon, 14 Sep 2026 14:41:06 +0800	[thread overview]
Message-ID: <aqeXAob9hyiXQvhs@fedora> (raw)
In-Reply-To: <20260912234337.308298-1-kuba@kernel.org>

On Sat, Sep 12, 2026 at 04:43:36PM -0700, Jakub Kicinski wrote:
> TCP_FASTOPEN_COOKIE_MAX is the longest cookie we accept, not the shortest
> one. Cookies are even sized, from 4 bytes up, and the ones Linux itself
> generates are 8 bytes, so a 16 byte minimum declares all but the longest
> cookie invalid. The reference policy kept under #if 0 in tcp_metrics.c
> spells it as a maximum, which is what .len means for NLA_BINARY.
> 
> The IPv6 addresses err the other way. The policy uses
> NLA_POLICY_EXACT_LEN() for both, so a request carrying a longer address is
> rejected with -ERANGE, even though the spec advertises 16 bytes as a mere
> minimum. Were the policy generated from this spec, as kernel-policy: global
> promises, the check would turn into NLA_POLICY_MIN_LEN() and start
> accepting over-long addresses, of which nla_get_in6_addr() would take the
> first 16 bytes.
> 
> Nothing generated changes. fopen-cookie is reply-only so it never gets a
> policy entry, and exact-len only feeds the policy (and the fixed size array
> form, which needs a sub-type).
> 
> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
> ---
>  Documentation/netlink/specs/tcp_metrics.yaml | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/Documentation/netlink/specs/tcp_metrics.yaml b/Documentation/netlink/specs/tcp_metrics.yaml
> index 13144aeed31a..1d365908084d 100644
> --- a/Documentation/netlink/specs/tcp_metrics.yaml
> +++ b/Documentation/netlink/specs/tcp_metrics.yaml
> @@ -32,7 +32,7 @@ kernel-policy: global
>          name: addr-ipv6
>          type: binary
>          checks:
> -          min-len: 16
> +          exact-len: 16
>          byte-order: big-endian
>          display-hint: ipv6
>        -
> @@ -63,7 +63,7 @@ kernel-policy: global
>          name: fopen-cookie
>          type: binary
>          checks:
> -          min-len: tcp-fastopen-cookie-max
> +          max-len: tcp-fastopen-cookie-max
>        -
>          name: saddr-ipv4
>          type: u32
> @@ -73,7 +73,7 @@ kernel-policy: global
>          name: saddr-ipv6
>          type: binary
>          checks:
> -          min-len: 16
> +          exact-len: 16
>          byte-order: big-endian
>          display-hint: ipv6
>        -
> -- 
> 2.55.0
> 

Reviewed-by: Hangbin Liu <liuhangbin@kylinos.cn>

  parent reply	other threads:[~2026-09-14  6:41 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-12 23:43 [PATCH net-next 1/2] netlink: specs: tcp_metrics: fix the attribute length checks Jakub Kicinski
2026-09-12 23:43 ` [PATCH net-next 2/2] netlink: specs: tcp_metrics: drop the RTT shift instructions Jakub Kicinski
2026-09-14  6:49   ` Hangbin Liu
2026-09-14  6:41 ` Hangbin Liu [this message]
2026-09-15 13:10 ` [PATCH net-next 1/2] netlink: specs: tcp_metrics: fix the attribute length checks patchwork-bot+netdevbpf

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=aqeXAob9hyiXQvhs@fedora \
    --to=hangbin.liu@linux.dev \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=donald.hunter@gmail.com \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.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