• Johannes Berg's avatar
    netlink: add ethernet address policy types · b60b87fc
    Johannes Berg authored
    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: default avatarJohannes Berg <johannes.berg@intel.com>
    Reviewed-by: default avatarMarcelo Ricardo Leitner <marcelo.leitner@gmail.com>
    Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
    b60b87fc
nlattr.c 18.2 KB