* [PATCH] wifi: mac80211: fix interger overflow in hwmp_route_info_get()
@ 2024-12-26 7:47 Gavrilov Ilia
2025-01-13 15:05 ` Johannes Berg
0 siblings, 1 reply; 2+ messages in thread
From: Gavrilov Ilia @ 2024-12-26 7:47 UTC (permalink / raw)
To: Johannes Berg
Cc: Julan Hsu, linux-wireless, linux-kernel, lvc-project, stable
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: a8d418d9ac25 ("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>
---
net/mac80211/mesh_hwmp.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/net/mac80211/mesh_hwmp.c b/net/mac80211/mesh_hwmp.c
index 4e9546e998b6..7d367ff1efc2 100644
--- a/net/mac80211/mesh_hwmp.c
+++ b/net/mac80211/mesh_hwmp.c
@@ -458,7 +458,7 @@ static u32 hwmp_route_info_get(struct ieee80211_sub_if_data *sdata,
(mpath->sn == orig_sn &&
(rcu_access_pointer(mpath->next_hop) !=
sta ?
- mult_frac(new_metric, 10, 9) :
+ mult_frac((u64)new_metric, 10, 9) :
new_metric) >= mpath->metric)) {
process = false;
fresh_info = false;
@@ -533,7 +533,7 @@ static u32 hwmp_route_info_get(struct ieee80211_sub_if_data *sdata,
if ((mpath->flags & MESH_PATH_FIXED) ||
((mpath->flags & MESH_PATH_ACTIVE) &&
((rcu_access_pointer(mpath->next_hop) != sta ?
- mult_frac(last_hop_metric, 10, 9) :
+ mult_frac((u64)last_hop_metric, 10, 9) :
last_hop_metric) > mpath->metric)))
fresh_info = false;
} else {
--
2.39.5
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] wifi: mac80211: fix interger overflow in hwmp_route_info_get()
2024-12-26 7:47 [PATCH] wifi: mac80211: fix interger overflow in hwmp_route_info_get() Gavrilov Ilia
@ 2025-01-13 15:05 ` Johannes Berg
0 siblings, 0 replies; 2+ messages in thread
From: Johannes Berg @ 2025-01-13 15:05 UTC (permalink / raw)
To: Gavrilov Ilia
Cc: Julan Hsu, linux-wireless, linux-kernel, lvc-project, stable
On Thu, 2024-12-26 at 07:47 +0000, Gavrilov Ilia wrote:
> 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.
>
> - mult_frac(new_metric, 10, 9) :
> + mult_frac((u64)new_metric, 10, 9) :
>
As you would expect, this doesn't build on 32-bit.
johannnes
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-01-13 15:05 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-12-26 7:47 [PATCH] wifi: mac80211: fix interger overflow in hwmp_route_info_get() Gavrilov Ilia
2025-01-13 15:05 ` Johannes Berg
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®