Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3431977imu; Sun, 11 Nov 2018 14:59:16 -0800 (PST) X-Google-Smtp-Source: AJdET5fJbmKHX00bsut53KNiVxKQSUrXUW9Zd8N+vME9jKxltzKdSpbwuhG5qIGS0qV2odUlNE5R X-Received: by 2002:a62:9f98:: with SMTP id v24-v6mr8397829pfk.163.1541977156598; Sun, 11 Nov 2018 14:59:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541977156; cv=none; d=google.com; s=arc-20160816; b=oFIiKw6d1JoBe/3oLsqiJtG0GXd1muqMJre6rSpXj+NrJjHnQjJ3HZ51YM03AfA0Fk sSsRcaRT2foFhRh/QwtnRUYEqfMV49sTIWMOmyAf4fzTsejDaB9Zxv5jtwg+KOOPv6uQ 9Ezrh9Y4DIBVJNMcNwKyn7J1G310mV5MZSDSv56pUPTsJWAnhtsFwzTH1q6BN0t+rRhT vM3UPA4mxAAQxYD05jMfX0wzUkn+SG0Vrogq6VJtyR9hmyB2lqs9g52+3vM72MKmOk8X JW47oD1JWrirDHwNHgbu97yGXnluSXRRTMPJnnzmrsoTr1W7UYRfitY7Ac7R/C4XRFIW pM8g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=QkjU7F4H5ha7riUDsXIakzHW4GXtKxWfZTykM/0xjhs=; b=uCTLf/Dmz5myRhmSluQBspX+P2TPKzxSkMTCMXUgGW2Xv5+f2vF6v4fWzep5+1vI9d zIkOyMm3vGHF+/2AsTvAJp+ij+5GX+4j36oAKD4dnslE3gT3h1+OFdJ7qLh6pWpQEUEk 6dVFHf2wn2uLLrAozKy7Me9Th4STLBvyTVKMb/IEZbFPqLYd91BG6ajRZ647REZfT1Na uI58RHeL9NPM1DYS7+CjXi2MtQ+mkqfHMq7VWI2VxMwhExZTD+cfj0jqzsz/1aSJnDx5 qgXCTl8JSG93NzLyuKSuJSDy1PgajWe66XQbiMJXJCmU1kZILcKj1jhxqu5Se7EnkP5f N0BA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=2o9pkUAP; 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 be8-v6si15146419plb.143.2018.11.11.14.59.01; Sun, 11 Nov 2018 14:59:16 -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; dkim=pass header.i=@kernel.org header.s=default header.b=2o9pkUAP; 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 S2403902AbeKLIse (ORCPT + 99 others); Mon, 12 Nov 2018 03:48:34 -0500 Received: from mail.kernel.org ([198.145.29.99]:52394 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2403757AbeKLIWk (ORCPT ); Mon, 12 Nov 2018 03:22:40 -0500 Received: from localhost (unknown [206.108.79.134]) (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 82CB3223C7; Sun, 11 Nov 2018 22:32:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541975562; bh=I1xeypVHgg9D0WgoPBDj2YYCUYC31Dn4DldSJRF487I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2o9pkUAP5gLGFsQOaJxY7ucILvzNXNYA1L1XQ7y4Tf6sdYa0Trnd59gYb99qbPBCW cK/jRq7FkwqLye7AqPpbYnsTNAr5SSF4JYxHqexn2F8ZYLqjnv4P42DgILX3vVmwh0 2vcxjvhAa+5YJ2EGCQ+mQ9Abqgf4A08Tz0FVAXcc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Luca Coelho , Kalle Valo Subject: [PATCH 4.14 127/222] iwlwifi: mvm: check return value of rs_rate_from_ucode_rate() Date: Sun, 11 Nov 2018 14:23:44 -0800 Message-Id: <20181111221658.999939192@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181111221647.665769131@linuxfoundation.org> References: <20181111221647.665769131@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review 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 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Luca Coelho commit 3d71c3f1f50cf309bd20659422af549bc784bfff upstream. The rs_rate_from_ucode_rate() function may return -EINVAL if the rate is invalid, but none of the callsites check for the error, potentially making us access arrays with index IWL_RATE_INVALID, which is larger than the arrays, causing an out-of-bounds access. This will trigger KASAN warnings, such as the one reported in the bugzilla issue mentioned below. This fixes https://bugzilla.kernel.org/show_bug.cgi?id=200659 Cc: stable@vger.kernel.org Signed-off-by: Luca Coelho Signed-off-by: Kalle Valo Signed-off-by: Greg Kroah-Hartman --- drivers/net/wireless/intel/iwlwifi/mvm/rs.c | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) --- a/drivers/net/wireless/intel/iwlwifi/mvm/rs.c +++ b/drivers/net/wireless/intel/iwlwifi/mvm/rs.c @@ -1226,7 +1226,11 @@ void iwl_mvm_rs_tx_status(struct iwl_mvm !(info->flags & IEEE80211_TX_STAT_AMPDU)) return; - rs_rate_from_ucode_rate(tx_resp_hwrate, info->band, &tx_resp_rate); + if (rs_rate_from_ucode_rate(tx_resp_hwrate, info->band, + &tx_resp_rate)) { + WARN_ON_ONCE(1); + return; + } #ifdef CONFIG_MAC80211_DEBUGFS /* Disable last tx check if we are debugging with fixed rate but @@ -1277,7 +1281,10 @@ void iwl_mvm_rs_tx_status(struct iwl_mvm */ table = &lq_sta->lq; lq_hwrate = le32_to_cpu(table->rs_table[0]); - rs_rate_from_ucode_rate(lq_hwrate, info->band, &lq_rate); + if (rs_rate_from_ucode_rate(lq_hwrate, info->band, &lq_rate)) { + WARN_ON_ONCE(1); + return; + } /* Here we actually compare this rate to the latest LQ command */ if (lq_color != LQ_FLAG_COLOR_GET(table->flags)) { @@ -1379,8 +1386,12 @@ void iwl_mvm_rs_tx_status(struct iwl_mvm /* Collect data for each rate used during failed TX attempts */ for (i = 0; i <= retries; ++i) { lq_hwrate = le32_to_cpu(table->rs_table[i]); - rs_rate_from_ucode_rate(lq_hwrate, info->band, - &lq_rate); + if (rs_rate_from_ucode_rate(lq_hwrate, info->band, + &lq_rate)) { + WARN_ON_ONCE(1); + return; + } + /* * Only collect stats if retried rate is in the same RS * table as active/search. @@ -3244,7 +3255,10 @@ static void rs_build_rates_table_from_fi for (i = 0; i < num_rates; i++) lq_cmd->rs_table[i] = ucode_rate_le32; - rs_rate_from_ucode_rate(ucode_rate, band, &rate); + if (rs_rate_from_ucode_rate(ucode_rate, band, &rate)) { + WARN_ON_ONCE(1); + return; + } if (is_mimo(&rate)) lq_cmd->mimo_delim = num_rates - 1;