OSDN Git Service

netlink: add ethernet address policy types
authorJohannes Berg <johannes.berg@intel.com>
Mon, 17 Sep 2018 09:57:29 +0000 (11:57 +0200)
committerDavid S. Miller <davem@davemloft.net>
Wed, 19 Sep 2018 02:51:29 +0000 (19:51 -0700)
commitb60b87fc2996240e298529a46e122ef62ef9c27f
treea39a2b84798368f1c53b412586eff77e6e3b1673
parent568b742a9d9888aca876b6ad9fa45490f18bee0a
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>
include/net/netlink.h
lib/nlattr.c