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.61.60 ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796385012; b=JyrLHTdVQ+xcGq18yCRP6fr95Iz+emmOF2JJIDUpS9Ke8D5e+0ZvwAAcuVSzTSd2k+Cz w4NotXEY76Z1WoRWyydgHoD2AT9fJBxLweTnn+M3GJSWq05eC7TP2VUM+q8v+r9cbEQTA m88VvK6Y3tlEY71KQ5XFORWqitW/h3bS/GVZv5fELEkjhluVgI404bcyMs7KGvz8TzNUw 4ZUfVVmd+pieIboVTUSpfxz7Vpf+12kaTKQTMygTrWI0ueMk4riPzIFhBrWMgkLmj/Elw B8ppuamv4TKaZP9bm73Jy5yvl/osQtLAeI7T1RFnqUMM9xXcVGFmSPlsoqNwFBFOqsA== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796385012; 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=QJgAqMguS/IF5+89UX4Q6YBpauBk7iTNtrZsUgCZXJg=; b=0u0d039obSAHmx1iQL296XwE7hYk/72AkwR2008rJvg23ZcB39LcnDy1KXFeTKtoxJBL YO+aopCnU7ypWsXAP8+ttbjuao7VGn8NmwIUUkrqtKM6BZ1tRVzryxhgiAxLN+G5/S61Y MY7iKf5Cyxpfdg3vscEnH/l4UkT4JqTSchp25YqVvUbK54KkxC0gDpn+3DNe112Aac9sn 4IhiPMtXcMu40Pz2CEWD1cTuHjtgivt3nL8RUPHQzOMTYlvcAUcAaMwpK0EkZJA9P04b0 AWHPdm27dSaJEnzug4xQl/Q4uQF3KF01KGrOkLU69ExjFBIwZBNPx9CwVWVSRKGHf7w== 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=K89UPwh5; arc=pass header.oldest-pass=0 smtp.remote-ip=52.101.61.60 Received: from DM1PR04CU001.outbound.protection.outlook.com (mail-centralusazon11010060.outbound.protection.outlook.com [52.101.61.60]) (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 72BE8606A32D; Fri, 4 Dec 2026 11:50:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 72BE8606A32D 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=K89UPwh5 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=KKUJkQlkL85YkJK+0AtfnCcUjT0R0/tcb60ZIKf35l4EzC/Ma9D4P5b+DlVMBYxskwAthKhju1MRXtadzKW6pJwhGYhMXwrwmTo2O7OEiYq6z3uFz9WKhztBQRPIgWA0C8qzV2iD8N00O4UgHiG1yZzm1u7N6/yIb1M0PtdlEr1ZuWQPmLY/Z64qis5I9E1T6ZknOC2nDgXTc3ExcjLstLoLCUUgZOgmH6oP4I1ImsuPeLd22iorXEjSrY6Aj/EC9bdaZ/JKX7pETtmToThETAWAcDdtPmG2iekT2qTkMqMCJcUCop7QQb3DmPqHq+alWxUOXCaEikorVI2wKaPk4A== 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=QJgAqMguS/IF5+89UX4Q6YBpauBk7iTNtrZsUgCZXJg=; b=LSEIXCoRDzbyJDTEnlD1AJXkxL/9T/Tsr9iTWWv/TxxzxVyslEWfd2GSpxRucpls6GFuTGTZKPO8pWGkES1AOpt4Ffp6NgMLzqSSH3xQd5qhFbArCqR4uHkat0DsMvH9T9d4ZJIHvlk1hjrZTHBOpkcWUkUC7iSUJaTj6nARtGcLq26/BxCi0hYw7ucLPGunCzLvN/gc0TJ8gDGtGucSUFgAuFZYslQi8swwSWYaBEjSbJaJ/6L0XGMznN1Y9p8xURGJqHI62NuEMicnkTyR7Zqa8RgOWm/gvTb4O8THizVGatSJkeHDcYhi36DeUzTMsdc8u9JZxchk/UNtbFGEUw== 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=QJgAqMguS/IF5+89UX4Q6YBpauBk7iTNtrZsUgCZXJg=; b=K89UPwh5NlXFGi7HGe+EX6gAZ3uSZdGYRJQKJNcixGTbDgBjOQ4nB5iLWWniKm1CuYnT6A/fVQhVT5jWUfaQkObKNLiJ7FaxYh9pnVvIqw0HdXIbtgFyQD8iaUecm29dmKoXuk5+lGENjJCd9OWCl6TNFF1mxJ+SDZIkz6cX8oQ= Received: from PH1PEPF00013312.namprd07.prod.outlook.com (2603:10b6:518:1::d) by LV0PR12MB259608.namprd12.prod.outlook.com (2603:10b6:408:3ef::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:07 +0000 Received: from SJ5PEPF000001EC.namprd05.prod.outlook.com (2a01:111:f403:c902::) by PH1PEPF00013312.outlook.office365.com (2603:1036:903:47::9) 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:07 +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 SJ5PEPF000001EC.mail.protection.outlook.com (10.167.242.200) 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:07 +0000 Received: from Satlexmb09.amd.com (10.181.42.218) 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; Fri, 4 Dec 2026 05:50:04 -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:03 -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:50:01 -0600 From: Abhijit Gangurde To: , CC: , , , , "Abhijit Gangurde" , Jiri Pirko Subject: [for-next v5 2/4] RDMA/ionic: Check user ring alignment on the pinned umem Date: Fri, 4 Dec 2026 17:19:41 +0530 Message-ID: <20261204114943.3530599-3-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: SJ5PEPF000001EC:EE_|LV0PR12MB259608:EE_ X-MS-Office365-Filtering-Correlation-Id: c3cacee6-3eda-4b18-23b9-08df51fcbe05 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|36860700016|1800799024|23010399003|82310400026|18002099003|22082099003|10067099003|56012099006|261028144727099003|261026140227099003|261022105027099003|261021135927099003|261021121427099003|261102123227099003|261021123027099003|261009223027099003|11063799006; X-Microsoft-Antispam-Message-Info: wm3b7C2wtp5rcfuzRM4Ob+J/orUGxd/rzqobcbn/spo5sGsxlHfKBDy9IhuBvqH/ON0NVIVaLrP8XJAAs+wEGu+aLdsWolcCWA1YY4/R/z09b1hXxFkeSvZs4ie1byi2gUzVMH6IvfXwX4w3czksUFmqVQpqQm33Zpp72DmZK/lSG6FoG18rz1F8mFW+B4lrZJWrGyAWxUpuIprgX1YK1n4nC1nyKxyVwyjEHN/Y6ORWH2YG98O8/pWQ49BHUVwTLQZWKe2wKhGgjxh0vUOX0eDwpnbTTh4SY8VSveakAukbeu7IjWRhKfXFLwvsAUmUWk4s0vfV0YjMNdwZbl/nZ5AkmlHWqtgZH50/d0d272hc9jiQ6/GchiLw8U8Lm8pEGdrLA1/pyaUnd6X6NdQai3CA9l5ANU1G+iU4icnZ0+pXgGrKw7c7KrtA2EJ81TGYl34+0Z0INyD6NG/tjCoyJ3QIs1fsfP93fNZeiTI4+VZKmz4KXm6RIDJw92R37CpbCKuD2YV/7CYBJlx9o21RYE7YDI4SijRh0541J0MUkI/d4mplnQhd4Gy+6ZyZSZ+2gHww/M6leQcEHpJxN3LoZp7JW96yvHb60/MzZHDM8ZQV6nhAfYjNzn9QE/SFTFgt5WgWeMgQ3jEukppw8CVdHMSC/89JJJjrd4I1lC85PB9IOlK8r4YQVR52aAeIoWrU4E2qvJb7+1zBnRN3cooxqw== 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)(376014)(36860700016)(1800799024)(23010399003)(82310400026)(18002099003)(22082099003)(10067099003)(56012099006)(261028144727099003)(261026140227099003)(261022105027099003)(261021135927099003)(261021121427099003)(261102123227099003)(261021123027099003)(261009223027099003)(11063799006);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: dSHFRUktu0+k32/JQkirTE044jCgqXBrCRmpFUoG7djRXH0Dm+AZ3auDdvr0FoZqppGGWrtx2U9L9xMcaGxxfLhkazNgJZzL9LHU4mSlone1Ljrqj3Tlyv+T5lLPOFU1mhrfE6DosFHn3lQz4eDBei/S2Elv4xD+wISqkD0/5s/wXNvs8MoYbOH+u2AazzVc97Gf7AqUxL8pFZYX1PjeWk1d/b1XTo6KSru+ef3A1qQPXzOmx72peVfkohLjcUNBneIV4MJxrntvJcbSjVXapYBXV1MShv4IIp73wig/Ikr5pjKr32O++cSsK/8tepqTJa6YxTrqMT3rpUPA2u/jaKXPH69TzfgpkZAuKncnDkAJlBlJROmlo+SJ8WA2w3HMXcNxXFR7cYhVJ4EPQtnv7QsRpQOHqAP4xKpxa5QGA62AKGau5A4Ir3POGaSFO3V8 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Dec 2026 11:50:07.0509 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c3cacee6-3eda-4b18-23b9-08df51fcbe05 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: SJ5PEPF000001EC.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV0PR12MB259608 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. Reviewed-by: Jiri Pirko 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