Subject: Re: [PATCH 1/2 net-next v2] ipv4: validate IPV4_DEVCONF attributes properly

From: Jakub Kicinski <[email-masked]>
Date: Mon, 2 Mar 2026 16:18:24 -0800

On Mon, 2 Mar 2026 09:35:06 +0100 Fernando Fernandez Mancera wrote:
> >> Please note that MEDIUM_ID is defined as NLA_U32 too because currently
> >> its usage through netlink is broken for its valid value -1. Modifying
> >> the type to NLA_S32 would break existing users of set/get netlink
> >> operation.  
> > 
> > Say more? The policy type not matching the accessor used by the kernel
> > is probably fine in this case (since there's a common accessor used for
> > all attrs). If it helps the policy, we can use a different type.
> 
> The problem is not only not matching the accessor.. the problem is that 
> while it was not validated if users were using NLA_U32 as indicated by 
> the original implementation (see blamed commit), this would break them.
> 
> Is it one option to set the type to NLA_S32 and wait to see if someone 
> complains? I am not sure how many people might be using it considering 
> the type is wrong.

Sorry, I'm not connecting the dots.

	[IPV4_DEVCONF_MEDIUM_ID]	= { .type = NLA_U32 },
vs 
	[IPV4_DEVCONF_MEDIUM_ID]	= { .type = NLA_S32 },

makes absolutely _no_ difference. For bare types with no ranges 
the validation will only check the attr is 4B which is identical 
for both. 

For S32 you can add a range, however, the NLA_POLICY_RANGE() takes 
two signed 16b values. So a range of -1 .. x is completely fine.