From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9EE74C49ED7 for ; Thu, 19 Sep 2019 22:32:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6AB30208C0 for ; Thu, 19 Sep 2019 22:32:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1568932379; bh=akX1siLFCk+copmFe3BgnSzscjzDRnUliKegBLJAXSc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=ZLkEqi8ujxO80HX212Si/blHQMetrZT/9G/Vl9l3OqlJSrfKpBCmyobgto1B20dap odnqK1Vnlzri3zlV0qaVfV2+rKAePbbUcaly85b1Z5+s5sxmhvR6w/FhbvItzJjVO8 J0jxmEJO1sp+Mg7g/CRtXLHblCFSaMST/l1dfpdc= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2406846AbfISWc6 (ORCPT ); Thu, 19 Sep 2019 18:32:58 -0400 Received: from mail.kernel.org ([198.145.29.99]:51212 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2405965AbfISWMV (ORCPT ); Thu, 19 Sep 2019 18:12:21 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 38AD721920; Thu, 19 Sep 2019 22:12:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1568931140; bh=akX1siLFCk+copmFe3BgnSzscjzDRnUliKegBLJAXSc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gdgd8PeVzGqbTywy6J9knW2fjGnibZX3SeVAPygoFuVMUPq9sLWiJEdGABu2WHR6a IENkgyj81kadQ8W/WYCQP8/Z/5Jt/CmF24kbtgjLEs8fXa2z6IRlCr1dj7iaODW9SC 6ke+a3TQSZ3PWgbn1ZX0PVwZNJUKPamygMPyU/Qs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dan Carpenter , Masashi Honma , Johannes Berg Subject: [PATCH 4.19 18/79] nl80211: Fix possible Spectre-v1 for CQM RSSI thresholds Date: Fri, 20 Sep 2019 00:03:03 +0200 Message-Id: <20190919214809.383428098@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190919214807.612593061@linuxfoundation.org> References: <20190919214807.612593061@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Masashi Honma commit 4b2c5a14cd8005a900075f7dfec87473c6ee66fb upstream. commit 1222a1601488 ("nl80211: Fix possible Spectre-v1 for CQM RSSI thresholds") was incomplete and requires one more fix to prevent accessing to rssi_thresholds[n] because user can control rssi_thresholds[i] values to make i reach to n. For example, rssi_thresholds = {-400, -300, -200, -100} when last is -34. Cc: stable@vger.kernel.org Fixes: 1222a1601488 ("nl80211: Fix possible Spectre-v1 for CQM RSSI thresholds") Reported-by: Dan Carpenter Signed-off-by: Masashi Honma Link: https://lore.kernel.org/r/20190908005653.17433-1-masashi.honma@gmail.com Signed-off-by: Johannes Berg Signed-off-by: Greg Kroah-Hartman --- net/wireless/nl80211.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) --- a/net/wireless/nl80211.c +++ b/net/wireless/nl80211.c @@ -10270,9 +10270,11 @@ static int cfg80211_cqm_rssi_update(stru hyst = wdev->cqm_config->rssi_hyst; n = wdev->cqm_config->n_rssi_thresholds; - for (i = 0; i < n; i++) + for (i = 0; i < n; i++) { + i = array_index_nospec(i, n); if (last < wdev->cqm_config->rssi_thresholds[i]) break; + } low_index = i - 1; if (low_index >= 0) {