The patch titled Subject: mm/rmap: fix signedness bug in make_device_exclusive_range() has been added to the -mm tree. Its filename is mm-device-exclusive-memory-access-fix.patch This patch should soon appear at https://ozlabs.org/~akpm/mmots/broken-out/mm-device-exclusive-memory-access-fix.patch and later at https://ozlabs.org/~akpm/mmotm/broken-out/mm-device-exclusive-memory-access-fix.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next and is updated there every 3-4 working days ------------------------------------------------------ From: Dan Carpenter <dan.carpenter@xxxxxxxxxx> Subject: mm/rmap: fix signedness bug in make_device_exclusive_range() The get_user_pages_remote() function returns a long type, but we are using "unsigned long i;" as the list iterator. If "npages" is -ENOMEM, the comparison "i < npages" is type promoted and "npages" becomes a very high positive value. The loop will then iterate until the kernel crashes. There are two ways to fix this. Declare "i" as a long type or add an explicit check for get_user_pages_remote() error returns. Either approach will work so let's do both. Link: https://lkml.kernel.org/r/YNIz5NVnZ5GiZ3u1@mwanda Fixes: fa1e686e5f53 ("mm: device exclusive memory access") Signed-off-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx> Reviewed-by: Peter Xu <peterx@xxxxxxxxxx> Cc: Alistair Popple <apopple@xxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- mm/rmap.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) --- a/mm/rmap.c~mm-device-exclusive-memory-access-fix +++ a/mm/rmap.c @@ -2187,11 +2187,14 @@ int make_device_exclusive_range(struct m void *owner) { long npages = (end - start) >> PAGE_SHIFT; - unsigned long i; + long i; npages = get_user_pages_remote(mm, start, npages, FOLL_GET | FOLL_WRITE | FOLL_SPLIT_PMD, pages, NULL, NULL); + if (npages < 0) + return npages; + for (i = 0; i < npages; i++, start += PAGE_SIZE) { if (!trylock_page(pages[i])) { put_page(pages[i]); _ Patches currently in -mm which might be from dan.carpenter@xxxxxxxxxx are ocfs2-fix-snprintf-checking.patch mm-thp-refactor-numa-fault-handling-fix.patch mm-device-exclusive-memory-access-fix.patch