netlink: add mask validation
authorJakub Kicinski <kuba@kernel.org>
Mon, 5 Oct 2020 22:07:38 +0000 (15:07 -0700)
committerDavid S. Miller <davem@davemloft.net>
Tue, 6 Oct 2020 13:25:55 +0000 (06:25 -0700)
commitbdbb4e29df8b790db50cb73ce25d23543329f05f
tree78ff81363b9aec24e5199bf9082bcab104883209
parentddcf3b70c5ae8444e920d28e30e7ad4e866c8015
netlink: add mask validation

We don't have good validation policy for existing unsigned int attrs
which serve as flags (for new ones we could use NLA_BITFIELD32).
With increased use of policy dumping having the validation be
expressed as part of the policy is important. Add validation
policy in form of a mask of supported/valid bits.

Support u64 in the uAPI to be future-proof, but really for now
the embedded mask member can only hold 32 bits, so anything with
bit 32+ set will always fail validation.

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/net/netlink.h
include/uapi/linux/netlink.h
lib/nlattr.c
net/netlink/policy.c