Commit 9aebce6c authored by Johannes Berg's avatar Johannes Berg

wifi: mac80211: validate link address doesn't change

When modifying a link station, validate that the link address
doesn't change, except the first time the link is created.

Fixes: b95eb7f0 ("wifi: cfg80211/mac80211: separate link params from station params")
Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
parent 6d8e0f84
...@@ -1597,7 +1597,7 @@ static void sta_apply_mesh_params(struct ieee80211_local *local, ...@@ -1597,7 +1597,7 @@ static void sta_apply_mesh_params(struct ieee80211_local *local,
} }
static int sta_link_apply_parameters(struct ieee80211_local *local, static int sta_link_apply_parameters(struct ieee80211_local *local,
struct sta_info *sta, struct sta_info *sta, bool new_link,
struct link_station_parameters *params) struct link_station_parameters *params)
{ {
int ret = 0; int ret = 0;
...@@ -1618,8 +1618,13 @@ static int sta_link_apply_parameters(struct ieee80211_local *local, ...@@ -1618,8 +1618,13 @@ static int sta_link_apply_parameters(struct ieee80211_local *local,
return -EINVAL; return -EINVAL;
if (params->link_mac) { if (params->link_mac) {
memcpy(link_sta->addr, params->link_mac, ETH_ALEN); if (new_link) {
memcpy(link_sta->pub->addr, params->link_mac, ETH_ALEN); memcpy(link_sta->addr, params->link_mac, ETH_ALEN);
memcpy(link_sta->pub->addr, params->link_mac, ETH_ALEN);
} else if (!ether_addr_equal(link_sta->addr,
params->link_mac)) {
return -EINVAL;
}
} }
if (params->txpwr_set) { if (params->txpwr_set) {
...@@ -1797,7 +1802,8 @@ static int sta_apply_parameters(struct ieee80211_local *local, ...@@ -1797,7 +1802,8 @@ static int sta_apply_parameters(struct ieee80211_local *local,
if (params->listen_interval >= 0) if (params->listen_interval >= 0)
sta->listen_interval = params->listen_interval; sta->listen_interval = params->listen_interval;
ret = sta_link_apply_parameters(local, sta, &params->link_sta_params); ret = sta_link_apply_parameters(local, sta, false,
&params->link_sta_params);
if (ret) if (ret)
return ret; return ret;
...@@ -4650,7 +4656,7 @@ static int sta_add_link_station(struct ieee80211_local *local, ...@@ -4650,7 +4656,7 @@ static int sta_add_link_station(struct ieee80211_local *local,
if (ret) if (ret)
return ret; return ret;
ret = sta_link_apply_parameters(local, sta, params); ret = sta_link_apply_parameters(local, sta, true, params);
if (ret) { if (ret) {
ieee80211_sta_free_link(sta, params->link_id); ieee80211_sta_free_link(sta, params->link_id);
return ret; return ret;
...@@ -4688,7 +4694,7 @@ static int sta_mod_link_station(struct ieee80211_local *local, ...@@ -4688,7 +4694,7 @@ static int sta_mod_link_station(struct ieee80211_local *local,
if (!(sta->sta.valid_links & BIT(params->link_id))) if (!(sta->sta.valid_links & BIT(params->link_id)))
return -EINVAL; return -EINVAL;
return sta_link_apply_parameters(local, sta, params); return sta_link_apply_parameters(local, sta, false, params);
} }
static int static int
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment