diff options
author | Luis R. Rodriguez <mcgrof@do-not-panic.com> | 2013-11-05 12:18:01 -0500 |
---|---|---|
committer | Johannes Berg <johannes.berg@intel.com> | 2013-11-25 14:51:02 -0500 |
commit | e438768ff9b22c83a968e14b79e8c83128e8bfe4 (patch) | |
tree | 956366ad035f64af8965c3a737eaa74598d1e1b6 /net | |
parent | cc493e4f5296f4da111f25ea4a216bb77270ccc6 (diff) |
cfg80211: check regulatory request alpha2 early
Currently nl80211 allows userspace to send the kernel
a bogus regulatory domain with at most 32 rules set
and it won't reject it until after its allocated
memory. Let's be smart about it and take advantage
that the last_request is now available under RTNL
and check if the alpha2 matches an expected request
and reject any bogus userspace requests prior to
hitting the memory allocator.
Signed-off-by: Luis R. Rodriguez <mcgrof@do-not-panic.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Diffstat (limited to 'net')
-rw-r--r-- | net/wireless/nl80211.c | 3 | ||||
-rw-r--r-- | net/wireless/reg.c | 2 | ||||
-rw-r--r-- | net/wireless/reg.h | 1 |
3 files changed, 5 insertions, 1 deletions
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c index 04fa8bb1b4bb..7b73132910b7 100644 --- a/net/wireless/nl80211.c +++ b/net/wireless/nl80211.c | |||
@@ -5100,6 +5100,9 @@ static int nl80211_set_reg(struct sk_buff *skb, struct genl_info *info) | |||
5100 | return -EINVAL; | 5100 | return -EINVAL; |
5101 | } | 5101 | } |
5102 | 5102 | ||
5103 | if (!reg_is_valid_request(alpha2)) | ||
5104 | return -EINVAL; | ||
5105 | |||
5103 | size_of_regd = sizeof(struct ieee80211_regdomain) + | 5106 | size_of_regd = sizeof(struct ieee80211_regdomain) + |
5104 | num_rules * sizeof(struct ieee80211_reg_rule); | 5107 | num_rules * sizeof(struct ieee80211_reg_rule); |
5105 | 5108 | ||
diff --git a/net/wireless/reg.c b/net/wireless/reg.c index b4b16871a56e..d8f047aadd49 100644 --- a/net/wireless/reg.c +++ b/net/wireless/reg.c | |||
@@ -450,7 +450,7 @@ static int call_crda(const char *alpha2) | |||
450 | return kobject_uevent(®_pdev->dev.kobj, KOBJ_CHANGE); | 450 | return kobject_uevent(®_pdev->dev.kobj, KOBJ_CHANGE); |
451 | } | 451 | } |
452 | 452 | ||
453 | static bool reg_is_valid_request(const char *alpha2) | 453 | bool reg_is_valid_request(const char *alpha2) |
454 | { | 454 | { |
455 | struct regulatory_request *lr = get_last_request(); | 455 | struct regulatory_request *lr = get_last_request(); |
456 | 456 | ||
diff --git a/net/wireless/reg.h b/net/wireless/reg.h index 9677e3c13da9..b4076babaf47 100644 --- a/net/wireless/reg.h +++ b/net/wireless/reg.h | |||
@@ -18,6 +18,7 @@ | |||
18 | 18 | ||
19 | extern const struct ieee80211_regdomain __rcu *cfg80211_regdomain; | 19 | extern const struct ieee80211_regdomain __rcu *cfg80211_regdomain; |
20 | 20 | ||
21 | bool reg_is_valid_request(const char *alpha2); | ||
21 | bool is_world_regdom(const char *alpha2); | 22 | bool is_world_regdom(const char *alpha2); |
22 | bool reg_supported_dfs_region(u8 dfs_region); | 23 | bool reg_supported_dfs_region(u8 dfs_region); |
23 | 24 | ||