Re: [syzbot] [net?] kernel BUG in __nla_validate_parse

From: David Ahern
Date: Sat Mar 09 2024 - 15:56:19 EST


On 3/9/24 11:40 AM, Jakub Kicinski wrote:
> On Sat, 9 Mar 2024 16:25:18 +0100 Eric Dumazet wrote:
>> On Sat, Mar 9, 2024 at 4:13 PM syzbot
>>> ..
>> Petr, can you take a look ?
>>
>> Thanks !
>>
>>
>> commit 2118f9390d83cf942de8b34faf3d35b54f9f4eee
>> Author: Petr Machata <petrm@xxxxxxxxxx>
>> Date: Wed Mar 6 13:49:15 2024 +0100
>>
>> net: nexthop: Adjust netlink policy parsing for a new attribute
>
> Yeah
>
> +static const struct nla_policy rtm_nh_policy_del[] = {
> + [NHA_ID] = { .type = NLA_U32 },
> +};
>
> + err = nlmsg_parse(nlh, sizeof(struct nhmsg), tb, NHA_MAX,
> + rtm_nh_policy_del, extack);
>
> The policy size must be >= max_attr (NHA_MAX).

ARRAY_SIZE is sufficient for both tb and parse. That is what the rest of
the file uses.