Received: by 2002:a05:6a10:6d25:0:0:0:0 with SMTP id gq37csp1827664pxb; Mon, 13 Sep 2021 06:27:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw4fHtV6hPf28nioALJNBUtrjIZGKQBvg/gpem2EZz74NqUeU8NqCzoQT4vTRkBMd9Hpzpz X-Received: by 2002:a17:906:d04b:: with SMTP id bo11mr12352157ejb.513.1631539625017; Mon, 13 Sep 2021 06:27:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631539625; cv=none; d=google.com; s=arc-20160816; b=h0AyLHRJJ9POu1mXX5Uv4/DSh7sIw7cXA/3KACFyDCxn7wk8uOrfXRZJKvM/4poIFz Mt0aDKAWKOo615e7437tbM947lr+2Aup2J4Pnj7BHN9PX3vEIT0wGgoQuhr87e9ZT8h4 mgqWpFGaEf2OCp7ppUJUmduA2ElKYBnSsfcigdaG74E54yK24UoYTMU+J2AudNSRG/yc e6Q9D5A5kN39B+bqyMg5boHbSCP7ul3yP9I/KU3znzt+ucUu+7IJopa36Bge8RsTAsr4 xuZvktB1Jts7OVOJYr2KrSb3ksOR+UdxHFpE2AJooGxx+jjTmDxwkFbEDJWuCXfZRaZo Xhvg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=fKwlL/VafeWw8l7e+n+sQNqc0hVzDh9ucNWOGKzSWb8=; b=XSPW+htblF0zBoURk7p1YwK+K8At8XwP6DAwYyOTJquz2ZFTO/Dj/lbdQ7WMSGXNxi muV2CPC1JCUzR0JTRRbdxisv6JVMCoOayH+4GaYYvGy1hnudd/PKSxLAchnrPeljlVJK KRmqj4iBPrfbaTw3hS8Rd0fh+u0h92beRChJ1UGU79UJb2H7xxF45X7I48e+NOB5E4Iw aCrrWsrvGzEXuFdckpgq5chGXY47Tq5PdaY8SCdHlLR/9s8yj1A3wz7+8MRnKE+DGH60 cJgnxgaVNEePnLEJOPzgOxj3EYxzFh8/hPJBoElSwJVW+yrPdjTGjpeQleftHBmLulh3 xRGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=OBN+lD+g; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w6si6115925edj.147.2021.09.13.06.26.38; Mon, 13 Sep 2021 06:27:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=OBN+lD+g; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240079AbhIMNYa (ORCPT + 99 others); Mon, 13 Sep 2021 09:24:30 -0400 Received: from mail.kernel.org ([198.145.29.99]:35288 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240223AbhIMNUD (ORCPT ); Mon, 13 Sep 2021 09:20:03 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 9D79C6113E; Mon, 13 Sep 2021 13:18:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1631539093; bh=Mw3hIYQzh0QVHvYsLwLfms21TRhmklsfso0cJCrNguU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OBN+lD+glUXjTrilHNdLgdj5TEJIdqEi6d9JsUAuFShOVrjKEZsSeGTYnr4C1z0wX ejZf97EF49aHDColQBAyZt/g81a+QjZSSKRvpUzhxOgVdBD2ZDAMtjC+wEaT2hEZXY vCO2eHkV01HxNPSWdicRLbnKQWzpElI7MlIDyus8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Giovanni Cabiddu , Marco Chiappero , Fiona Trahe , Herbert Xu , Sasha Levin Subject: [PATCH 5.4 039/144] crypto: qat - use proper type for vf_mask Date: Mon, 13 Sep 2021 15:13:40 +0200 Message-Id: <20210913131049.255972256@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210913131047.974309396@linuxfoundation.org> References: <20210913131047.974309396@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Giovanni Cabiddu [ Upstream commit 462354d986b6a89c6449b85f17aaacf44e455216 ] Replace vf_mask type with unsigned long to avoid a stack-out-of-bound. This is to fix the following warning reported by KASAN the first time adf_msix_isr_ae() gets called. [ 692.091987] BUG: KASAN: stack-out-of-bounds in find_first_bit+0x28/0x50 [ 692.092017] Read of size 8 at addr ffff88afdf789e60 by task swapper/32/0 [ 692.092076] Call Trace: [ 692.092089] [ 692.092101] dump_stack+0x9c/0xcf [ 692.092132] print_address_description.constprop.0+0x18/0x130 [ 692.092164] ? find_first_bit+0x28/0x50 [ 692.092185] kasan_report.cold+0x7f/0x111 [ 692.092213] ? static_obj+0x10/0x80 [ 692.092234] ? find_first_bit+0x28/0x50 [ 692.092262] find_first_bit+0x28/0x50 [ 692.092288] adf_msix_isr_ae+0x16e/0x230 [intel_qat] Fixes: ed8ccaef52fa ("crypto: qat - Add support for SRIOV") Signed-off-by: Giovanni Cabiddu Reviewed-by: Marco Chiappero Reviewed-by: Fiona Trahe Signed-off-by: Herbert Xu Signed-off-by: Sasha Levin --- drivers/crypto/qat/qat_common/adf_isr.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/crypto/qat/qat_common/adf_isr.c b/drivers/crypto/qat/qat_common/adf_isr.c index 4898ef41fd9f..7d319c5c071c 100644 --- a/drivers/crypto/qat/qat_common/adf_isr.c +++ b/drivers/crypto/qat/qat_common/adf_isr.c @@ -59,6 +59,8 @@ #include "adf_transport_access_macros.h" #include "adf_transport_internal.h" +#define ADF_MAX_NUM_VFS 32 + static int adf_enable_msix(struct adf_accel_dev *accel_dev) { struct adf_accel_pci *pci_dev_info = &accel_dev->accel_pci_dev; @@ -111,7 +113,7 @@ static irqreturn_t adf_msix_isr_ae(int irq, void *dev_ptr) struct adf_bar *pmisc = &GET_BARS(accel_dev)[hw_data->get_misc_bar_id(hw_data)]; void __iomem *pmisc_bar_addr = pmisc->virt_addr; - u32 vf_mask; + unsigned long vf_mask; /* Get the interrupt sources triggered by VFs */ vf_mask = ((ADF_CSR_RD(pmisc_bar_addr, ADF_ERRSOU5) & @@ -132,8 +134,7 @@ static irqreturn_t adf_msix_isr_ae(int irq, void *dev_ptr) * unless the VF is malicious and is attempting to * flood the host OS with VF2PF interrupts. */ - for_each_set_bit(i, (const unsigned long *)&vf_mask, - (sizeof(vf_mask) * BITS_PER_BYTE)) { + for_each_set_bit(i, &vf_mask, ADF_MAX_NUM_VFS) { vf_info = accel_dev->pf.vf_info + i; if (!__ratelimit(&vf_info->vf2pf_ratelimit)) { -- 2.30.2