Re: [PATCH net-next 06/11] tools: ynl-gen: don't validate nested array attribute types
From: Asbjørn Sloth Tønnesen <hidden>
Date: 2025-09-06 13:22:14
Also in:
lkml
On 9/6/25 12:23 AM, Jakub Kicinski wrote:
On Thu, 4 Sep 2025 22:01:29 +0000 Asbjørn Sloth Tønnesen wrote:quoted
In nested arrays don't require that the intermediate attribute type should be a valid attribute type, it might just be an index or simple 0, it is often not even used. See include/net/netlink.h about NLA_NESTED_ARRAY:quoted
The difference to NLA_NESTED is the structure: NLA_NESTED has the nested attributes directly inside while an array has the nested attributes at another level down and the attribute types directly in the nesting don't matter.I don't understand, please provide more details. This is an ArrayNest, right? [ARRAY-ATTR] [ENTRY] [MEMBER1] [MEMBER2] [ENTRY] [MEMBER1] [MEMBER2] Which level are you saying doesn't matter? If entry is a nest it must be a valid nest. What the comment you're quoting is saying is that the nla_type of ENTRY doesn't matter.
I will expand this in v2, but the gist of it is that this is part of the "split attribute counting, and later allocating an array to hold them" code. The check that I remove for nested arrays, is an early exit during the counting phase. Later in the allocation and parse phase it validates the nested payload. In include/uapi/linux/wireguard.h: > WGDEVICE_A_PEERS: NLA_NESTED > 0: NLA_NESTED > WGPEER_A_PUBLIC_KEY: NLA_EXACT_LEN, len WG_KEY_LEN > [..] > 0: NLA_NESTED > ... > ... The current check requires that the nested type is valid in the nested attribute set, which in this case resolves to WGDEVICE_A_UNSPEC, which is YNL_PT_REJECT, and it takes the early exit and returns YNL_PARSE_CB_ERROR.