From: David S. Miller Date: Tue, 18 Aug 2020 19:28:45 +0000 (-0700) Subject: Merge branch 'netlink-allow-NLA_BINARY-length-range-validation' X-Git-Tag: howlett/maple_spf/20210104~792^2~488 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=396fc59e390429e87584d162462c1555fd64576a;p=users%2Fjedix%2Flinux-maple.git Merge branch 'netlink-allow-NLA_BINARY-length-range-validation' Johannes Berg says: ==================== netlink: allow NLA_BINARY length range validation In quite a few places (perhaps particularly in wireless) we need to validation an NLA_BINARY attribute with both a minimum and a maximum length. Currently, we can do either of the two, but not both, given that we have NLA_MIN_LEN (minimum length) and NLA_BINARY (maximum). Extend the range mechanisms that we use for integer validation to apply to NLA_BINARY as well. After converting everything to use NLA_POLICY_MIN_LEN() we can thus get rid of the NLA_MIN_LEN type since that's now a special case of NLA_BINARY with a minimum length validation. Similarly, NLA_EXACT_LEN can be specified using NLA_POLICY_EXACT_LEN() and also maps to the new NLA_BINARY validation (min == max == desired length). Finally, NLA_POLICY_EXACT_LEN_WARN() also gets to be a somewhat special case of this. I haven't included the patch here now that converts nl82011 to use this because it doesn't apply without another cleanup patch, but we can remove a number of hand-coded min/max length checks and get better error messages from the general validation code while doing that. As I had originally built the netlink policy export to userspace in a way that has min/max length for NLA_BINARY (for the types that we used to call NLA_MIN_LEN, NLA_BINARY and NLA_EXACT_LEN) anyway, it doesn't really change anything there except that now there's a chance that userspace sees min length < max length, which previously wasn't possible. v2: * fix the min --- 396fc59e390429e87584d162462c1555fd64576a