lkml.org 
[lkml]   [2009]   [Feb]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: [ath5k-devel] [PATCH 1/1] ath5k: fix hw rate index condition
    On Thu, Feb 26, 2009 at 06:27:04PM -0800, Bob Copeland wrote:
    > On Fri, Feb 27, 2009 at 12:32:55AM +0100, Jiri Slaby wrote:
    > > On 27.2.2009 00:28, Bob Copeland wrote:
    > >> hw_to_driver_rix() returns sc->rate_idx[x][y] as an int, and that
    > >> array is initialized to (u8)-1 for invalid rates. So, it can
    > >> return 255 if the hardware rate index (y) is bad, then the check
    > >> "rxs.rate_idx>= 0" would always be true, right? If it's not a
    > >> real bug yet, it likely will be one day :)
    > >
    > > Ah, yes, it really is a bug(tm), care to post a fix?
    >
    > Actually, I remembered in the dark recesses of my moldering brain
    > that someone had a lost patch for this a while ago, so I searched
    > the archives. Pavel, ok to add your s-o-b?
    >
    > From: Pavel Roskin <proski@gnu.org>
    > Subject: [PATCH] ath5k: use signed elements for rate index table
    >
    > A lookup table is used to convert from hardware rate indexes back
    > to driver-based rate indexes. For unknown hardware rates, we
    > initialize these values to -1, but since the array elements are of
    > type u8, they will be in the range 0-255. This can cause array
    > overruns because subsequent sanity checks only check for negative
    > values.
    >
    > Signed-off-by: Bob Copeland <me@bobcopeland.com>
    > ---
    > drivers/net/wireless/ath5k/base.h | 2 +-
    > 1 files changed, 1 insertions(+), 1 deletions(-)
    >
    > diff --git a/drivers/net/wireless/ath5k/base.h b/drivers/net/wireless/ath5k/base.h
    > index 20e0d14..8229561 100644
    > --- a/drivers/net/wireless/ath5k/base.h
    > +++ b/drivers/net/wireless/ath5k/base.h
    > @@ -112,7 +112,7 @@ struct ath5k_softc {
    > struct ieee80211_supported_band sbands[IEEE80211_NUM_BANDS];
    > struct ieee80211_channel channels[ATH_CHAN_MAX];
    > struct ieee80211_rate rates[IEEE80211_NUM_BANDS][AR5K_MAX_RATES];
    > - u8 rate_idx[IEEE80211_NUM_BANDS][AR5K_MAX_RATES];
    > + s8 rate_idx[IEEE80211_NUM_BANDS][AR5K_MAX_RATES];

    Might be worth adding a note why this is the case. Can't we simply avoid
    this by checking earlier for the error or simply assigning it an actual
    default _good_ hw rate value?

    Luis


    \
     
     \ /
      Last update: 2009-02-27 03:43    [W:0.049 / U:61.024 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site