From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=52.101.52.57 ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796385008; b=5GeNvnbkVXZUwFHy9z1MKJB+pYmSEcS5pfhfNotBOVpTqk8j96KcSv1cI9Xh81UKoMrZ xjGV6iJMr99VD2aEUOrZ97ce5azsUh0GqiHKQpkNxlpR1TXXhm47enKbXKSJ+4uBkkJat Z66AzP8GVIlapISA+ozR82JZPNQdaFzqNmLMA+Yq6cHArsxPoHjPshg8fm2wTCT1/4stF qjdk8OELxKqRrlmsgpxBHOuBghmUyfBfJvUT5eEpPucEAmXs/FcyPOvLMdhIT08eaTF+L XMJ6g84lpaKc39U129Yi6GD+HdbNUwVRo+N1RHQ29pIAvvs92ZtCywt9U5k5LlMSE5A== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796385008; h=DMARC-Filter:DKIM-Signature:Received:Received: X-MS-Exchange-Authentication-Results:Received-SPF:Received:Received: Received:Received:From:To:CC:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:MIME-Version:Content-Transfer-Encoding: Content-Type:X-EOPAttributedMessage:X-MS-PublicTrafficType: X-MS-TrafficTypeDiagnostic:X-MS-Office365-Filtering-Correlation-Id: X-MS-Exchange-SenderADCheck:X-MS-Exchange-AntiSpam-Relay: X-Microsoft-Antispam:X-Microsoft-Antispam-Message-Info: X-Forefront-Antispam-Report: X-MS-Exchange-AntiSpam-MessageData-ChunkCount: X-MS-Exchange-AntiSpam-MessageData-0:X-OriginatorOrg: X-MS-Exchange-CrossTenant-OriginalArrivalTime: X-MS-Exchange-CrossTenant-Network-Message-Id: X-MS-Exchange-CrossTenant-Id: X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: X-MS-Exchange-CrossTenant-AuthSource:X-MS-Exchange-CrossTenant-AuthAs: X-MS-Exchange-CrossTenant-FromEntityHeader: X-MS-Exchange-Transport-CrossTenantHeadersStamped; bh=kCXVPwCA18gvfjPA8rWyTaQ/x/ZdtaYagrPUJpMGa9g=; b=eukNYEdBspZQ/m+FOfjh52c4AfL8YNlbE/QwChttUGghtjqnOLBSKsz1f7JVKVEzNRGx dftqBVCHEzsivS/efA4wl3E6RFA8XT5nsjLtXJ6Fibh9fZhDG9LO8Kw1iVYMSUNv6zkBW tnPBHPYga1hja1jbi7BTiDelnaVilkbcTMt+W9t/dhUO5N2tRRjCml40kH0X+LVkIYPHl bjWVg4np9XPZ5WgPMI/p0xYN50bN5SYnWFHkdHbnTDOWMvWAJ6u4Rr7yWouwhrUpLnZ4O nVVEvCJJ0iWO0PgntvBSxaf63urHtl4B4Q4/VrN/OTZprLn1NAu1VNppBr2giAil2tA== ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass header.d=amd.com header.i=@amd.com header.a=rsa-sha256 header.s=selector1 header.b="nWM3e2J/"; arc=pass header.oldest-pass=0 smtp.remote-ip=52.101.52.57 Received: from BL2PR02CU003.outbound.protection.outlook.com (mail-eastusazon11011057.outbound.protection.outlook.com [52.101.52.57]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (secp384r1) server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 81690606A322; Fri, 4 Dec 2026 11:50:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 81690606A322 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=amd.com header.i=@amd.com header.a=rsa-sha256 header.s=selector1 header.b=nWM3e2J/ ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=aNaCectSKzb4e9oNLanyuVj3fUEp56trOI7lqIJ30+eZFUNVT0XQsRe+5jwV3wtumuaJJ0lcUMVazq6j5TaTEAxbnNJZvMSDO6W8nYdfmr/gyu5NqFVkRWKXJboI9XEAa5EH/bjivz/bf5ejKMkMiQAnEZne6QemZCWP0TfMMW//8atu5q1oHMeYGbc9UnPTUjHe3c+58KxHj6/7wkfFvYNOo8hkp2ZDmaUJGu65Zbfdgn3UIq5ZPIyPIJF7PBUHrPZDtixJkJn4eJ0mLMUlVQS0xK30s7DEN1DUmfE4JkkMpuo4N8qbgJE41NUv3NY0JOfpyzyitPoalT+JvsRakQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=kCXVPwCA18gvfjPA8rWyTaQ/x/ZdtaYagrPUJpMGa9g=; b=kkGi4aZGpi5RyD/mO5OoPQMLtArfoaG/ujNEsCUOQLjN6/gwxyca586xy3KeUs3YWL8ZgwtnV30Um9+Ptxa4gAvmWT++8cAgs8YCoVQv/sMYkmhzO3EsNlEJK/gkORNLaK8UPJVxQBpARs+WrRkdr9fPdXrRCNu1vYy5aj/zwXaAYJVEFsXxtUMX35x9QCiHNk86bmrEwaGNz/wvoHwY5hq6fiQNXlRlo/ja9WOsxbfkdO+kb+AXDVuZPBk7TDMhA48Pv1pUNEIsqAni+b7G+0C0YsdbuJOhGJXmSdEwVAkpoJbtig+K9cxZiORJ5cYC9yDHLWA2ND2s3Sd1lThfjQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=ziepe.ca smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=kCXVPwCA18gvfjPA8rWyTaQ/x/ZdtaYagrPUJpMGa9g=; b=nWM3e2J/9njYUDlJj0NUkApWq2AYmGr0JkcLPEujE2K/EpU3NIHPeivJyAJp/aao386W0oL9nI2NocnDFEJpMWXpaUIv6eLjM0LFcz4N13hbisbvucM6FYHIC2xU5sVC2xXcM6I39jsSh57G344vnMMO5XjysUn/M7Vwg+wbZsk= Received: from CY5PR10CA0006.namprd10.prod.outlook.com (2603:10b6:930:1c::6) by DM6PR12MB4186.namprd12.prod.outlook.com (2603:10b6:5:21b::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.688.12; Fri, 4 Dec 2026 11:50:04 +0000 Received: from CY5PEPF00000E83.namprd05.prod.outlook.com (2603:10b6:930:1c:cafe::98) by CY5PR10CA0006.outlook.office365.com (2603:10b6:930:1c::6) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.688.13 via Frontend Transport; Fri, 4 Dec 2026 11:50:03 +0000 X-MS-Exchange-Authentication-Results: mx.microsoft.com 1; spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=satlexmb08.amd.com; pr=C Received: from satlexmb08.amd.com (165.204.84.17) by CY5PEPF00000E83.mail.protection.outlook.com (10.167.247.182) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.709.6 via Frontend Transport; Fri, 4 Dec 2026 11:50:03 +0000 Received: from Satlexmb09.amd.com (10.181.42.218) by satlexmb08.amd.com (10.181.42.217) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.57; Fri, 4 Dec 2026 05:50:01 -0600 Received: from satlexmb08.amd.com (10.181.42.217) by satlexmb09.amd.com (10.181.42.218) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.57; Fri, 4 Dec 2026 05:50:01 -0600 Received: from xhdipdslab46.xilinx.com (10.180.168.240) by satlexmb08.amd.com (10.181.42.217) with Microsoft SMTP Server id 15.2.2562.57 via Frontend Transport; Fri, 4 Dec 2026 05:49:59 -0600 From: Abhijit Gangurde To: , CC: , , , , "Abhijit Gangurde" , Jiri Pirko Subject: [for-next v5 1/4] RDMA/ionic: Bound user queue depth and stride before shifting Date: Fri, 4 Dec 2026 17:19:40 +0530 Message-ID: <20261204114943.3530599-2-abhijit.gangurde@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261204114943.3530599-1-abhijit.gangurde@amd.com> References: <20261204114943.3530599-1-abhijit.gangurde@amd.com> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY5PEPF00000E83:EE_|DM6PR12MB4186:EE_ X-MS-Office365-Filtering-Correlation-Id: be78dde4-4c4e-4641-9f66-08df51fcbc11 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|23010399003|82310400026|376014|1800799024|36860700016|261102123227099003|261021135927099003|261021121427099003|11063799006|56012099006|10067099003|18002099003|22082099003|261009223027099003; X-Microsoft-Antispam-Message-Info: LlBY4CCfE1YEdxryZHA1BAMJitXzVaDJDxH2tTgEuoNihAiFVzLdV133sT3TvQFMw6YCpcTvtqp4gG0stdBbslBXK1Ih5ByqNmfP/kkqIsNXj0N44gIdeU+LP6PQFoIgraCxxXLBmjvBMlbvMIC6QYeqWfqn2XF61Tas3b70SqgBvrKon7fxnRf+AXTtJgypCobGIzV06ve3F0S3lWTcCasXki2B98BinoG/3yUn1DIZhRHxrPiSO5nV6Eg2oBZEO2NhL5y6QF6nfVMjm/d2x0RqvJtmLHxOYwF4KxBsp2S7tTo+OBNU8yMfFKV98rT7+2USGTsqu6QXK4TL0o5zYWGnczYdPnhx0x+slqx468vNZcnSc4MrPktns8yyzbuc6XfJ70rfPK5ZxXQk4mcG/5DTwrdDb2DCFfRR6WERMzacbsF9VBY9DOO6W0G5T2EWdbnOXMdVlRvHcNfb2KQKe1jvVTAO1qfh1oXx77wYb/VGCXIsAzqfj+ypje9cvMemW4za+huBj05dwndG+dYalxKQtCbXT2cFpjK/eTN0zeYBd3oi5qfkgasghsZtjSC8KJdMt3SJdsBlfLu+5GJE5Llplyc3IJOWuEALhWlnW0oTdVH48iBIWcL1zyeAMqktN/m6kLdT7YDl+kqfmyMrhgWRPdULff0dN49BY21ZpQA1IEVFyHJ8DHejUjXVPC9PggkAUc8F439pX8bVe/qbFw== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:satlexmb08.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(23010399003)(82310400026)(376014)(1800799024)(36860700016)(261102123227099003)(261021135927099003)(261021121427099003)(11063799006)(56012099006)(10067099003)(18002099003)(22082099003)(261009223027099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ERc/u2PAmNTl/gcLWoSc9kVBBhmN1M47MEBWhL8px6ML6rzn5wQr25JX52FK1m8b/8qIg8gP5o8c4pVgw/w9Jt820tjxs1N1kUDGXJyQ/9rs8YH4RupPtj4mlVYWrGQ+yxTq8ew+oIq8/lqT0Aq0GFIwzzqv1j8aEzAPSuE+LxLWFzjbzR20R0rrlpWCU+n4Y4EkPpmxYtvJSnrON1V03IlBEew68SRq8bvU+JDF3PyET395vosbqOm7jzUIXYxx+XT/03tNno+wVn6LOR4LPT7EiP/VU+ryNU1Jz9L+eGOtjsi6g1L7HZbNXVpkBh/ozmdoz2FxQW35FbHGa0eOnG2geVkKlnLfPOZPT1f3lAYI8APB/Q3q9Ho4KqgxITzvfjdpsEOIBlKds0t2k7o4rAoj+r35PKK/tfjfF023owxP090s1qFiGGC7uK309eKL X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Dec 2026 11:50:03.7930 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: be78dde4-4c4e-4641-9f66-08df51fcbc11 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[satlexmb08.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY5PEPF00000E83.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4186 ionic_validate_qdesc() uses depth_log2 and stride_log2 from the user request as shift counts without an upper bound. Both are u8, so BIT(depth_log2) and BIT_ULL(depth_log2 + stride_log2) can shift by the width of the type or more, which is undefined behaviour. Where the shift count wraps, as on x86-64, the size check can be bypassed. With depth_log2 = 4, mask = 15 and stride_log2 = 60, the required size BIT_ULL(64) evaluates to 1, so a one page ring passes validation with a depth and stride it cannot hold. Reject a depth_log2 above order_base_2(IONIC_MAX_DEPTH), and a depth_log2 + stride_log2 of BITS_PER_LONG_LONG or more, before either shift. Fixes: f3bdbd42702c ("RDMA/ionic: Create device queues to support admin operations") Reviewed-by: Jiri Pirko Signed-off-by: Abhijit Gangurde --- drivers/infiniband/hw/ionic/ionic_controlpath.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/infiniband/hw/ionic/ionic_controlpath.c b/drivers/infiniband/hw/ionic/ionic_controlpath.c index bf012f886fbc..717ab78b603c 100644 --- a/drivers/infiniband/hw/ionic/ionic_controlpath.c +++ b/drivers/infiniband/hw/ionic/ionic_controlpath.c @@ -23,6 +23,13 @@ static int ionic_validate_qdesc(struct ionic_qdesc *q) if (q->addr & (PAGE_SIZE - 1)) return -EINVAL; + /* Keep the shift counts below within the width of their types */ + if (q->depth_log2 > order_base_2(IONIC_MAX_DEPTH)) + return -EINVAL; + + if (q->depth_log2 + q->stride_log2 >= BITS_PER_LONG_LONG) + return -EINVAL; + if (q->mask != BIT(q->depth_log2) - 1) return -EINVAL; -- 2.43.0