netlink: export policy in extended ACK
authorJohannes Berg <johannes.berg@intel.com>
Thu, 8 Oct 2020 10:45:17 +0000 (12:45 +0200)
committerJakub Kicinski <kuba@kernel.org>
Sat, 10 Oct 2020 03:22:32 +0000 (20:22 -0700)
commit44f3625bc61653ea3bde9960298faf2f5518fda5
treee36d5d8e5795a8992618cc2f756c5bc38d977434
parentd2681e93b0ab7afe01d07f8c96f14afaccdcea4c
netlink: export policy in extended ACK

Add a new attribute NLMSGERR_ATTR_POLICY to the extended ACK
to advertise the policy, e.g. if an attribute was out of range,
you'll know the range that's permissible.

Add new NL_SET_ERR_MSG_ATTR_POL() and NL_SET_ERR_MSG_ATTR_POL()
macros to set this, since realistically it's only useful to do
this when the bad attribute (offset) is also returned.

Use it in lib/nlattr.c which practically does all the policy
validation.

v2:
 - add and use netlink_policy_dump_attr_size_estimate()
v3:
 - remove redundant break
v4:
 - really remove redundant break ... sorry

Reviewed-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
include/linux/netlink.h
include/net/netlink.h
include/uapi/linux/netlink.h
lib/nlattr.c
net/netlink/af_netlink.c
net/netlink/policy.c