Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3475571imu; Sun, 11 Nov 2018 15:58:49 -0800 (PST) X-Google-Smtp-Source: AJdET5f53cvnUQv7WgWzVKNRpLAZzJJUwBjMMQVkoz8pAIMBXO8As81x1vEOeCCsHP0afsYGlu67 X-Received: by 2002:a62:27c4:: with SMTP id n187-v6mr2882831pfn.3.1541980729397; Sun, 11 Nov 2018 15:58:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541980729; cv=none; d=google.com; s=arc-20160816; b=hQAKUFZiajUrIUMbOobwfZjCveAukPF4F5JMqxcyY6CzQCigbh6OOQUq9DAA1qmQtE Tcs5EKoTA1FHIvPTJ5FQZ/MiTm25QZbvUgfMIzbNWj4d/Vq8s0XPU0uaVxz6hKT1HMuI sM+pzeiTyut/FEXdlVc44UonKG/5a7fHucNSIxtq43WPENQBwl0/CUJj77efY0Aebvnd jCpYmz9KfennUNrMVpNMoSOLdHESpcU+QiuNYBzQLUpznebd7Nk9tFlUdfqozxQPQhxm vc0IbwUZi4rH1QMlBr+cgLcuafDYd/UqCVe/Xcky1OUTEMTXjN/HIAFKc+hwWUfIpyzf UeaA== 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=FzUyyyT3fOPf/Iedn3a4IRrGwC7NZeigtUkEE0p0FSk=; b=G7UfnUl1Nkf098e+bTUZSUuDZK4vFCUiaBGaJPFM9XLWVxGjmfiT2dzIyTgCx8t+AD DWGj+OkSMGagD2o05hf4dsMMEV65OMGka9Z3XlxWV2pqEfXqRGxycS1INKq7S6qfY+Zv U9ksKgzqgCoUGnUPDDkz97JMI/Lt+/uFaVylWlrDDJ8x9DqgFVFTgiT9vtKYvfQWv0aP EmCgBclADSV4vnAXHbwcWkvg007bdAAIX1f/J2Z/0LW1CWMz7127wSAUlbRDIoGeK6yy b3CXNkHZBlYPL2TO7+dVHOMtMdok6sVZdYfUO4kmKaYDLv8wXGH7JUmGTsGb3KW6bnYX FFgw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=DVKDPJqb; 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 p9si11999812pgc.448.2018.11.11.15.58.34; Sun, 11 Nov 2018 15:58:49 -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=DVKDPJqb; 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 S1732754AbeKLJrX (ORCPT + 99 others); Mon, 12 Nov 2018 04:47:23 -0500 Received: from mail.kernel.org ([198.145.29.99]:35400 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732359AbeKLISM (ORCPT ); Mon, 12 Nov 2018 03:18:12 -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 1CB16215EA; Sun, 11 Nov 2018 22:28:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541975296; bh=NWyAU0Iwr9qC/fZYDreHkKt4WmE3Zl8w6vvioxYAzXM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DVKDPJqb8iMNG6kjFF5owE4SjBnto2uJicEY+0Avz6mSnYUNV2pdLpv+UEltSZm/l h15FJiciXpJRs9DG8rGq1aq1w8h99uYvLk9UkS2O/azav8tIzIuSPfmxzvmbTipFWI bY1B2IEwxUXlxujTlUrvjxF6S/EhO5mQsFnnlCDc= 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.19 212/361] iwlwifi: mvm: check return value of rs_rate_from_ucode_rate() Date: Sun, 11 Nov 2018 14:19:19 -0800 Message-Id: <20181111221649.776537046@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181111221619.915519183@linuxfoundation.org> References: <20181111221619.915519183@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.19-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 @@ -1239,7 +1239,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 @@ -1290,7 +1294,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)) { @@ -1392,8 +1399,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. @@ -3262,7 +3273,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;