From: "Luis R. Rodriguez" <lrodriguez@atheros.com>
To: <johannes@sipsolutions.net>, <johannes@sipsolutions.net>,
<linville@tuxdriver.com>
Cc: "Luis R. Rodriguez" <lrodriguez@atheros.com>,
<linux-wireless@vger.kernel.org>
Subject: [PATCH 4/6] cfg80211: add assert_cfg80211_lock() to ensure proper protection
Date: Thu, 12 Feb 2009 21:36:01 -0800 [thread overview]
Message-ID: <1234503363-11014-5-git-send-email-lrodriguez@atheros.com> (raw)
In-Reply-To: <1234503363-11014-4-git-send-email-lrodriguez@atheros.com>
Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
---
net/wireless/core.c | 5 ++++-
net/wireless/core.h | 6 ++++++
net/wireless/nl80211.c | 3 ++-
net/wireless/reg.c | 15 +++++++++++++++
4 files changed, 27 insertions(+), 2 deletions(-)
diff --git a/net/wireless/core.c b/net/wireless/core.c
index f55040a..6807538 100644
--- a/net/wireless/core.c
+++ b/net/wireless/core.c
@@ -7,7 +7,6 @@
#include <linux/if.h>
#include <linux/module.h>
#include <linux/err.h>
-#include <linux/mutex.h>
#include <linux/list.h>
#include <linux/nl80211.h>
#include <linux/debugfs.h>
@@ -47,6 +46,8 @@ cfg80211_drv_by_wiphy_idx(int wiphy_idx)
{
struct cfg80211_registered_device *result = NULL, *drv;
+ assert_cfg80211_lock();
+
list_for_each_entry(drv, &cfg80211_drv_list, list) {
if (drv->wiphy_idx == wiphy_idx) {
result = drv;
@@ -66,6 +67,8 @@ __cfg80211_drv_from_info(struct genl_info *info)
struct net_device *dev;
int err = -EINVAL;
+ assert_cfg80211_lock();
+
if (info->attrs[NL80211_ATTR_WIPHY]) {
bywiphyidx = cfg80211_drv_by_wiphy_idx(
nla_get_u32(info->attrs[NL80211_ATTR_WIPHY]));
diff --git a/net/wireless/core.h b/net/wireless/core.h
index ba0531e..2500dbc 100644
--- a/net/wireless/core.h
+++ b/net/wireless/core.h
@@ -10,6 +10,7 @@
#include <linux/netdevice.h>
#include <linux/kref.h>
#include <linux/rbtree.h>
+#include <linux/mutex.h>
#include <net/genetlink.h>
#include <net/wireless.h>
#include <net/cfg80211.h>
@@ -72,6 +73,11 @@ bool wiphy_idx_valid(int wiphy_idx)
extern struct mutex cfg80211_mutex;
extern struct list_head cfg80211_drv_list;
+static inline void assert_cfg80211_lock(void)
+{
+ BUG_ON(!mutex_is_locked(&cfg80211_mutex));
+}
+
struct cfg80211_internal_bss {
struct list_head list;
struct rb_node rbn;
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index f5c2c05..843d26d 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -7,7 +7,6 @@
#include <linux/if.h>
#include <linux/module.h>
#include <linux/err.h>
-#include <linux/mutex.h>
#include <linux/list.h>
#include <linux/if_ether.h>
#include <linux/ieee80211.h>
@@ -138,6 +137,8 @@ static int nl80211_send_wiphy(struct sk_buff *msg, u32 pid, u32 seq, int flags,
int i;
u16 ifmodes = dev->wiphy.interface_modes;
+ assert_cfg80211_lock();
+
hdr = nl80211hdr_put(msg, pid, seq, flags, NL80211_CMD_NEW_WIPHY);
if (!hdr)
return -1;
diff --git a/net/wireless/reg.c b/net/wireless/reg.c
index ba82312..aab1c69 100644
--- a/net/wireless/reg.c
+++ b/net/wireless/reg.c
@@ -830,6 +830,8 @@ static void handle_channel(struct wiphy *wiphy, enum ieee80211_band band,
struct ieee80211_supported_band *sband;
struct ieee80211_channel *chan;
+ assert_cfg80211_lock();
+
sband = wiphy->bands[band];
BUG_ON(chan_idx >= sband->n_channels);
chan = &sband->channels[chan_idx];
@@ -1042,6 +1044,10 @@ static int reg_copy_regd(const struct ieee80211_regdomain **dst_regd,
static int ignore_request(struct wiphy *wiphy, enum reg_set_by set_by,
const char *alpha2)
{
+
+ if (set_by != REGDOM_SET_BY_CORE)
+ assert_cfg80211_lock();
+
/* All initial requests are respected */
if (!last_request)
return 0;
@@ -1126,6 +1132,9 @@ int __regulatory_hint(struct wiphy *wiphy, enum reg_set_by set_by,
bool intersect = false;
int r = 0;
+ if (set_by != REGDOM_SET_BY_CORE)
+ assert_cfg80211_lock();
+
r = ignore_request(wiphy, set_by, alpha2);
if (r == REG_INTERSECT) {
@@ -1201,6 +1210,8 @@ EXPORT_SYMBOL(regulatory_hint);
static bool reg_same_country_ie_hint(struct wiphy *wiphy,
u32 country_ie_checksum)
{
+ assert_cfg80211_lock();
+
if (!last_request->wiphy)
return false;
if (likely(last_request->wiphy != wiphy))
@@ -1567,6 +1578,8 @@ int set_regdom(const struct ieee80211_regdomain *rd)
{
int r;
+ assert_cfg80211_lock();
+
/* Note that this doesn't update the wiphys, this is done below */
r = __set_regdom(rd);
if (r) {
@@ -1589,6 +1602,8 @@ int set_regdom(const struct ieee80211_regdomain *rd)
/* Caller must hold cfg80211_mutex */
void reg_device_remove(struct wiphy *wiphy)
{
+ assert_cfg80211_lock();
+
kfree(wiphy->regd);
if (!last_request || !last_request->wiphy)
return;
--
1.6.1.2.253.ga34a
next prev parent reply other threads:[~2009-02-13 5:36 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-02-13 5:35 [PATCH 0/6] cfg80211: adds a workqueue for regulatory hints Luis R. Rodriguez
2009-02-13 5:35 ` [PATCH 1/6] cfg80211: rename cfg80211_registered_device's idx to wiphy_idx Luis R. Rodriguez
2009-02-13 5:35 ` [PATCH 2/6] cfg80211: add wiphy_idx_valid to check for wiphy_idx sanity Luis R. Rodriguez
2009-02-13 5:36 ` [PATCH 3/6] cfg80211: rename cfg80211_drv_mutex to cfg80211_mutex Luis R. Rodriguez
2009-02-13 5:36 ` Luis R. Rodriguez [this message]
2009-02-13 5:36 ` [PATCH 5/6] cfg80211: make regulatory_request use wiphy_idx instead of wiphy Luis R. Rodriguez
2009-02-13 5:36 ` [PATCH 6/6] cfg80211: move regulatory hints to workqueue Luis R. Rodriguez
2009-02-13 6:56 ` Johannes Berg
2009-02-13 7:09 ` Luis R. Rodriguez
2009-02-13 7:14 ` Luis R. Rodriguez
2009-02-13 7:14 ` Luis R. Rodriguez
2009-02-13 7:17 ` Johannes Berg
2009-02-13 7:35 ` Luis R. Rodriguez
2009-02-13 7:48 ` Johannes Berg
2009-02-13 7:57 ` Luis R. Rodriguez
2009-02-13 8:08 ` Johannes Berg
2009-02-13 8:19 ` Luis R. Rodriguez
2009-02-13 11:04 ` [PATCH 5/6] cfg80211: make regulatory_request use wiphy_idx instead of wiphy Johannes Berg
2009-02-13 18:21 ` Luis R. Rodriguez
2009-02-13 21:24 ` Johannes Berg
2009-02-13 21:40 ` Luis R. Rodriguez
2009-02-13 6:54 ` [PATCH 4/6] cfg80211: add assert_cfg80211_lock() to ensure proper protection Johannes Berg
2009-02-13 7:08 ` Luis R. Rodriguez
2009-02-13 6:53 ` [PATCH 2/6] cfg80211: add wiphy_idx_valid to check for wiphy_idx sanity Johannes Berg
2009-02-13 7:08 ` Luis R. Rodriguez
2009-02-13 7:18 ` Johannes Berg
2009-02-13 9:13 ` [PATCH 0/6] cfg80211: adds a workqueue for regulatory hints Johannes Berg
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=1234503363-11014-5-git-send-email-lrodriguez@atheros.com \
--to=lrodriguez@atheros.com \
--cc=johannes@sipsolutions.net \
--cc=linux-wireless@vger.kernel.org \
--cc=linville@tuxdriver.com \
/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