Received: by 10.223.176.5 with SMTP id f5csp713241wra; Fri, 9 Feb 2018 06:06:19 -0800 (PST) X-Google-Smtp-Source: AH8x226oJ+YlGIfTLLvzKsEf+GkK349RJ2ryaXpGPh6PpT3gqvGFr8TB4ubkGbxExSQkoNnoIGdc X-Received: by 10.101.72.129 with SMTP id n1mr2427362pgs.181.1518185179262; Fri, 09 Feb 2018 06:06:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518185179; cv=none; d=google.com; s=arc-20160816; b=W0nYDGMdl8L6EAJwTpR4VUmf8uX/lSWmTSQebnsfsUS7CNduBQOpZfeudBo9WiqhKC XwZiT0qO0LHHk9a/aETNhPAUwt+NeTuT4S3DyW/j+j2GrxnGpcyL5ve45n3xTW6F27jU Wt2tcXr0PepFaVKvfMg/zpyQPe6GkFm4Uxdx9MlnXEh45z6CC7KCTHvSvMiyYpeW8zoC WLX1cSY+jvwD86tTLsYuLz+xbKreXa7LJdOUfeSrKEEtKletpKqnP1qU2W9u51YONWiy eHnsXJwBtFGlYjx75tDcItdbKWh/pQGWF5qcILO1aLwVl5XCXC+omT/OlVjWL31t2aro SAEw== 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=Gde4GuCXVdMJqBWVopiXHL7W3Pvwh5LglPW7FmiSGmY=; b=DzLHfz3JRXQSEsEWkh1yvl5IfdgSj+qo+6kQQwiIESoWOA/UXsTdhG+RxezVq00RFd GgpkJzOKrpnOFtgCileCO6+1Y7CWV1HCBwyEyYBs6+fpoF9SRh8CvvkorMQuYmvbT1bF lbOVnS1d9cfMc2N1WARQtPmmak9D9aFLFr/X6PLqS2Kf52OLhVUQ0SPmfl+LGMHsGXX3 PT9JqfDmNTQ5OAu26n8MkQfez20hQtpIJDqB2lma6ltKCiPoUjUTnzmL+zJJMzbCzJGX Dhe5b1fPFEbJ+e8dd55mEVloGiuzMO7hdqXVdk3F/oMhjh5lhnbUew/2qDDW7x2lMiOW rWQg== 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 9-v6si1552827ple.367.2018.02.09.06.06.04; Fri, 09 Feb 2018 06:06:19 -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 S1753269AbeBINnh (ORCPT + 99 others); Fri, 9 Feb 2018 08:43:37 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:50864 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753234AbeBINnf (ORCPT ); Fri, 9 Feb 2018 08:43:35 -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 271931058; Fri, 9 Feb 2018 13:43:18 +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 Subject: [PATCH 4.9 66/92] nl80211: Sanitize array index in parse_txq_params Date: Fri, 9 Feb 2018 14:39:35 +0100 Message-Id: <20180209133936.035590734@linuxfoundation.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180209133931.211869118@linuxfoundation.org> References: <20180209133931.211869118@linuxfoundation.org> User-Agent: quilt/0.65 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.9-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 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 @@ -2014,20 +2015,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; }