From patchwork Fri Feb 23 10:42:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinpu Wang X-Patchwork-Id: 10237449 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 5421D602DC for ; Fri, 23 Feb 2018 11:25:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4B11C2952F for ; Fri, 23 Feb 2018 11:25:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3F86D29538; Fri, 23 Feb 2018 11:25:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from mother.openwall.net (mother.openwall.net [195.42.179.200]) by mail.wl.linuxfoundation.org (Postfix) with SMTP id 04DCD29537 for ; Fri, 23 Feb 2018 11:25:51 +0000 (UTC) Received: (qmail 19574 invoked by uid 550); 23 Feb 2018 11:23:09 -0000 Mailing-List: contact kernel-hardening-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Delivered-To: mailing list kernel-hardening@lists.openwall.com Delivered-To: moderator for kernel-hardening@lists.openwall.com Received: (qmail 5452 invoked from network); 23 Feb 2018 10:42:51 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=profitbricks-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=UHTeR9dmR2yqsOvVMNy3Nstlsd4F0cnGIJcb/C6+z1s=; b=pV1zWtLfjDQszzOVeUifs9gu/ra8gAO1h1QPJHOUa1wnykqoxxY3BZoDQ4o1jH7tAm zfuezcJZ9WV7WLRl4qYJj+1BFpIqnh493OPkDPsMWSV0Rr2GNe/+cjH+QaHlbmo4xnWD UTSBz6EPgEh0zAYy7ZaxIlcz7xaZNKsHfyhKWGHHmS6n5dmX7gAjXUm5+c6zA84Yr82N 6de7XL5TJ2DP6IdOuV9RE8+qRlJZVFDP8QxZvy6tw93+rTJsd2YJR8f2dtCIxEzrV6Bb mTGyICUd5A0zBEM24PeluaPVzQfjbM2BmhT8ofjPKmEvB+TVChB5Aaual2yeAcpHA977 ovTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=UHTeR9dmR2yqsOvVMNy3Nstlsd4F0cnGIJcb/C6+z1s=; b=URqzu70UzIrNBFmhK04bwOY5gOUZr1GJbSuJUOKWQo9nQWksgRs8cFNtpA9FeoX4mS A0hoA6n8DsUfbZaglr2QWU4JiveFnY546ffxn+l6Vv0HyIwrdiBoEkXLVBtOsWPewXND mAvTP0Aq9yn+lUCjmQC8fhrp7RBPABoeFj4DNwnssIomS0+a9qqKaWRzFZ5HKL3VWIpK YBpqwgCH+/myx+FiiZMRfs6hTfbgsQ/ZCsqhrKXyEdXhKBT2PROg6eStXQQgbuLObHf6 r6FAnS0FDV6BZ2SwU7q09B/uJzN3nUkYtlkgbvGL/6qCQTPs2wVY86K0SeY893PFdzRH o5IQ== X-Gm-Message-State: APf1xPBESUZYbYN3ixGa1/cUArJzVFjiKalF2KfyZ8hIAnEhjNR+Udgy SEnXVBjj3GJl9Sx3IKy1qZ0Skw== X-Google-Smtp-Source: AH8x225lPKEW54krM+QcjAwh4o1P5Mctc3p5WSP6U0KuYp3PNxr9+JAp7Fm6q7CHZcD6IQSwAgGAaQ== X-Received: by 10.223.190.15 with SMTP id n15mr1276468wrh.82.1519382560613; Fri, 23 Feb 2018 02:42:40 -0800 (PST) From: Jack Wang X-Google-Original-From: Jack Wang To: gregkh@linuxfoundation.org, stable@vger.kernel.org Cc: Dan Williams , Thomas Gleixner , 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: [stable 4.4 17/29] nl80211: Sanitize array index in parse_txq_params Date: Fri, 23 Feb 2018 11:42:06 +0100 Message-Id: <1519382538-15143-18-git-send-email-jinpu.wangl@profitbricks.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1519382538-15143-1-git-send-email-jinpu.wangl@profitbricks.com> References: <1519382538-15143-1-git-send-email-jinpu.wangl@profitbricks.com> X-Virus-Scanned: ClamAV using ClamSMTP 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 [jwang: cherry pick to 4.4] Signed-off-by: Jack Wang --- net/wireless/nl80211.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c index 7950506..b0b58d1 100644 --- 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_params_policy[NL80211_TXQ_ATTR_MAX + 1] = { 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; }