netlink: add ethernet address policy types
Commonly, ethernet addresses are just using a policy of
{ .len = ETH_ALEN }
which leaves userspace free to send more data than it should,
which may hide bugs.
Introduce NLA_EXACT_LEN which checks for exact size, rejecting
the attribute if it's not exactly that length. Also add
NLA_EXACT_LEN_WARN which requires the minimum length and will
warn on longer attributes, for backward compatibility.
Use these to define NLA_POLICY_ETH_ADDR (new strict policy) and
NLA_POLICY_ETH_ADDR_COMPAT (compatible policy with warning);
these are used like this:
static const struct nla_policy <name>[...] = {
[NL_ATTR_NAME] = NLA_POLICY_ETH_ADDR,
...
};
Signed-off-by:
Johannes Berg <johannes.berg@intel.com>
Reviewed-by:
Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Signed-off-by:
David S. Miller <davem@davemloft.net>
Git-commit: b60b87fc2996240e298529a46e122ef62ef9c27f
Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/jberg/mac80211-next.git
CRs-Fixed: 2743684
Change-Id: If057bfa497823f69251ca8e1b951267193530397
Signed-off-by:
Vinita S. Maloo <vmaloo@codeaurora.org>
Loading
Please register or sign in to comment