netlink: fix policy dump for int with validation callback
Subsystems (2)
Jakub Kicinski
maintainerPATCH 1/1 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.
---
CC: [email protected]
CC: [email protected]
--- include/net/netlink.h | 6 ++++++ net/netlink/policy.c | 5 +++++ 2 files changed, 11 insertions(+)
include/net/netlink.h +6 -0
@@ -321,7 +321,13 @@ enum nla_policy_validation {* All other Unused - but note that it's a union * * Meaning of `validate' field, use via NLA_POLICY_VALIDATE_FN: +* NLA_U8, NLA_U16, +* NLA_U32, NLA_U64, +* NLA_S8, NLA_S16, +* NLA_S32, NLA_S64, +* NLA_MSECS, * NLA_BINARY Validation function called for the attribute. +* * All other Unused - but note that it's a union * * Example:
net/netlink/policy.c +5 -0
@@ -311,6 +311,8 @@ __netlink_policy_dump_write_attr(struct netlink_policy_dump_state *state, NL_POLICY_TYPE_ATTR_PAD)) goto nla_put_failure;break ; + }else if (pt->validation_type ==NLA_VALIDATE_FUNCTION ) { +break ; }nla_get_range_unsigned (pt, &range);
@@ -340,6 +342,9 @@ __netlink_policy_dump_write_attr(struct netlink_policy_dump_state *state,else type =NL_ATTR_TYPE_SINT ; +if (pt->validation_type ==NLA_VALIDATE_FUNCTION ) +break ; +nla_get_range_signed (pt, &range); if (nla_put_s64(skb, NL_POLICY_TYPE_ATTR_MIN_VALUE_S,
Signature · 1 line
2.49.0
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Quoted 10 lines · On Fri, 9 May 2025 14:27:51 -0700 you wrote:
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 429ac6211494 ("devlink: define enum for attr types of dynamic attributes")Reported-by [email protected]Signed-off-by Jakub Kicinski <[email protected]>[...]
Here is the summary with links:
- [net-next] netlink: fix policy dump for int with validation callback
https://git.kernel.org/netdev/net-next/c/a96876057b9e
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html