Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2257167imm; Mon, 28 May 2018 04:55:37 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrc9+fT42HnrZbCI8bq5NN4zJtxmCWXjhAvLkByWoPIX+Hj5WEgiHa7nqaqx2j3rNOWel89 X-Received: by 2002:a17:902:9a95:: with SMTP id w21-v6mr12968643plp.168.1527508537190; Mon, 28 May 2018 04:55:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527508537; cv=none; d=google.com; s=arc-20160816; b=G5sw9n/tJDgsqn4z+wwotanGHTdluahw6gQSVmHgMNZLBDucYC7nSVrf8LO3sxj8xr edr/k8is9tOuWqI8+JlL/HgjWfX2nufUdKVpz/k2Upi6FoieIue6JqhZlL3/McpM24V9 losyra5nm/+lX1oBVbbL1DrpfoH/BmJzmlfVRW3DkhgEmrAu6qrzlL78WYHwqZaN2Nva sF6nscvW9E3YYTwGkNbdOlWnPwDxH0OhOocaxzHupQiOxNoz85EH30uKEh8Y3RyeIv5/ kqTO66sM1eC1MvAcuXTABog+mCeMCE4WG/bDrcwKQa6t6NkvtkVl8/esalpglsXnkap7 NIbg== 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=bFz3Vn3ns5Cw4bsBnjyPgrv3dCbfEhLmEb9RTyi3nCA=; b=Hy/+1lJgy9aFseTTI4/f3kX6pPlloXIYeBlOu5hBmAvLUL+dDtzEywwY3Wbw6TF5fo RRGjBp4yOm2D0k9EzQLh63JaJCPJYy+EHceRTy3nenyq1KNNURtWOBuKunK2+uOTAL39 HtPHI8QqqgjLoMVB1lwv+9Kha5WHoiB/rNPg6bJqwsye/qvXdmHuzdV4OdJiq05a3AVw Ne2pm9peink3DL82rONMIUg8XAotL2DmthV7Vx6VkHxapgYXZerkNz3bU42WP0vG/roT woZaCc6C/rK4/I9OeVGJke1EoJw58yApibnWiUAb1WoNpjBmyIukZLAnAhfUQ06sRV+B B7zg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=N+Xl1W7L; 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 j78-v6si5065971pfe.187.2018.05.28.04.55.22; Mon, 28 May 2018 04:55:37 -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=N+Xl1W7L; 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 S1423838AbeE1Ly3 (ORCPT + 99 others); Mon, 28 May 2018 07:54:29 -0400 Received: from mail.kernel.org ([198.145.29.99]:56346 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1423309AbeE1LIr (ORCPT ); Mon, 28 May 2018 07:08:47 -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 6EBC32089E; Mon, 28 May 2018 11:08:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527505726; bh=kedHkX+623nY53jbBOdiVC2wqP3X+q3fndkf4iHPxa0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=N+Xl1W7LIUa2VjrEuN+xqN1YgoJimVRKebNfWWdEKn2FdcHtlNN9c31cUMNTUftmD 7d3lKIt3O50yw+RIHuJqIn97V5UKrg69AoYpDse2oURUtS6FW5TtV+4yjXX5FUg8+m m1WHece5xgtzFeUPQkc8JqsbwZW8QseN2obQiG2A= 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.16 106/272] iwlwifi: mvm: check if mac80211_queue is valid in iwl_mvm_disable_txq Date: Mon, 28 May 2018 12:02:19 +0200 Message-Id: <20180528100250.008518285@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180528100240.256525891@linuxfoundation.org> References: <20180528100240.256525891@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.16-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 @@ -800,12 +800,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);