Skip to content

Commit 14c3634

Browse files
committed
netlink: fix policy dump for int with validation callback
JIRA: https://issues.redhat.com/browse/RHEL-104975 commit a968760 Author: Jakub Kicinski <kuba@kernel.org> Date: Fri May 9 14:27:51 2025 -0700 netlink: fix policy dump for int with validation callback Recent devlink change added validation of an integer value via NLA_POLICY_VALIDATE_FN, for sparse enums. Handle this in policy dump. We can't extract any info out of the callback, so report only the type. Fixes: 429ac62 ("devlink: define enum for attr types of dynamic attributes") Reported-by: syzbot+01eb26848144516e7f0a@syzkaller.appspotmail.com Link: https://patch.msgid.link/20250509212751.1905149-1-kuba@kernel.org Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Ivan Vecera <ivecera@redhat.com>
1 parent e553a58 commit 14c3634

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

include/net/netlink.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,13 @@ enum nla_policy_validation {
318318
* All other Unused - but note that it's a union
319319
*
320320
* Meaning of `validate' field, use via NLA_POLICY_VALIDATE_FN:
321+
* NLA_U8, NLA_U16,
322+
* NLA_U32, NLA_U64,
323+
* NLA_S8, NLA_S16,
324+
* NLA_S32, NLA_S64,
325+
* NLA_MSECS,
321326
* NLA_BINARY Validation function called for the attribute.
327+
*
322328
* All other Unused - but note that it's a union
323329
*
324330
* Example:

net/netlink/policy.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,8 @@ __netlink_policy_dump_write_attr(struct netlink_policy_dump_state *state,
311311
NL_POLICY_TYPE_ATTR_PAD))
312312
goto nla_put_failure;
313313
break;
314+
} else if (pt->validation_type == NLA_VALIDATE_FUNCTION) {
315+
break;
314316
}
315317

316318
nla_get_range_unsigned(pt, &range);
@@ -340,6 +342,9 @@ __netlink_policy_dump_write_attr(struct netlink_policy_dump_state *state,
340342
else
341343
type = NL_ATTR_TYPE_SINT;
342344

345+
if (pt->validation_type == NLA_VALIDATE_FUNCTION)
346+
break;
347+
343348
nla_get_range_signed(pt, &range);
344349

345350
if (nla_put_s64(skb, NL_POLICY_TYPE_ATTR_MIN_VALUE_S,

0 commit comments

Comments
 (0)