Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2303469imm; Mon, 28 May 2018 05:44:05 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrRq0tpOWRJrkznUfFrAh4JFzjs0xrsKnyOdXMUVDxFYhye/oRBNzrkwxJKluW5ESvzpzUz X-Received: by 2002:a17:902:6046:: with SMTP id a6-v6mr13451082plt.59.1527511445516; Mon, 28 May 2018 05:44:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527511445; cv=none; d=google.com; s=arc-20160816; b=q6XV3ZZRyueNy+Aog6MSnLhFG0HR4du4e+lsmHY642vTuVvRTDailG5uadZZ38gGI0 p8Wd59TcA81DNxlgz6bSNu2WQGmGLEWLBK8GG7rWWyjVO14bmwLmbpRyIuQ4mvKH2EhQ OaSIL+dbMc5io++3FsSJcOQuYkD4eVFLal5T1H2KRo9r9eXMZhG8uf7N8gc8XDIQ1FU2 sDtMB6bbXClpdylzGOmBgQPwe/NTCgWRjZCZKnLalj8CqyV5xwxIv3ml+PN+0KNG7uFk d7aRGoBlh9ihoQEC7m8wnIoZ8rHM+uSDCR+XpJvDdfjpEQ3WnTnT+cjyWvRURJyB+IDP 387A== 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:dkim-signature :arc-authentication-results; bh=Fa2nxqRFm6GCaUVYbaCa/nLw1Bveqq0GGejEXX834eA=; b=RdOEqofYEnzbVVLo+v1KbtudXD8/d+sNd2CQqfWNhfevh1FSDBfbiwF/DCKY1kzu1X PYZOYrYpg7zWvo/O0C/DbHILLyil5T48fhNaI9gxIlb1yxvgQPigL5vpaKjTDOxFCWbw rdvd3TKoYS2ITpARF7xRkJX78ckaPSiWXWM+08cTy2y/Scu4q3LE0DkOuKG5vw0AKu0D 6jo1mpbleaDpRJcTF+tgRzKqQS1j5x3q8RM+YWOrbYabWrJOoZyfc6jrx5s+Fpwzqla9 8fkD7rwJKzn0mtcf9C3c+mJv8dCbLvk+oo0geFrpnGVHtgmbpC9B17cYDJP7egdVBgQP 0m7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=NtB4+Hfj; 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 p61-v6si30463976plb.472.2018.05.28.05.43.50; Mon, 28 May 2018 05:44:05 -0700 (PDT) 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=NtB4+Hfj; 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 S937949AbeE1K6E (ORCPT + 99 others); Mon, 28 May 2018 06:58:04 -0400 Received: from mail.kernel.org ([198.145.29.99]:46192 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S937912AbeE1K6A (ORCPT ); Mon, 28 May 2018 06:58:00 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) (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 BD07B2087E; Mon, 28 May 2018 10:57:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527505080; bh=/DvGaZZtzYfWRq54IYTEy7bNgxAnxoKRxK7RUlZOjLY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NtB4+Hfjt/hkVhao98Ij4ZTf8lFVX7tFKOl3HhJXut7KC8nSNUBLzn8t/KpS/guXW xTr7Bgs+MaRJ+gnBsTzNNn3Z4sRxpK7vZn1CXlNnojrOaDqU7TgyN2lsg5w5jxQfbW 2yxXkstf1PRMyKzAnLsznKNPs7U1aA6Mk+IQcQg0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Paul Menzel , Luca Coelho , Sasha Levin Subject: [PATCH 4.14 368/496] iwlwifi: mvm: check if mac80211_queue is valid in iwl_mvm_disable_txq Date: Mon, 28 May 2018 12:02:33 +0200 Message-Id: <20180528100335.306594848@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180528100319.498712256@linuxfoundation.org> References: <20180528100319.498712256@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review 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.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Luca Coelho [ Upstream commit 9a233bb8025105db9a60b5d761005cc5a6c77f3d ] Sometimes iwl_mvm_disable_txq() may be called with mac80211_queue == IEEE80211_INVAL_HW_QUEUE, and this would cause us to use BIT(0xFF) which is way too large for the u16 we used to store it in hw_queue_to_mac820211. If this happens the following UBSAN warning will be generated: [ 167.185167] UBSAN: Undefined behaviour in drivers/net/wireless/intel/iwlwifi/mvm/utils.c:838:5 [ 167.185171] shift exponent 255 is too large for 64-bit type 'long unsigned int' Fix that by checking that it is not IEEE80211_INVAL_HW_QUEUE and, while at it, add a warning if the queue number is larger than IEEE80211_MAX_QUEUES. Fixes: 34e10860ae8d ("iwlwifi: mvm: remove references to queue_info in new TX path") Reported-by: Paul Menzel Signed-off-by: Luca Coelho Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/net/wireless/intel/iwlwifi/mvm/utils.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) --- a/drivers/net/wireless/intel/iwlwifi/mvm/utils.c +++ b/drivers/net/wireless/intel/iwlwifi/mvm/utils.c @@ -810,12 +810,19 @@ int iwl_mvm_disable_txq(struct iwl_mvm * .scd_queue = queue, .action = SCD_CFG_DISABLE_QUEUE, }; - bool remove_mac_queue = true; + bool remove_mac_queue = mac80211_queue != IEEE80211_INVAL_HW_QUEUE; int ret; + if (WARN_ON(remove_mac_queue && mac80211_queue >= IEEE80211_MAX_QUEUES)) + return -EINVAL; + if (iwl_mvm_has_new_tx_api(mvm)) { spin_lock_bh(&mvm->queue_info_lock); - mvm->hw_queue_to_mac80211[queue] &= ~BIT(mac80211_queue); + + if (remove_mac_queue) + mvm->hw_queue_to_mac80211[queue] &= + ~BIT(mac80211_queue); + spin_unlock_bh(&mvm->queue_info_lock); iwl_trans_txq_free(mvm->trans, queue);