Received: by 10.223.185.116 with SMTP id b49csp1118985wrg; Fri, 23 Feb 2018 12:15:13 -0800 (PST) X-Google-Smtp-Source: AH8x225wf7ByeQgJ7lTqf4DC+jlG6j+3cTG1jCEgkjlJa9vym9Klz84dM47iStfl9wf7TUJO5yAp X-Received: by 2002:a17:902:b2c6:: with SMTP id x6-v6mr2734737plw.285.1519416913590; Fri, 23 Feb 2018 12:15:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519416913; cv=none; d=google.com; s=arc-20160816; b=FxgKHc837+esG2XXqxfNzvci6jmIZqb/VkoPSWHkVNXyZi8+YbeJ6EvhCD/9zpukvP t73eYHTeGlSirvT+sy54OkkdZChXUkryR72/4xDD/tZVMqLkpZT1Vtl8CLilsHsEwuje vECKGEyHQ82jHL2LnMJaRvMDwWssZxf8SigduYoaIeXwSKJ9weLtQnK1aBan7Yy0nJfe MICSVqgcnvRwBqzxeCTlI2itGGaeOulD/8rVaWD01ksg0PMcO/xuyAoIZwP7+HTgqVCT ZhrMR6TmHAuUu3kxilOrVLAJj1T0snJ04KTw9ZZevIkTQX14QMDX+KRQOZdUsZIP/xDq t4Jw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=R9dKKsVygUpm0t1EGJOqgLjVlbyOq1bfVrFfv5I0h28=; b=o2QSqUEAxHNv3p8TGZpUXcnARzX3c/dMZ7ypmggwoX6nARqgiyiDdilC7gffhFCW2L FLkz3PBOCgw7zKBZ2AI0D3YCXbDVoJxWAnJV1Z5A4DK8cfsnLS+RFioE1CcpVe06LBre SgJSptpHfEvski0wXuswcjQWUOBBbil/KE/EI4DbUXmjQB/JA4Vx+EoCuDFMPiz/Lu6x OCd7it4FMHYRRFmGflPXcbgryobolCENoZsMa20urn1SFWVALBGbDmEpZ15GAOBpE7Yt Mf2BKbGTl5OwBHouiSJNM2z8X6Pf66450m1AqGRccwKIAHAEcFGb38qHjQnlpRs60gGa DsaA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e13si1907449pgu.821.2018.02.23.12.14.58; Fri, 23 Feb 2018 12:15:13 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755169AbeBWUNv (ORCPT + 99 others); Fri, 23 Feb 2018 15:13:51 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:40474 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754121AbeBWSlN (ORCPT ); Fri, 23 Feb 2018 13:41:13 -0500 Received: from localhost (LFbn-1-12258-90.w90-92.abo.wanadoo.fr [90.92.71.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id A025D11E9; Fri, 23 Feb 2018 18:41:12 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Christian Lamparter , Elena Reshetova , Dan Williams , Thomas Gleixner , Johannes Berg , linux-arch@vger.kernel.org, kernel-hardening@lists.openwall.com, linux-wireless@vger.kernel.org, torvalds@linux-foundation.org, "David S. Miller" , alan@linux.intel.com, David Woodhouse , Jack Wang Subject: [PATCH 4.4 180/193] nl80211: Sanitize array index in parse_txq_params Date: Fri, 23 Feb 2018 19:26:53 +0100 Message-Id: <20180223170354.369164387@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180223170325.997716448@linuxfoundation.org> References: <20180223170325.997716448@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Dan Williams (cherry picked from commit 259d8c1e984318497c84eef547bbb6b1d9f4eb05) Wireless drivers rely on parse_txq_params to validate that txq_params->ac is less than NL80211_NUM_ACS by the time the low-level driver's ->conf_tx() handler is called. Use a new helper, array_index_nospec(), to sanitize txq_params->ac with respect to speculation. I.e. ensure that any speculation into ->conf_tx() handlers is done with a value of txq_params->ac that is within the bounds of [0, NL80211_NUM_ACS). Reported-by: Christian Lamparter Reported-by: Elena Reshetova Signed-off-by: Dan Williams Signed-off-by: Thomas Gleixner Acked-by: Johannes Berg Cc: linux-arch@vger.kernel.org Cc: kernel-hardening@lists.openwall.com Cc: gregkh@linuxfoundation.org Cc: linux-wireless@vger.kernel.org Cc: torvalds@linux-foundation.org Cc: "David S. Miller" Cc: alan@linux.intel.com Link: https://lkml.kernel.org/r/151727419584.33451.7700736761686184303.stgit@dwillia2-desk3.amr.corp.intel.com Signed-off-by: David Woodhouse [jwang: cherry pick to 4.4] Signed-off-by: Jack Wang Signed-off-by: Greg Kroah-Hartman --- net/wireless/nl80211.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) --- a/net/wireless/nl80211.c +++ b/net/wireless/nl80211.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -1879,20 +1880,22 @@ static const struct nla_policy txq_param static int parse_txq_params(struct nlattr *tb[], struct ieee80211_txq_params *txq_params) { + u8 ac; + if (!tb[NL80211_TXQ_ATTR_AC] || !tb[NL80211_TXQ_ATTR_TXOP] || !tb[NL80211_TXQ_ATTR_CWMIN] || !tb[NL80211_TXQ_ATTR_CWMAX] || !tb[NL80211_TXQ_ATTR_AIFS]) return -EINVAL; - txq_params->ac = nla_get_u8(tb[NL80211_TXQ_ATTR_AC]); + ac = nla_get_u8(tb[NL80211_TXQ_ATTR_AC]); txq_params->txop = nla_get_u16(tb[NL80211_TXQ_ATTR_TXOP]); txq_params->cwmin = nla_get_u16(tb[NL80211_TXQ_ATTR_CWMIN]); txq_params->cwmax = nla_get_u16(tb[NL80211_TXQ_ATTR_CWMAX]); txq_params->aifs = nla_get_u8(tb[NL80211_TXQ_ATTR_AIFS]); - if (txq_params->ac >= NL80211_NUM_ACS) + if (ac >= NL80211_NUM_ACS) return -EINVAL; - + txq_params->ac = array_index_nospec(ac, NL80211_NUM_ACS); return 0; }