lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20201016015034.GA2122229@ubuntu-m3-large-x86>
Date:   Thu, 15 Oct 2020 18:50:34 -0700
From:   Nathan Chancellor <natechancellor@...il.com>
To:     Jerome Pouiller <Jerome.Pouiller@...abs.com>
Cc:     devel@...verdev.osuosl.org, linux-wireless@...r.kernel.org,
        netdev@...r.kernel.org, linux-kernel@...r.kernel.org,
        Kalle Valo <kvalo@...eaurora.org>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        "David S . Miller" <davem@...emloft.net>,
        Dan Carpenter <dan.carpenter@...cle.com>
Subject: Re: [PATCH 8/8] staging: wfx: improve robustness of wfx_get_hw_rate()

On Fri, Oct 09, 2020 at 07:13:07PM +0200, Jerome Pouiller wrote:
> From: Jérôme Pouiller <jerome.pouiller@...abs.com>
> 
> Smatch complains:
> 
>     data_tx.c:37 wfx_get_hw_rate() warn: constraint '(struct ieee80211_supported_band)->bitrates' overflow 'band->bitrates' 0 <= abs_rl '0-127' user_rl '' required = '(struct ieee80211_supported_band)->n_bitrates'
>     23          struct ieee80211_supported_band *band;
>     24
>     25          if (rate->idx < 0)
>     26                  return -1;
>     27          if (rate->flags & IEEE80211_TX_RC_MCS) {
>     28                  if (rate->idx > 7) {
>     29                          WARN(1, "wrong rate->idx value: %d", rate->idx);
>     30                          return -1;
>     31                  }
>     32                  return rate->idx + 14;
>     33          }
>     34          // WFx only support 2GHz, else band information should be retrieved
>     35          // from ieee80211_tx_info
>     36          band = wdev->hw->wiphy->bands[NL80211_BAND_2GHZ];
>     37          return band->bitrates[rate->idx].hw_value;
> 
> Add a simple check to make Smatch happy.
> 
> Reported-by: Dan Carpenter <dan.carpenter@...cle.com>
> Signed-off-by: Jérôme Pouiller <jerome.pouiller@...abs.com>
> ---
>  drivers/staging/wfx/data_tx.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/drivers/staging/wfx/data_tx.c b/drivers/staging/wfx/data_tx.c
> index 8db0be08daf8..41f6a604a697 100644
> --- a/drivers/staging/wfx/data_tx.c
> +++ b/drivers/staging/wfx/data_tx.c
> @@ -31,6 +31,10 @@ static int wfx_get_hw_rate(struct wfx_dev *wdev,
>  		}
>  		return rate->idx + 14;
>  	}
> +	if (rate->idx >= band->n_bitrates) {
> +		WARN(1, "wrong rate->idx value: %d", rate->idx);
> +		return -1;
> +	}
>  	// WFx only support 2GHz, else band information should be retrieved
>  	// from ieee80211_tx_info
>  	band = wdev->hw->wiphy->bands[NL80211_BAND_2GHZ];
> -- 
> 2.28.0
> 

This now causes a clang warning:

drivers/staging/wfx/data_tx.c:34:19: warning: variable 'band' is uninitialized when used here [-Wuninitialized]
        if (rate->idx >= band->n_bitrates) {
                         ^~~~
drivers/staging/wfx/data_tx.c:23:39: note: initialize the variable 'band' to silence this warning
        struct ieee80211_supported_band *band;
                                             ^
                                              = NULL
1 warning generated.

Cheers,
Nathan

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ