Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 85ca8fc7 authored by Johannes Berg's avatar Johannes Berg
Browse files

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: default avatarJohannes Berg <johannes.berg@intel.com>
parent de0421d5
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -2112,6 +2112,9 @@ static int hwsim_tx_info_frame_received_nl(struct sk_buff *skb_2,
	int i;
	bool found = false;

	if (info->snd_portid != wmediumd_portid)
		return -EINVAL;

	if (!info->attrs[HWSIM_ATTR_ADDR_TRANSMITTER] ||
	    !info->attrs[HWSIM_ATTR_FLAGS] ||
	    !info->attrs[HWSIM_ATTR_COOKIE] ||
@@ -2185,6 +2188,9 @@ static int hwsim_cloned_frame_received_nl(struct sk_buff *skb_2,
	void *frame_data;
	struct sk_buff *skb = NULL;

	if (info->snd_portid != wmediumd_portid)
		return -EINVAL;

	if (!info->attrs[HWSIM_ATTR_ADDR_RECEIVER] ||
	    !info->attrs[HWSIM_ATTR_FRAME] ||
	    !info->attrs[HWSIM_ATTR_RX_RATE] ||
@@ -2237,6 +2243,9 @@ out:
static int hwsim_register_received_nl(struct sk_buff *skb_2,
				      struct genl_info *info)
{
	if (wmediumd_portid)
		return -EBUSY;

	wmediumd_portid = info->snd_portid;

	printk(KERN_DEBUG "mac80211_hwsim: received a REGISTER, "