mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-04-13 09:59:31 +00:00
wifi: mac80211: fix integer overflow in hwmp_route_info_get()
Since the new_metric and last_hop_metric variables can reach
the MAX_METRIC(0xffffffff) value, an integer overflow may occur
when multiplying them by 10/9. It can lead to incorrect behavior.
Found by InfoTeCS on behalf of Linux Verification Center
(linuxtesting.org) with SVACE.
Fixes: a8d418d9ac
("mac80211: mesh: only switch path when new metric is at least 10% better")
Cc: stable@vger.kernel.org
Signed-off-by: Ilia Gavrilov <Ilia.Gavrilov@infotecs.ru>
Link: https://patch.msgid.link/20250212082124.4078236-1-Ilia.Gavrilov@infotecs.ru
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
This commit is contained in:
parent
ebf9944bed
commit
d00c0c4105
1 changed files with 10 additions and 4 deletions
|
@ -367,6 +367,12 @@ u32 airtime_link_metric_get(struct ieee80211_local *local,
|
||||||
return (u32)result;
|
return (u32)result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Check that the first metric is at least 10% better than the second one */
|
||||||
|
static bool is_metric_better(u32 x, u32 y)
|
||||||
|
{
|
||||||
|
return (x < y) && (x < (y - x / 10));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* hwmp_route_info_get - Update routing info to originator and transmitter
|
* hwmp_route_info_get - Update routing info to originator and transmitter
|
||||||
*
|
*
|
||||||
|
@ -458,8 +464,8 @@ static u32 hwmp_route_info_get(struct ieee80211_sub_if_data *sdata,
|
||||||
(mpath->sn == orig_sn &&
|
(mpath->sn == orig_sn &&
|
||||||
(rcu_access_pointer(mpath->next_hop) !=
|
(rcu_access_pointer(mpath->next_hop) !=
|
||||||
sta ?
|
sta ?
|
||||||
mult_frac(new_metric, 10, 9) :
|
!is_metric_better(new_metric, mpath->metric) :
|
||||||
new_metric) >= mpath->metric)) {
|
new_metric >= mpath->metric))) {
|
||||||
process = false;
|
process = false;
|
||||||
fresh_info = false;
|
fresh_info = false;
|
||||||
}
|
}
|
||||||
|
@ -533,8 +539,8 @@ static u32 hwmp_route_info_get(struct ieee80211_sub_if_data *sdata,
|
||||||
if ((mpath->flags & MESH_PATH_FIXED) ||
|
if ((mpath->flags & MESH_PATH_FIXED) ||
|
||||||
((mpath->flags & MESH_PATH_ACTIVE) &&
|
((mpath->flags & MESH_PATH_ACTIVE) &&
|
||||||
((rcu_access_pointer(mpath->next_hop) != sta ?
|
((rcu_access_pointer(mpath->next_hop) != sta ?
|
||||||
mult_frac(last_hop_metric, 10, 9) :
|
!is_metric_better(last_hop_metric, mpath->metric) :
|
||||||
last_hop_metric) > mpath->metric)))
|
last_hop_metric > mpath->metric))))
|
||||||
fresh_info = false;
|
fresh_info = false;
|
||||||
} else {
|
} else {
|
||||||
mpath = mesh_path_add(sdata, ta);
|
mpath = mesh_path_add(sdata, ta);
|
||||||
|
|
Loading…
Add table
Reference in a new issue