Skip to content

Commit 09ad94c

Browse files
Hans Westgaard RySomasundaram Krishnasamy
authored andcommitted
rds: Handle unsupported rdma request to fs dax memory
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 because of other processes can issue file operations like ftruncate while memory is registered for RDMA. The patch adds a check so that such an attempt to RDMA to/from memory apertures requiring ODP will fail. Using 'get_user_pages_longterm' instead of 'get_user_pages_fast' when allocating memory gives us checking for FS DAX memory. 'get_user_pages_longterm' will fail with errorcode -ENOTSUPP if FS DAX memory is detected. Orabug: 30731395 Signed-off-by: Hans Westgaard Ry <[email protected]> Reviewed-by: Santosh Shilimkar <[email protected]> Signed-off-by: Somasundaram Krishnasamy <[email protected]>
1 parent a61ccaa commit 09ad94c

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

net/rds/rdma.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
#include <linux/pagemap.h>
3434
#include <linux/rbtree.h>
3535
#include <linux/dma-mapping.h> /* for DMA_*_DEVICE */
36-
36+
#include <linux/sched/mm.h>
3737
#include "rds.h"
3838

3939
/*
@@ -163,14 +163,19 @@ static int rds_pin_pages(unsigned long user_addr, unsigned int nr_pages,
163163
struct page **pages, int write)
164164
{
165165
int ret;
166+
struct mm_struct *mm = current->mm;
166167

167-
ret = get_user_pages_fast(user_addr, nr_pages, write, pages);
168+
mmgrab(mm);
169+
down_read(&mm->mmap_sem);
170+
ret = get_user_pages_longterm(user_addr, nr_pages, write, pages, NULL);
168171

169172
if (ret >= 0 && (unsigned) ret < nr_pages) {
170173
while (ret--)
171174
put_page(pages[ret]);
172175
ret = -EFAULT;
173176
}
177+
up_read(&mm->mmap_sem);
178+
mmdrop(mm);
174179

175180
return ret;
176181
}

0 commit comments

Comments
 (0)