diff mbox

[v2] mac80211: Avoid STA expiration timer truncation to u32

Message ID 1421389121-2841-1-git-send-email-masashi.honma@gmail.com (mailing list archive)
State Superseded
Delegated to: Johannes Berg
Headers show

Commit Message

Masashi Honma Jan. 16, 2015, 6:18 a.m. UTC
On some combination of plink_timeout and HZ, the STA expiration timer will be
unexpectedly truncated to u32. Maybe there is a question "Who sets such a large
number to plink_timeout ?". At least wpa_supplicant will set 0xffffffff to
plink_timeout to disable this timer because wpa_supplicant has it's own
expiration mechanism.

Signed-off-by: Masashi Honma <masashi.honma@gmail.com>
---
 net/mac80211/mesh.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Bob Copeland Jan. 16, 2015, 1:31 p.m. UTC | #1
On Fri, Jan 16, 2015 at 03:18:41PM +0900, Masashi Honma wrote:
> On some combination of plink_timeout and HZ, the STA expiration timer will be
> unexpectedly truncated to u32. Maybe there is a question "Who sets such a large

Nice catch!

> -	ieee80211_sta_expire(sdata, ifmsh->mshcfg.plink_timeout * HZ);
> +	ieee80211_sta_expire(sdata, ifmsh->mshcfg.plink_timeout *
> +			     (unsigned long)HZ);

There's a remaining problem on 32-bit platforms: there, unsigned long
is 32 bits so 0xffffffff * HZ will still truncate to 32 bits.

For normal values of HZ though, result will still be 'a rather large
number,' so maybe it's not worth caring about that.
Masashi Honma Jan. 20, 2015, 2:44 a.m. UTC | #2
2015-01-16 22:31 GMT+09:00 Bob Copeland <me@bobcopeland.com>:
> Nice catch!
> There's a remaining problem on 32-bit platforms: there, unsigned long
> is 32 bits so 0xffffffff * HZ will still truncate to 32 bits.
>
> For normal values of HZ though, result will still be 'a rather large
> number,' so maybe it's not worth caring about that.

Thank you for your review.

I modified my patch.
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/net/mac80211/mesh.c b/net/mac80211/mesh.c
index 0c8b2a7..bb721a0 100644
--- a/net/mac80211/mesh.c
+++ b/net/mac80211/mesh.c
@@ -574,7 +574,8 @@  static void ieee80211_mesh_housekeeping(struct ieee80211_sub_if_data *sdata)
 	struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
 	u32 changed;
 
-	ieee80211_sta_expire(sdata, ifmsh->mshcfg.plink_timeout * HZ);
+	ieee80211_sta_expire(sdata, ifmsh->mshcfg.plink_timeout *
+			     (unsigned long)HZ);
 	mesh_path_expire(sdata);
 
 	changed = mesh_accept_plinks_update(sdata);