aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohannes Berg <johannes.berg@intel.com>2014-01-07 17:21:34 -0500
committerJohannes Berg <johannes.berg@intel.com>2014-01-10 14:12:58 -0500
commit85ca8fc74671def6041fb12c0a7d3423da56ffd3 (patch)
tree933e2c462951f7ad364be6edef2ad96f6bffd207
parentde0421d53bfb5f7783e5228f8cf49f2ae7140d54 (diff)
mac80211_hwsim: verify wmediumd socket
There can't be two wmediumd instances controlling hwsim, so reject registration from a second one and verify in the commands that it's the correct instance calling. Signed-off-by: Johannes Berg <johannes.berg@intel.com>
-rw-r--r--drivers/net/wireless/mac80211_hwsim.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c
index 1c51c33c385f..4ee88a9b095d 100644
--- a/drivers/net/wireless/mac80211_hwsim.c
+++ b/drivers/net/wireless/mac80211_hwsim.c
@@ -2112,6 +2112,9 @@ static int hwsim_tx_info_frame_received_nl(struct sk_buff *skb_2,
2112 int i; 2112 int i;
2113 bool found = false; 2113 bool found = false;
2114 2114
2115 if (info->snd_portid != wmediumd_portid)
2116 return -EINVAL;
2117
2115 if (!info->attrs[HWSIM_ATTR_ADDR_TRANSMITTER] || 2118 if (!info->attrs[HWSIM_ATTR_ADDR_TRANSMITTER] ||
2116 !info->attrs[HWSIM_ATTR_FLAGS] || 2119 !info->attrs[HWSIM_ATTR_FLAGS] ||
2117 !info->attrs[HWSIM_ATTR_COOKIE] || 2120 !info->attrs[HWSIM_ATTR_COOKIE] ||
@@ -2185,6 +2188,9 @@ static int hwsim_cloned_frame_received_nl(struct sk_buff *skb_2,
2185 void *frame_data; 2188 void *frame_data;
2186 struct sk_buff *skb = NULL; 2189 struct sk_buff *skb = NULL;
2187 2190
2191 if (info->snd_portid != wmediumd_portid)
2192 return -EINVAL;
2193
2188 if (!info->attrs[HWSIM_ATTR_ADDR_RECEIVER] || 2194 if (!info->attrs[HWSIM_ATTR_ADDR_RECEIVER] ||
2189 !info->attrs[HWSIM_ATTR_FRAME] || 2195 !info->attrs[HWSIM_ATTR_FRAME] ||
2190 !info->attrs[HWSIM_ATTR_RX_RATE] || 2196 !info->attrs[HWSIM_ATTR_RX_RATE] ||
@@ -2237,6 +2243,9 @@ out:
2237static int hwsim_register_received_nl(struct sk_buff *skb_2, 2243static int hwsim_register_received_nl(struct sk_buff *skb_2,
2238 struct genl_info *info) 2244 struct genl_info *info)
2239{ 2245{
2246 if (wmediumd_portid)
2247 return -EBUSY;
2248
2240 wmediumd_portid = info->snd_portid; 2249 wmediumd_portid = info->snd_portid;
2241 2250
2242 printk(KERN_DEBUG "mac80211_hwsim: received a REGISTER, " 2251 printk(KERN_DEBUG "mac80211_hwsim: received a REGISTER, "