• Johannes Berg's avatar
    netlink: make NLA_BINARY validation more flexible · 8aa26c57
    Johannes Berg authored
    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: default avatarJohannes Berg <johannes.berg@intel.com>
    Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
    8aa26c57
policy.c 6.95 KB