Skip to content

netlink: extended attribute validation

Johannes Berg linux-wireless netdev 1 version New

Get series with b4
b4 am [email protected]

Versions newest first

  1. v2 Latest2 patches 0 repliesNew

Changes in v2 from the cover letter

* split off validate_type from type and use that for min/max/range and function; this is better because the range is limited to the range of s16 and so things like "u16 with minimum value 1" couldn't be expressed earlier
* add macros for this, e.g. NLA_POLICY_MIN(NLA_U16, 1) for the case mentioned in the previous bullet

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2netlink: add attribute range validation to policyinclude/net/netlink.h lib/nlattr.c+136 -30 replies
2/2netlink: add validation function to policyinclude/net/netlink.h lib/nlattr.c+30 -10 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v2 yet.

Read the v2 thread

Cover letter [PATCH v2 0/2] netlink: extended attribute validation

This adds further netlink attribute validation:
* min/max/range validation
* validation through a custom function pointer

This is useful to
* reduce boilerplate code in command handling code, if attributes are used commonly across different commands
* get more extended ACK error messages/attribute pointers
* ensure attributes are valid even when ignored (though this might be a problem when converting existing code)

Changes since v1:
* split off validate_type from type and use that for min/max/range and function; this is better because the range is limited to the range of s16 and so things like "u16 with minimum value 1" couldn't be expressed earlier
* add macros for this, e.g. NLA_POLICY_MIN(NLA_U16, 1) for the case mentioned in the previous bullet

Using this pretty much in all places where applicable in nl80211 reduces the code size there by about 1.8KiB, with just a minimal code increase in lib/nlattr.o.

johannes