]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commit - lib/nlattr.c
netlink: make NLA_BINARY validation more flexible
authorJohannes Berg <johannes.berg@intel.com>
Tue, 18 Aug 2020 08:17:33 +0000 (10:17 +0200)
committerDavid S. Miller <davem@davemloft.net>
Tue, 18 Aug 2020 19:28:45 +0000 (12:28 -0700)
commit8aa26c575fb343ebde810b30dad0cba7d8121efb
treed82231bd12bd50475c0eada026b3220f445292ec
parentbc0435855041d7fff0b83dd992fc4be34aa11afb
netlink: make NLA_BINARY validation more flexible

Add range validation for NLA_BINARY, allowing validation of any
combination of combination minimum or maximum lengths, using the
existing NLA_POLICY_RANGE()/NLA_POLICY_FULL_RANGE() macros, just
like for integers where the value is checked.

Also make NLA_POLICY_EXACT_LEN(), NLA_POLICY_EXACT_LEN_WARN()
and NLA_POLICY_MIN_LEN() special cases of this, removing the old
types NLA_EXACT_LEN and NLA_MIN_LEN.

This allows us to save some code where both minimum and maximum
lengths are requires, currently the policy only allows maximum
(NLA_BINARY), minimum (NLA_MIN_LEN) or exact (NLA_EXACT_LEN), so
a range of lengths cannot be accepted and must be checked by the
code that consumes the attributes later.

Also, this allows advertising the correct ranges in the policy
export to userspace. Here, NLA_MIN_LEN and NLA_EXACT_LEN already
were special cases of NLA_BINARY with min and min/max length
respectively.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/net/netlink.h
lib/nlattr.c
net/netlink/policy.c