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=40.107.200.58 ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796296113; b=dgJKy/KTpVb/b+T0/pPxJFVY/TZB8dVp7ONu7zP4nvfSOSbSj3XtrhBAEZ43Ie0x28I9 mtTJoRTIUdCrXhUQKve3q2CW3YFMa/Xj8FMbpYCxXB7FIFecs7hMIIW7hzYz1vFibtjPn KCubxXKhGtE6xsPylCIoo2B/UFISR/zVBT+wiQrIKvn7jkAM9oOAaWXII70LBqCwADK5E w+EoiAEOyUb4HuSr3F7xwEv088zaVFqvMVMHVMs2XKoAN3Aq2yPhqbTs5RLEUUbYnbs1W 9oZD6V2w75B1RtbHuNmP1k5xrJG/XVOKsK7RKD+9mUP0uReamGdOfjACWst6A990lnA== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796296113; 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=Vn60Q+hPMBnbPY3VYVVhKY3JX/aoQgitO2wFCXwzVls=; b=yHOWBVCzH5uC0BE17kT7zR89LSp+buHljqLCBIMjNzL+3VdMCNu5gwc7zxekW7kaGq+k nPn4tAv792onwhZPoP02gJRG2yV9+7MF3kFgxvhP5LVie9o62vTVVkV3PFUb4XoXNFh5M jyjDMB1HpK8OU+7LPY2Yz7JxSxEMDQ3ReGTw7tDqoX8MQTHXv2J9a+ljZWWgBc40446lV ApTTSl26YBLJ47ywkVoNpRACQmV4nB2i77j/y9tUVMjOWlxZZS/lf1ZiAW2S3aqLMp1Wk SxazF40sdo4t/knjsy0XyC/nu1pp2Lt0ou9sOxA5xmjUHluFzlq84Ul8BWYHn8oSxgw== 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=BZIB9RAY; arc=pass header.oldest-pass=0 smtp.remote-ip=40.107.200.58 Received: from CH5PR02CU005.outbound.protection.outlook.com (mail-northcentralusazon11012058.outbound.protection.outlook.com [40.107.200.58]) (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 82354606A333; Thu, 3 Dec 2026 11:08:32 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 82354606A333 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=BZIB9RAY ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=XysfHJGCquM9KaOqHW1OO/+ZPGIEOsKJV4li0WrSuKShchThplynD3ZNKTmeadClHqz6xg1Tflo37gfNtzASY9Ghf2ZscGaue1IHuvhBLdTra9PJ7AHSrg94CfxHnoJn2P3J9z9RBpztAMuOOP5AwY1G4ezr4/n9naZ3imqNGCN3+3PPO7G++SQAipxSlnNiPYWaCmq5NYaQF12xDvjthGVkcXGkCPSJD5OkqrO8TM2u3s4OxSa1vkQ29u7Gd/CMwyaHZl83HGY6CbSNQnit7zTwSZkXfuPq/cSAqbR/KS1pbx0VsJ977bEGIMtEcZwZtLzjlsUPyDQUs7JAi4chrQ== 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=Vn60Q+hPMBnbPY3VYVVhKY3JX/aoQgitO2wFCXwzVls=; b=LYJc+60PqdDO8+Xlfx7JgUH+WF3URhsWoANJjB/2SN+ErDztF4pqBji35BuXh5tuEo2ViV7LXZUbdP5z2kTZSGg7mLhqDChzb6h5ItfoQpXdqDwKzTQK0E63Ak2pdhV36ukVV4uyzbiUBqgNz4wZLHuFD2kkqG2RVAYLWN34639xEYY/PRm6f8YTPKJLon0VGxvdi51elThQxK5uV6NqGCtFo5biT6wGO5vP8kF3cnfVVgkaPEly6+0MD0pwVe/x55PjJtlrfctBSTHt6mwnFRQJaJOe/Aadg1C99CG0gSFh4Y3TohnmVuA16tK4PHnTRGjEBDLh0Dd0VCRUrJL97w== 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=Vn60Q+hPMBnbPY3VYVVhKY3JX/aoQgitO2wFCXwzVls=; b=BZIB9RAYEkegY/XsKaiciOAWb6lCZr0H9zuedWeKpmFjtlXcGSQkrD/Exu1IV5eaTzq4GYJo1G5rBi3h0zDuCF5RqMLS4JIQiha2amggnJOWYq6yZRIIAxucc0MqoZlTRcjb6e98qzUbOgHIdUBroI0yHvE49FNzN1+DAH/BtBg= Received: from DS1P222CA0028.NAMP222.PROD.OUTLOOK.COM (2603:10b6:8:44b::11) by DS0PR12MB9400.namprd12.prod.outlook.com (2603:10b6:8:1b6::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.688.10; Thu, 3 Dec 2026 11:08:27 +0000 Received: from DSM2EPF0000000E.namprd02.prod.outlook.com (2603:10b6:8:44b:cafe::9c) by DS1P222CA0028.outlook.office365.com (2603:10b6:8:44b::11) 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:27 +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=satlexmb07.amd.com; pr=C Received: from satlexmb07.amd.com (165.204.84.17) by DSM2EPF0000000E.mail.protection.outlook.com (10.167.23.8) 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:27 +0000 Received: from satlexmb07.amd.com (10.181.42.216) by satlexmb07.amd.com (10.181.42.216) 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:26 -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:25 -0600 From: Abhijit Gangurde To: , CC: , , , , "Abhijit Gangurde" Subject: [for-next v4 2/4] RDMA/ionic: Check user ring alignment on the pinned umem Date: Thu, 3 Dec 2026 16:38:03 +0530 Message-ID: <20261203110805.2577721-3-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: DSM2EPF0000000E:EE_|DS0PR12MB9400:EE_ X-MS-Office365-Filtering-Correlation-Id: 5a5970bc-3f8a-473f-7f16-08df512dc1b5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|23010399003|36860700016|1800799024|376014|11063799006|261009223027099003|18002099003|22082099003|261022105027099003|10067099003|56012099006|261102123227099003|261026140227099003|261021135927099003|261021121427099003|261021123027099003|261028144727099003; X-Microsoft-Antispam-Message-Info: wuu29X/X+OTJ8QzWxgnB4F/eertah0XIJEO8H0lqGOuwU9tBWNS3RH1L8tV+NY3p/ZazTLehGH5thE5P6v+f4/0IWxqWSJwGCfM0sqNljdbqHzslBapOaM08BXnozVhAgaab3o0KyO3KWK09SDa0zbm80eab1Rw/SSuU4Krg0irJOWoR0cFPtjHNcXiAjvvrhga9Tn3c3wYi1l+Koh7cdr8cHpcQ1Fp2XowSLs0z+Mw9YjEcXZA5CLaeKRi616N3TWIfbatPZtFKI3SazIXQedzGBYJPl0JmnX4dI6sVFcnWMfIswhoe/AmqCtWe1R31SGruKj7MJ6hufAgmn4pA1R03qeTYz+HlyK2yeApmgrORTbFBXifgpTm3JDi0G/v9ClmuxM6yrQnm8ztmS+RD1w+Ta7bHCmebyTapcVOlNa4vUhUtoRtVDzv6XEqr/a2wAqMDNV6t1Ef6JufXH2OJ1Zgj8C3szTbVXnjUNuAlh4SW/IYfTHwnpsI48Nne2AgVLLN+JN0vRUcYIyB1rOo7u6ui8cib6ir9SyySmP3ZdTHaN/7nFtmLh13Umb0VlqDhHq5/fO+A0EX7hQIq8K/i+V7od+XqQgYMpC81WdN4Gib83FPxG5y/ee2LNrSNEUobzGv1xFYML/rRhUjB6S/hAQsXgsChI275rYbKdZ/CIlhnPpRkeQwHrEA3IMchN81n+X8bSktqfce9pXnvbzg61Q== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:satlexmb07.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(82310400026)(23010399003)(36860700016)(1800799024)(376014)(11063799006)(261009223027099003)(18002099003)(22082099003)(261022105027099003)(10067099003)(56012099006)(261102123227099003)(261026140227099003)(261021135927099003)(261021121427099003)(261021123027099003)(261028144727099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: g0BfM8B0reoXzbOAXyBcOqfWm6dHxqwyd971I77fwD+KnIG43tpUF6B/ml5WFGXyHuEbzJy27gc3E33+tZW7pLOfoFTaSS60w+PWihPQid+cFvSQGx2fHsN6hSeZSFEH0xRJV5G1LoSFHFiChjgqFZKT7o35TT2D9vWfvh9TlylNO3BPFFFOeEHET39h8gQKCI7CnV+46Z6gVJ/fhtoHEH7W6LXoGZKX/KLzidubipIukbVE1TLffPH5TckJzP1QyljgD7qA+ZzwFRc+vrVr9a0Vmx4Eqoj/liPYubn025YNe0xAWH5Ez70JxIhSuSduN+kzKKi8QWa5pfzrpib3dH4hEr2bOT5pxqZn9/Gg+dP6yPWp9Ob18cP3N63CRKBhhD7yG7W1QOefDRZTJPBLdm07nkhtNi4TxwXjyZHPuJNa3dQIRhCHM7mPphwcwjk4 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Dec 2026 11:08:27.4411 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5a5970bc-3f8a-473f-7f16-08df512dc1b5 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=[satlexmb07.amd.com] X-MS-Exchange-CrossTenant-AuthSource: DSM2EPF0000000E.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB9400 ionic_validate_qdesc() rejects a user CQ, SQ or RQ ring when the address in the request is zero or not page aligned. That only works while the request address is the one place a ring can come from. Check the pinned umem instead. Add ionic_cq_get_user_umem() and ionic_get_user_q_umem(), which validate the queue geometry, pin the ring and reject it with -EINVAL when ib_umem_offset() is not zero. ionic_validate_qdesc() no longer looks at the address. A ring that is not page aligned is still rejected with -EINVAL. A zero address is no longer special-cased. Like any other unmapped address, it fails with -EFAULT when the ring is pinned. This prepares for rings passed as ioctl umem attributes, where the buffer is described by the attribute and not by the request address. Signed-off-by: Abhijit Gangurde --- .../infiniband/hw/ionic/ionic_controlpath.c | 79 +++++++++++++------ 1 file changed, 54 insertions(+), 25 deletions(-) diff --git a/drivers/infiniband/hw/ionic/ionic_controlpath.c b/drivers/infiniband/hw/ionic/ionic_controlpath.c index 717ab78b603c..3abb8c01daf6 100644 --- a/drivers/infiniband/hw/ionic/ionic_controlpath.c +++ b/drivers/infiniband/hw/ionic/ionic_controlpath.c @@ -14,13 +14,9 @@ #define ionic_set_ecn(tos) (((tos) | 2u) & ~1u) #define ionic_clear_ecn(tos) ((tos) & ~3u) -static int ionic_validate_qdesc(struct ionic_qdesc *q) +static int ionic_validate_qdesc(const struct ionic_qdesc *q) { - if (!q->addr || !q->size || !q->mask || - !q->depth_log2 || !q->stride_log2) - return -EINVAL; - - if (q->addr & (PAGE_SIZE - 1)) + if (!q->size || !q->mask || !q->depth_log2 || !q->stride_log2) return -EINVAL; /* Keep the shift counts below within the width of their types */ @@ -80,6 +76,31 @@ static void ionic_put_cqid(struct ionic_ibdev *dev, u32 cqid) ionic_resid_put(&dev->inuse_cqid, bitid); } +static int ionic_cq_get_user_umem(struct ionic_ibdev *dev, struct ionic_cq *cq, + const struct ionic_qdesc *req_cq) +{ + struct ib_umem *umem; + int rc; + + rc = ionic_validate_qdesc(req_cq); + if (rc) + return rc; + + umem = ib_umem_get_cq_buf_or_va(&dev->ibdev, NULL, req_cq->addr, + req_cq->size, IB_ACCESS_LOCAL_WRITE); + if (IS_ERR(umem)) + return PTR_ERR(umem); + + /* The ring is given to the device as whole pages */ + if (ib_umem_offset(umem)) { + ib_umem_release(umem); + return -EINVAL; + } + + cq->umem = umem; + return 0; +} + int ionic_create_cq_common(struct ionic_vcq *vcq, struct ionic_tbl_buf *buf, const struct ib_cq_init_attr *attr, @@ -113,18 +134,10 @@ int ionic_create_cq_common(struct ionic_vcq *vcq, INIT_LIST_HEAD(&cq->flush_rq); if (udata) { - rc = ionic_validate_qdesc(req_cq); + rc = ionic_cq_get_user_umem(dev, cq, req_cq); if (rc) goto err_qdesc; - cq->umem = ib_umem_get_cq_buf_or_va(&dev->ibdev, NULL, - req_cq->addr, req_cq->size, - IB_ACCESS_LOCAL_WRITE); - if (IS_ERR(cq->umem)) { - rc = PTR_ERR(cq->umem); - goto err_qdesc; - } - cq->q.ptr = NULL; cq->q.size = req_cq->size; cq->q.mask = req_cq->mask; @@ -1963,6 +1976,30 @@ static void ionic_qp_sq_destroy_cmb(struct ionic_ibdev *dev, ionic_put_cmb(dev->lif_cfg.lif, qp->sq_cmb_pgid, qp->sq_cmb_order); } +static int ionic_get_user_q_umem(struct ionic_ibdev *dev, struct ionic_qdesc *q, + struct ib_umem **umem_out) +{ + struct ib_umem *umem; + int rc; + + rc = ionic_validate_qdesc(q); + if (rc) + return rc; + + umem = ib_umem_get_va(&dev->ibdev, q->addr, q->size, 0); + if (IS_ERR(umem)) + return PTR_ERR(umem); + + /* The ring is given to the device as whole pages */ + if (ib_umem_offset(umem)) { + ib_umem_release(umem); + return -EINVAL; + } + + *umem_out = umem; + return 0; +} + static int ionic_qp_sq_init(struct ionic_ibdev *dev, struct ionic_ctx *ctx, struct ionic_qp *qp, struct ionic_qdesc *sq, struct ionic_tbl_buf *buf, int max_wr, int max_sge, @@ -2010,7 +2047,7 @@ static int ionic_qp_sq_init(struct ionic_ibdev *dev, struct ionic_ctx *ctx, return rc; if (udata) { - rc = ionic_validate_qdesc(sq); + rc = ionic_get_user_q_umem(dev, sq, &qp->sq_umem); if (rc) return rc; @@ -2024,10 +2061,6 @@ static int ionic_qp_sq_init(struct ionic_ibdev *dev, struct ionic_ctx *ctx, qp->sq_meta = NULL; qp->sq_msn_idx = NULL; - - qp->sq_umem = ib_umem_get_va(&dev->ibdev, sq->addr, sq->size, 0); - if (IS_ERR(qp->sq_umem)) - return PTR_ERR(qp->sq_umem); } else { qp->sq_umem = NULL; @@ -2247,7 +2280,7 @@ static int ionic_rq_init(struct ionic_ibdev *dev, struct ionic_ctx *ctx, return rc; if (udata) { - rc = ionic_validate_qdesc(qdesc); + rc = ionic_get_user_q_umem(dev, qdesc, &rq->umem); if (rc) return rc; @@ -2260,10 +2293,6 @@ static int ionic_rq_init(struct ionic_ibdev *dev, struct ionic_ctx *ctx, rq->q.stride_log2 = qdesc->stride_log2; rq->meta = NULL; - - rq->umem = ib_umem_get_va(&dev->ibdev, qdesc->addr, qdesc->size, 0); - if (IS_ERR(rq->umem)) - return PTR_ERR(rq->umem); } else { rq->umem = NULL; -- 2.43.0