Received: by 10.223.176.5 with SMTP id f5csp2848633wra; Mon, 5 Feb 2018 10:54:32 -0800 (PST) X-Google-Smtp-Source: AH8x226np/OwFSSEz0G4wYkEBNkaC0kw8gCp5PZADcHyhJmRhtROsSlRwoa7l+pZeNUp6cek12ki X-Received: by 2002:a17:902:d904:: with SMTP id c4-v6mr24239260plz.125.1517856872749; Mon, 05 Feb 2018 10:54:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517856872; cv=none; d=google.com; s=arc-20160816; b=I5rvS5J59VQs4G+HbL8IOsrqcDCvBF1sXjXgy2JanpyDEZF1Cvnmgorw4Dr3LANu05 oy5s6Nkuk7qhEmy8cMlZXDRbUDX1mb8Le97EWV+zowP2T+n5T/qpfxGFlUdbFx92NhpC 82wtHvNClYZ+G4l1aUXW8r8PNrzdJPRnQBX79QfB/yfhLDl7CU3s0YDVKtq3YqAG5ijj FSlS9o6JS8d853yj8aEcc9mg6Db2Q93rT7j6iCE4LHL7RHEZvTXKmjEAs5H5zDIW5ct8 CrSbQ58F8A40ThJpn6avXAN331TUvPT1sF9YR2nzuNGR7FzBZT5UuB1VB3zP+u1yimW+ glgQ== 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=9MBcfaPHsaTzzBWYwjwIcCnRTmWcs8vZzfj92Msdl4c=; b=K58IxcEE7ajFM5/vE24k9CPIm7eJWNtnb/tys+8Ytj7fjgbcIMxyXVUXJ6QY0coCRB m/Hx1aSB0qI5Ul5ISmyfb0mib3VIheH7ol3kuubh24EHoUmc87l4rahg3JnSsjgnfSL1 +hH+cxjo7fdGcxAiSENYC4e1JJfu0AN7or47sWhRf3BNQvJUwDMOgIi3yATqnGOENim7 cYQPou6SCOqhBOofie/1ydMXffUEBz/r7HYUiqlZytFcCxpc78ovzweb4oDkYhwWAWOW wE22X00Vdt/+BtlFJSYfGjIfHQJ2Jim2hRbGZmoCtxeJ5iTIG4sa+Q9vJwKq4yI1ETzz /cFA== 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 b75si6199483pfk.409.2018.02.05.10.54.18; Mon, 05 Feb 2018 10:54:32 -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 S1753290AbeBESx2 (ORCPT + 99 others); Mon, 5 Feb 2018 13:53:28 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:52878 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753797AbeBESZo (ORCPT ); Mon, 5 Feb 2018 13:25:44 -0500 Received: from localhost (unknown [104.132.1.108]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 818A81126; Mon, 5 Feb 2018 18:25:28 +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 Subject: [PATCH 4.15 42/60] nl80211: Sanitize array index in parse_txq_params Date: Mon, 5 Feb 2018 10:23:15 -0800 Message-Id: <20180205182215.701214369@linuxfoundation.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180205182213.902626065@linuxfoundation.org> References: <20180205182213.902626065@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.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Dan Williams dan.j.williams@intel.com 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: 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 @@ -2056,20 +2057,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; }