Thread (28 messages) 28 messages, 3 authors, 2019-05-10

Re: [net-next][PATCH v2 1/2] rds: handle unsupported rdma request to fs dax memory

From: Leon Romanovsky <leon@kernel.org>
Date: 2019-05-01 17:28:30

On Mon, Apr 29, 2019 at 04:37:19PM -0700, Santosh Shilimkar wrote:
quoted hunk ↗ jump to hunk
From: Hans Westgaard Ry <redacted>

RDS doesn't support RDMA on memory apertures that require On Demand
Paging (ODP), such as FS DAX memory. User applications can try to use
RDS to perform RDMA over such memories and since it doesn't report any
failure, it can lead to unexpected issues like memory corruption when
a couple of out of sync file system operations like ftruncate etc. are
performed.

The patch adds a check so that such an attempt to RDMA to/from memory
apertures requiring ODP will fail.

Reviewed-by: Håkon Bugge <redacted>
Reviewed-tested-by: Zhu Yanjun [off-list ref]
Signed-off-by: Hans Westgaard Ry <redacted>
Signed-off-by: Santosh Shilimkar <redacted>
---
 net/rds/rdma.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/net/rds/rdma.c b/net/rds/rdma.c
index 182ab84..e0a6b72 100644
--- a/net/rds/rdma.c
+++ b/net/rds/rdma.c
@@ -158,8 +158,9 @@ static int rds_pin_pages(unsigned long user_addr, unsigned int nr_pages,
 {
 	int ret;

-	ret = get_user_pages_fast(user_addr, nr_pages, write, pages);
-
+	/* get_user_pages return -EOPNOTSUPP for fs_dax memory */
+	ret = get_user_pages_longterm(user_addr, nr_pages,
+				      write, pages, NULL);
I'm not RDS expert, but from what I see in net/rds/rdma.c and this code,
you tried to mimic ib_umem_get() without protection, checks and native
ODP, FS and DAX supports.

The real way to solve your ODP problem will require to extend
ib_umem_get() to work for kernel ULPs too and use it instead of
get_user_pages(). We are working on that and it is in internal review now.

It is applicable if underneath your RDS code, there is IB code, in case
there is no such layer, you shouldn't return IB_DEVICE_ON_DEMAND_PAGING
capability to user space and return EINVAL for every attempt to create
such ODP MR.

Thanks
 	if (ret >= 0 && ret < nr_pages) {
 		while (ret--)
 			put_page(pages[ret]);
--
1.9.1
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help