Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp3411969rwa; Tue, 23 Aug 2022 04:28:08 -0700 (PDT) X-Google-Smtp-Source: AA6agR6jBWfsFUjbreli1ptrHhN2qPGRzFK8NGaskgW4F2prh3MfT+OvqRRVUQMNIvoZxS3XU6sw X-Received: by 2002:a17:902:d708:b0:172:f24e:2e59 with SMTP id w8-20020a170902d70800b00172f24e2e59mr6914745ply.169.1661254087922; Tue, 23 Aug 2022 04:28:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661254087; cv=none; d=google.com; s=arc-20160816; b=LL1B34YEFbvVk5O6IzKA9k4KLP0dtmnEt0i5Wl5pjZr2IJUdL8/d7qlGXcCn1pzrUQ 7N/TiEzCHqDHgR+gJjny56UBv9YRaoMRqkoqUpIjNJe/PRA3mRJ/axEigVC0bsoOI6DB Y2W2sf6gv0vmd3nlU6VS1DRetBoVujODXPnVdjP1MadBqRLvq6DQfJqkXtzG5pwhAHmw OR5VpbCSQd2gxAMMaRmi7WvO936VEu14ZwZlNvH07Hx7BhEVWhyAIYVpcViMsjLrx8So C4pz+S/7MhCZha38RVYz9hAtnoFw0iAumVfLRoTz54vvaH1yP3+ev+CAi52QG60odjS4 8IAQ== 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=VYxXSA9FnblS8mf1O0LjKlbjsL8zZ8af+HaunaRKnRg=; b=ZORLjCHZnbziP5VDkDIlKg9Io6DNYmgaw0hnUKgr0BqIeZoOdLwGISHDbY4OeIQqmT 0U/PnVwI2ZRsS6tdYAshDvGhatRoq8D1AO/a+L1WCi8XDerEZx4q3TrN0sMtV9mmLSge b+HGbEKCFqXlZhzCcfKRbtq8JjgDg1oYpExjehmig841l7C4Ky2tkDjKaOhz65U2xS3U G2Ae97ReHfv41Go2qX3vPDApZDG0o9umLWL629vI9VPbM1KT2yJvMpuNVRjPrkYRxMOw E/KyeXYSif6j87h1TQ6XszHGJnS4XynXM6dhBZ8bvRWbIdJbthrF64gb+ccAp6HZyINq HKjw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Z0l7i63A; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id rm2-20020a17090b3ec200b001f3e54ca93asi13065687pjb.76.2022.08.23.04.27.57; Tue, 23 Aug 2022 04:28:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Z0l7i63A; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S243049AbiHWJP0 (ORCPT + 99 others); Tue, 23 Aug 2022 05:15:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34114 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348506AbiHWJMs (ORCPT ); Tue, 23 Aug 2022 05:12:48 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E0EAD86C33; Tue, 23 Aug 2022 01:31:36 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id CF1E0614BC; Tue, 23 Aug 2022 08:31:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BE261C433D6; Tue, 23 Aug 2022 08:31:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1661243479; bh=epSUldJ7qZaSa/KN4cH2lvf0JxykKV7qMCXgRU+QuaQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Z0l7i63AkSN42453pTLeDfJFTBngHltKBNV9+I9omEU4VpmjsA+QyuVpCYhvSQ7hL gDuo2R1lcZHhZDF9EIvQtPK67cxvGPoK168beIlCOvRX6zmWW/Bh64lSdpiL+36zi7 ZcftaY1vLSXDaJnxeCtQsJ3fTq63MAvhR2OEJ8kw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ofir Bitton , Oded Gabbay , Sasha Levin Subject: [PATCH 5.19 290/365] habanalabs/gaudi: fix shift out of bounds Date: Tue, 23 Aug 2022 10:03:11 +0200 Message-Id: <20220823080130.342666788@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220823080118.128342613@linuxfoundation.org> References: <20220823080118.128342613@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ofir Bitton [ Upstream commit 01622098aeb05a5efbb727199bbc2a4653393255 ] When validating NIC queues, queue offset calculation must be performed only for NIC queues. Signed-off-by: Ofir Bitton Reviewed-by: Oded Gabbay Signed-off-by: Oded Gabbay Signed-off-by: Sasha Levin --- drivers/misc/habanalabs/gaudi/gaudi.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/drivers/misc/habanalabs/gaudi/gaudi.c b/drivers/misc/habanalabs/gaudi/gaudi.c index e6bfaf55c6b6..3fb221f2e393 100644 --- a/drivers/misc/habanalabs/gaudi/gaudi.c +++ b/drivers/misc/habanalabs/gaudi/gaudi.c @@ -5654,15 +5654,17 @@ static int gaudi_parse_cb_no_ext_queue(struct hl_device *hdev, { struct asic_fixed_properties *asic_prop = &hdev->asic_prop; struct gaudi_device *gaudi = hdev->asic_specific; - u32 nic_mask_q_id = 1 << (HW_CAP_NIC_SHIFT + - ((parser->hw_queue_id - GAUDI_QUEUE_ID_NIC_0_0) >> 2)); + u32 nic_queue_offset, nic_mask_q_id; if ((parser->hw_queue_id >= GAUDI_QUEUE_ID_NIC_0_0) && - (parser->hw_queue_id <= GAUDI_QUEUE_ID_NIC_9_3) && - (!(gaudi->hw_cap_initialized & nic_mask_q_id))) { - dev_err(hdev->dev, "h/w queue %d is disabled\n", - parser->hw_queue_id); - return -EINVAL; + (parser->hw_queue_id <= GAUDI_QUEUE_ID_NIC_9_3)) { + nic_queue_offset = parser->hw_queue_id - GAUDI_QUEUE_ID_NIC_0_0; + nic_mask_q_id = 1 << (HW_CAP_NIC_SHIFT + (nic_queue_offset >> 2)); + + if (!(gaudi->hw_cap_initialized & nic_mask_q_id)) { + dev_err(hdev->dev, "h/w queue %d is disabled\n", parser->hw_queue_id); + return -EINVAL; + } } /* For internal queue jobs just check if CB address is valid */ -- 2.35.1