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.46.36 ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796296108; b=E/+K9qUagE5ePN29eduY0Xnc1M63QnYaTMUczAewmQfXXI0v61BBad6p8aUogkVdo+/y jlN5lhByDVY1bba9F4aGeeZA1lYERPOV+uPB81BP3e7EpB9+OE+dCfnn4pmQLOkKM1v5t qBmeXdsAnJzAQePer1TZLvfG+mUwJsjPt/dIq3biv0HKoZJS8QWp2/EVCDhjR8vEgSYD8 nceLHhNmP2SeBu/9eWMggWkZIvmQpmS4xypZBlxKyUwrhhhRbDxgJqrmvL8OldvVAVLoP qrv4Fa0CrmOphbJpuUZrCA1QIAV8siNZPpAeubmBxxecOQYqBHde2EElY4LxsPCeQOA== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796296108; h=DMARC-Filter:DKIM-Signature:Received:Received: X-MS-Exchange-Authentication-Results:Received-SPF: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=rdlfWvzfISzn8kQMrAn9T5LiEAF04o/rwCujocnADxw=; b=IwmLWfwEMj+9sugQHQz+FWKB5pp+poG/08HlEfvaRuwCyiQXxruR2dX2EkKvo4nA2O46 zRIJS6NmfXVLQbn/LbgRRJLXP2dsm2Av3jsp3Fy0aE4LRAqvlzzYotwNrVnr42MTEGGmb aH4RWfDgXp6HPRYB4mN1pzOIfwzN5v/T4NUG4dS3ewvteLq0r5iOzSWeYGGulHfV0enM3 bL/aNsHh9DmEA7dF9BYYVEnZFfzAOYqJljwL6tLSx78TdxMhJHQkOzKV32xi9lrdKDLEb dHI99sNMif3+8LENxCstRViwC76Tgq3J5GbRAuLpDIk9eKYOjphx4fcfWtHhlSeMoBw== 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=RFQD3apX; arc=pass header.oldest-pass=0 smtp.remote-ip=52.101.46.36 Received: from CO1PR03CU002.outbound.protection.outlook.com (mail-westus2azon11010036.outbound.protection.outlook.com [52.101.46.36]) (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 84BBB606A32C; Thu, 3 Dec 2026 11:08:27 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 84BBB606A32C 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=RFQD3apX ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Eib86QfvUlUBo6CaXhxfZV60fYlPABgmF29xROwWR043GicpeD/KSYEvhyanYrv3y4LNjnMU1FKGV53ns+fYfSDq+Lq+SnYNEhix8QoPV4NEZ1x8fLQIGpAVBYqvDIwOs7rNL0EotMfBcrwrrOn88oowlg77w2hXevxBr+0GpFRlVVN7W+kThf+9pUF+fCRPDWBVYwgQFFDDF0NOSAJR6eq2lR00QJqP+e2r09kABDcbYsVu0vIcyK2g1t23rR+oZQKxSL2563SUhYtXxRGY9Yp/KsXpBMQ1IXlbxkA6D3rqyhtZ6ALiUqj1sc5jtakHmEotxeQLX8rRlPSLS1nJBg== 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=rdlfWvzfISzn8kQMrAn9T5LiEAF04o/rwCujocnADxw=; b=IXVq0PRY97vbqkdlABG9j/WRWABQlNNAWlNAAWzy2nAsfB/4srQ/F6LJx2w8GlbduYBwzKvrKkWp46/P4u4cG4VPNeTHHQvc2J+fMqp1dsq+Sd/z0aU50A4o0KdjRlyuNXK3xx84S1plhLz4lUHDUJxv81Jxbq+5dZy+PT2L835xI1qL0oNqfSSkWF6Ii5VnH09n/0XGJEhHoirP8WE3vM9qtpyPgYa5SzH/fKnKOkjBVIGBQhpVxuMia/38xSW907g6nBL7j68yj8PExR9Nr5u7zadel/FXwbYgkS9gUvk1Ukx5cA6Jh1zVtspxrfFWHimoc4yr4LiuYk0HSC0pfQ== 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=rdlfWvzfISzn8kQMrAn9T5LiEAF04o/rwCujocnADxw=; b=RFQD3apXraqPVThbYvGDBOxB5begRzTu5PxoAOeWQV8W91o3U7HBpdTMmkrKtSCV/qLS67H2CC3lWBWBPfsglkROmxgpUjKoDb4zBvATHnOQYqo5+uB8q+3SiQpCH3pqzFd2e5n5Uq8O2S5Eal2mqgjSFVy769oJ+XzzHBXUUu0= Received: from PH8P221CA0015.NAMP221.PROD.OUTLOOK.COM (2603:10b6:510:2d8::20) by CH8PR12MB735095.namprd12.prod.outlook.com (2603:10b6:610:32c::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.688.12; Thu, 3 Dec 2026 11:08:25 +0000 Received: from PH3PEPF00059616.namprd05.prod.outlook.com (2603:10b6:510:2d8:cafe::96) by PH8P221CA0015.outlook.office365.com (2603:10b6:510:2d8::20) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.688.12 via Frontend Transport; Thu, 3 Dec 2026 11:08:25 +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 PH3PEPF00059616.mail.protection.outlook.com (10.167.243.20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.709.6 via Frontend Transport; Thu, 3 Dec 2026 11:08:25 +0000 Received: from satlexmb07.amd.com (10.181.42.216) 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; Thu, 3 Dec 2026 05:08:24 -0600 Received: from xhdipdslab46.xilinx.com (10.180.168.240) by satlexmb07.amd.com (10.181.42.216) with Microsoft SMTP Server id 15.2.2562.57 via Frontend Transport; Thu, 3 Dec 2026 05:08:22 -0600 From: Abhijit Gangurde To: , CC: , , , , "Abhijit Gangurde" Subject: [for-next v4 1/4] RDMA/ionic: Bound user queue depth and stride before shifting Date: Thu, 3 Dec 2026 16:38:02 +0530 Message-ID: <20261203110805.2577721-2-abhijit.gangurde@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261203110805.2577721-1-abhijit.gangurde@amd.com> References: <20261203110805.2577721-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: PH3PEPF00059616:EE_|CH8PR12MB735095:EE_ X-MS-Office365-Filtering-Correlation-Id: 136b0439-c03f-4ea4-097f-08df512dc04f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|36860700016|376014|23010399003|82310400026|18002099003|22082099003|10067099003|56012099006|261102123227099003|261021135927099003|261021121427099003|261009223027099003|11063799006; X-Microsoft-Antispam-Message-Info: XBfoY/KQBjFUFl9Su2zBBAUnZWANyu7JxaZMcSglgoSZrdJIAgG7NFagCiMvdgeWQW8QpDPt8h0k8n2N5BndDMcFZ0SUnhg+Oh+zRELuS4h311Mr33SvjzC1gZ5huK8fa2zKyBrVsyQTmErtnLxwnHXBXS1XoiQJzXpy3ubsEpId1/u50cBgDXmd71ONxeyh3VaQ3kPMgfgyWSNTqLO60Gy/0CIPa64Lgqyixm4jC841Wq0NEHzY9RU2HcuSi/H/iPtR32kKfIjReAwlp85pa9PiHUWAfreA8B5eCLk6VGtOb2qZ/UDT1Ikr4xuxYxOKAwbtxohSW8oRvOuJZWwcuJvynbWZbNfLVmyAvalU1bGFHy2m7UN6UpV+1NLGVWInna0R1sSgkBH+pkR1GJjhMrgVPo1/FP/lzDWOg01XIqQjhHNbdKdsGEGhFeuH7XeNYFoy2XdxL/NzMWmM3bJNQd/Z1VA1eGGiW3PV/J3I5hLhkUHLJmUPThK5601LX5J0C0e6j7ryGKK1MTO0KmSt4xL/PzYxkipZjCCmB+NNsVPmtBD72uq3KefAwwIqXeuLMaoufMInO4ugAhJKql+LaSDfULf+mzoTQ8qceiv88HxCm145Q6YPVGtw7HJI5UuU/7+zETUC3giwQj534BjigHllzm8xMz1mftt+QtHs2ZZxVT1SpBuAmtK9IMECV7ngRG13wqChxmSFoH8aeyCu6g== 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)(1800799024)(36860700016)(376014)(23010399003)(82310400026)(18002099003)(22082099003)(10067099003)(56012099006)(261102123227099003)(261021135927099003)(261021121427099003)(261009223027099003)(11063799006);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: GsvwuIoAsMLWHIZJPlqmfy0VHV2tDMFul7fOa1+iBGuPssw48eHw21568zREA4n3+0XWrtkcXW+NVCcCtIzD9eizxs8KDCVsJQ8VTOeJug/5noR55wExhQJfCisTpxnw5a8tHw2deqCQ/1XFqCpqmzxf4sFskrLbioV54UGe0kd+SjkdXZDLWgCQEKrJ9q0YKAql/ciddFmoF7vzvbIK3tV/pZVUVfHhHLdsN9bgJ5fXeh/Uc0AV8U8xvp0+SQTYNJYJ7s4JE730EuUJNnjQSEjQHK8DcTbwhOk1l3U6KRBIEficzdUrRNZcvfUyDirjrXHSlH6JZdJ1npy1hI1Y6dHiJsN19PZ++hOETNiBEWCUEfsiLuO2qhIk4t+TeC7DY4PrdTEBvH5QclCysbnFWMsgcpTTh1E+06tV8gSiPV7PR189zQXdAneUyGabjfxk X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Dec 2026 11:08:25.0911 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 136b0439-c03f-4ea4-097f-08df512dc04f 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: PH3PEPF00059616.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH8PR12MB735095 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") 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