Re: [PATCH net v3 1/2] net: ethtool: reject an out of range hwtstamp provider index

From
Nicolai Buchwitz <nb@tipi-net.de>
Date
2026-09-25 14:07:25
Also in
lkml
Reply to
Kory Maincent, 2026-09-25
Hi Kory

On 25.9.2026 15:55, Kory Maincent wrote:
[...]
quoted
  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]
[...]
Thanks,
Nicolai
Thread (6 messages) 6 messages, 3 authors, last reply 2026-09-29
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help