From: Johannes Berg <johannes@sipsolutions.net>
To: netdev@vger.kernel.org
Cc: Antonio Quartulli <ordex@autistici.org>,
linux-wireless@vger.kernel.org,
Johannes Berg <johannes.berg@intel.com>
Subject: [PATCH 5/7] netlink: allow NLA_MSECS to have range validation
Date: Wed, 29 Apr 2020 15:48:41 +0200 [thread overview]
Message-ID: <20200429154836.b9b70600438d.I46e9164d064042d49227b9af7a686b3a02080ff0@changeid> (raw)
In-Reply-To: <20200429134843.42224-1-johannes@sipsolutions.net>
From: Johannes Berg <johannes.berg@intel.com>
Since NLA_MSECS is really equivalent to NLA_U64, allow
it to have range validation as well.
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
---
include/net/netlink.h | 6 ++++--
lib/nlattr.c | 2 ++
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/include/net/netlink.h b/include/net/netlink.h
index 94a7df4ab122..4acd7165e900 100644
--- a/include/net/netlink.h
+++ b/include/net/netlink.h
@@ -371,7 +371,8 @@ struct nla_policy {
#define __NLA_ENSURE(condition) BUILD_BUG_ON_ZERO(!(condition))
#define NLA_ENSURE_UINT_TYPE(tp) \
(__NLA_ENSURE(tp == NLA_U8 || tp == NLA_U16 || \
- tp == NLA_U32 || tp == NLA_U64) + tp)
+ tp == NLA_U32 || tp == NLA_U64 || \
+ tp == NLA_MSECS) + tp)
#define NLA_ENSURE_SINT_TYPE(tp) \
(__NLA_ENSURE(tp == NLA_S8 || tp == NLA_S16 || \
tp == NLA_S32 || tp == NLA_S64) + tp)
@@ -379,7 +380,8 @@ struct nla_policy {
(__NLA_ENSURE(tp == NLA_S8 || tp == NLA_U8 || \
tp == NLA_S16 || tp == NLA_U16 || \
tp == NLA_S32 || tp == NLA_U32 || \
- tp == NLA_S64 || tp == NLA_U64) + tp)
+ tp == NLA_S64 || tp == NLA_U64 || \
+ tp == NLA_MSECS) + tp)
#define NLA_ENSURE_NO_VALIDATION_PTR(tp) \
(__NLA_ENSURE(tp != NLA_BITFIELD32 && \
tp != NLA_REJECT && \
diff --git a/lib/nlattr.c b/lib/nlattr.c
index bb66d06cc6f9..ab7fa7726c12 100644
--- a/lib/nlattr.c
+++ b/lib/nlattr.c
@@ -150,6 +150,7 @@ static int nla_validate_int_range_unsigned(const struct nla_policy *pt,
value = nla_get_u32(nla);
break;
case NLA_U64:
+ case NLA_MSECS:
value = nla_get_u64(nla);
break;
default:
@@ -226,6 +227,7 @@ static int nla_validate_int_range(const struct nla_policy *pt,
case NLA_U16:
case NLA_U32:
case NLA_U64:
+ case NLA_MSECS:
return nla_validate_int_range_unsigned(pt, nla, extack);
case NLA_S8:
case NLA_S16:
--
2.25.1
next prev parent reply other threads:[~2020-04-29 13:49 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-29 13:48 [PATCH 0/7] netlink validation improvements/refactoring Johannes Berg
2020-04-29 13:48 ` [PATCH 1/7] netlink: remove type-unsafe validation_data pointer Johannes Berg
2020-04-29 13:48 ` [PATCH 2/7] netlink: limit recursion depth in policy validation Johannes Berg
2020-04-29 13:48 ` [PATCH 3/7] nl80211: link recursive netlink nested policy Johannes Berg
2020-04-29 13:48 ` [PATCH 4/7] netlink: extend policy range validation Johannes Berg
2020-04-29 18:10 ` Jakub Kicinski
2020-04-29 19:21 ` Johannes Berg
2020-04-29 13:48 ` Johannes Berg [this message]
2020-04-29 13:48 ` [PATCH 6/7] netlink: remove NLA_EXACT_LEN_WARN Johannes Berg
2020-04-29 13:48 ` [PATCH 7/7] netlink: factor out policy range helpers Johannes Berg
2020-04-29 13:49 ` [RFC PATCH] netlink: add infrastructure to expose policies to userspace Johannes Berg
2020-04-29 19:11 ` [PATCH 0/7] netlink validation improvements/refactoring 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:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200429154836.b9b70600438d.I46e9164d064042d49227b9af7a686b3a02080ff0@changeid \
--to=johannes@sipsolutions.net \
--cc=johannes.berg@intel.com \
--cc=linux-wireless@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=ordex@autistici.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).