mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Kory Maincent <kory.maincent@bootlin.com>
To: Nicolai Buchwitz <nb@tipi-net.de>
Cc: Andrew Lunn <andrew@lunn.ch>, Jakub Kicinski <kuba@kernel.org>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@kernel.org>,
	Paolo Abeni <pabeni@redhat.com>, Simon Horman <horms@kernel.org>,
	Vadim Fedorenko <vadim.fedorenko@linux.dev>,
	Maxime Chevallier <maxime.chevallier@bootlin.com>,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH net v3 1/2] net: ethtool: reject an out of range hwtstamp provider index
Date: Fri, 25 Sep 2026 19:57:20 +0200	[thread overview]
Message-ID: <7782c263-503d-485b-9029-de611536abd6@bootlin.com> (raw)
In-Reply-To: <5ff0fa6eee1605e546d433c7944fa769@tipi-net.de>



On 9/25/26 16:07, Nicolai Buchwitz wrote:
> Hi Kory
> 
> On 25.9.2026 15:55, Kory Maincent wrote:
> 
>> [...]
> 
>>>   static const struct nla_policy
>>>   ethnl_ts_hwtst_prov_policy[ETHTOOL_A_TS_HWTSTAMP_PROVIDER_MAX + 1] = {
>>> -    [ETHTOOL_A_TS_HWTSTAMP_PROVIDER_INDEX] = { .type = NLA_U32 },
>>> +    [ETHTOOL_A_TS_HWTSTAMP_PROVIDER_INDEX] =
>>> +        NLA_POLICY_FULL_RANGE(NLA_U32, &ethnl_ts_prov_index_range),
>>>       [ETHTOOL_A_TS_HWTSTAMP_PROVIDER_QUALIFIER] =
>>>           NLA_POLICY_MAX(NLA_U32, HWTSTAMP_PROVIDER_QUALIFIER_CNT - 1)
>>>   };
>>
>> I think you can simply do this:
>> [ETHTOOL_A_TS_HWTSTAMP_PROVIDER_INDEX] =
>>     NLA_POLICY_MAX(NLA_U32, INT_MAX),
> 
> That was my initial thought, but unfortunately it doesn't work. struct 
> nla_policy's
> .max is s16 and INT_MAX is truncated to -1. It ends up as U64_MAX in the 
> range check
> and in the end nothing gets rejected.
> 
>      include/vdso/limits.h:8:25: warning: overflow in conversion from 'int'
>      to 'short int' changes value from '2147483647' to '-1' [-Woverflow]

Indeed.
Reviewed-by: Kory Maincent <kory.maincent@bootlin.com>

Thank you!

-- 
Köry Maincent, Bootlin
Embedded Linux and kernel engineering
https://bootlin.com


  reply	other threads:[~2026-09-25 17:57 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20260925135237.3432266-1-nb@tipi-net.de>
2026-09-25 13:52 ` Nicolai Buchwitz
2026-09-25 13:55   ` Kory Maincent
2026-09-25 14:07     ` Nicolai Buchwitz
2026-09-25 17:57       ` Kory Maincent [this message]
2026-09-25 13:52 ` [PATCH net v3 2/2] net: ethtool: let tsconfig reach a PHY-only timestamp provider Nicolai Buchwitz

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=7782c263-503d-485b-9029-de611536abd6@bootlin.com \
    --to=kory.maincent@bootlin.com \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maxime.chevallier@bootlin.com \
    --cc=nb@tipi-net.de \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=vadim.fedorenko@linux.dev \
    /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®