Linux wireless drivers development
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: masashi.honma@gmail.com
Cc: linux-wireless@vger.kernel.org
Subject: [bug report] nl80211: Fix possible Spectre-v1 for CQM RSSI thresholds
Date: Sat, 7 Sep 2019 16:02:34 +0300	[thread overview]
Message-ID: <20190907130234.GA32057@mwanda> (raw)

Hello Masashi Honma,

The patch 1222a1601488: "nl80211: Fix possible Spectre-v1 for CQM
RSSI thresholds" from Sep 25, 2018, leads to the following static
checker warning:

	net/wireless/nl80211.c:10820 cfg80211_cqm_rssi_update()
	warn: disabling speculation after use: 'i'

net/wireless/nl80211.c
 10804          last = wdev->cqm_config->last_rssi_event_value;
 10805          hyst = wdev->cqm_config->rssi_hyst;
 10806          n = wdev->cqm_config->n_rssi_thresholds;
 10807  
 10808          for (i = 0; i < n; i++)
 10809                  if (last < wdev->cqm_config->rssi_thresholds[i])
                                                     ^^^^^^^^^^^^^^^^^^
We've already used "i" as an index.

 10810                          break;
 10811  
 10812          low_index = i - 1;
 10813          if (low_index >= 0) {
 10814                  low_index = array_index_nospec(low_index, n);
                                    ^^^^^^^^^^^^^^^^^^

 10815                  low = wdev->cqm_config->rssi_thresholds[low_index] - hyst;
 10816          } else {
 10817                  low = S32_MIN;
 10818          }
 10819          if (i < n) {
 10820                  i = array_index_nospec(i, n);
                            ^^^^^^^^^^^^^^^^^^
So this seems like closing the barn door after the horses have left.

 10821                  high = wdev->cqm_config->rssi_thresholds[i] + hyst - 1;
 10822          } else {
 10823                  high = S32_MAX;
 10824          }

regards,
dan carpenter

             reply	other threads:[~2019-09-07 13:04 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-07 13:02 Dan Carpenter [this message]
2019-09-08  0:55 ` [bug report] nl80211: Fix possible Spectre-v1 for CQM RSSI thresholds Masashi Honma

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190907130234.GA32057@mwanda \
    --to=dan.carpenter@oracle.com \
    --cc=linux-wireless@vger.kernel.org \
    --cc=masashi.honma@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox