Netdev Archive on
help / color / mirror / Atom feed
From: Johannes Berg <>
Subject: [PATCH v2 0/3] netlink: allow NLA_BINARY length range validation
Date: Tue, 18 Aug 2020 10:17:30 +0200	[thread overview]
Message-ID: <> (raw)

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

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

 * fix the min<max comment to correctly say min<=max


             reply	other threads:[~2020-08-18  8:17 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-18  8:17 Johannes Berg [this message]
2020-08-18  8:17 ` [PATCH v2 1/3] netlink: consistently use NLA_POLICY_EXACT_LEN() Johannes Berg
2020-08-18  8:53   ` Matthieu Baerts
2020-08-18  8:17 ` [PATCH v2 2/3] netlink: consistently use NLA_POLICY_MIN_LEN() Johannes Berg
2020-08-18  8:17 ` [PATCH v2 3/3] netlink: make NLA_BINARY validation more flexible Johannes Berg
2020-08-18 19:29 ` [PATCH v2 0/3] netlink: allow NLA_BINARY length range validation David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \ \ \ \
    --subject='Re: [PATCH v2 0/3] netlink: allow NLA_BINARY length range validation' \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).