Skip to content

Commit 57e7ded

Browse files
committed
tools: ynl-gen: make sure we validate subtype of array-nest
ArrayNest AKA indexed-array support currently skips inner type validation. We count the attributes and then we parse them, make sure we call validate, too. Otherwise buggy / unexpected kernel response may lead to crashes. Fixes: be5bea1 ("net: add basic C code generators for Netlink") Reviewed-by: Donald Hunter <donald.hunter@gmail.com> Reviewed-by: Jacob Keller <jacob.e.keller@intel.com> Link: https://patch.msgid.link/20250414211851.602096-5-kuba@kernel.org Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent ce6cb81 commit 57e7ded

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

tools/net/ynl/pyynl/ynl_gen_c.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -714,8 +714,11 @@ def _attr_typol(self):
714714
def _attr_get(self, ri, var):
715715
local_vars = ['const struct nlattr *attr2;']
716716
get_lines = [f'attr_{self.c_name} = attr;',
717-
'ynl_attr_for_each_nested(attr2, attr)',
718-
f'\t{var}->n_{self.c_name}++;']
717+
'ynl_attr_for_each_nested(attr2, attr) {',
718+
'\tif (ynl_attr_validate(yarg, attr2))',
719+
'\t\treturn YNL_PARSE_CB_ERROR;',
720+
f'\t{var}->n_{self.c_name}++;',
721+
'}']
719722
return get_lines, None, local_vars
720723

721724

0 commit comments

Comments
 (0)