mac80211: fix minstrel single-rate memory corruption
commit6e8ad8ea9d8c134f345ef3cca89c91aeadf2553e
authorBob Copeland <me@bobcopeland.com>
Fri, 5 Jun 2009 12:21:50 +0000 (5 08:21 -0400)
committerGreg Kroah-Hartman <gregkh@suse.de>
Thu, 2 Jul 2009 23:40:48 +0000 (2 16:40 -0700)
treefdd815dde924b67319d00b545d6e7fc89ff8cd86
parent40df2000dc79061fea477c4be54ef93ecc25f04a
mac80211: fix minstrel single-rate memory corruption

commit 5ee58d7e6ad019675b4090582aec4fa1180d8703 upstream.

The minstrel rate controller periodically looks up rate indexes in
a sampling table.  When accessing a specific row and column, minstrel
correctly does a bounds check which, on the surface, appears to handle
the case where mi->n_rates < 2.  However, mi->sample_idx is actually
defined as an unsigned, so the right hand side is taken to be a huge
positive number when negative, and the check will always fail.

Consequently, the RC will overrun the array and cause random memory
corruption when communicating with a peer that has only a single rate.
The max value of mi->sample_idx is around 25 so casting to int should
have no ill effects.

Without the change, uptime is a few minutes under load with an AP
that has a single hard-coded rate, and both the AP and STA could
potentially crash.  With the change, both lasted 12 hours with a
steady load.

Thanks to Ognjen Maric for providing the single-rate clue so I could
reproduce this.

This fixes http://bugzilla.kernel.org/show_bug.cgi?id=12490 on the
regression list (also http://bugzilla.kernel.org/show_bug.cgi?id=13000).

Reported-by: Sergey S. Kostyliov <rathamahata@gmail.com>
Reported-by: Ognjen Maric <ognjen.maric@gmail.com>
Signed-off-by: Bob Copeland <me@bobcopeland.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
net/mac80211/rc80211_minstrel.c