4.2.8-ckt5 -stable review patch. If anyone has any objections, please let me know.
---8<------------------------------------------------------------ From: "Kirill A. Shutemov" <kirill.shute...@linux.intel.com> commit 461c7fa126794157484dca48e88effa4963e3af3 upstream. Reduced testcase: #include <fcntl.h> #include <unistd.h> #include <sys/mman.h> #include <numaif.h> #define SIZE 0x2000 int main() { int fd; void *p; fd = open("/dev/sg0", O_RDWR); p = mmap(NULL, SIZE, PROT_EXEC, MAP_PRIVATE | MAP_LOCKED, fd, 0); mbind(p, SIZE, 0, NULL, 0, MPOL_MF_MOVE); return 0; } We shouldn't try to migrate pages in sg VMA as we don't have a way to update Sg_scatter_hold::pages accordingly from mm core. Let's mark the VMA as VM_IO to indicate to mm core that the VMA is not migratable. Signed-off-by: Kirill A. Shutemov <kirill.shute...@linux.intel.com> Reported-by: Dmitry Vyukov <dvyu...@google.com> Acked-by: Vlastimil Babka <vba...@suse.cz> Cc: Doug Gilbert <dgilb...@interlog.com> Cc: David Rientjes <rient...@google.com> Cc: Naoya Horiguchi <n-horigu...@ah.jp.nec.com> Cc: "Kirill A. Shutemov" <kirill.shute...@linux.intel.com> Cc: Shiraz Hashim <shas...@codeaurora.org> Cc: Hugh Dickins <hu...@google.com> Cc: Sasha Levin <sasha.le...@oracle.com> Cc: syzkaller <syzkal...@googlegroups.com> Cc: Kostya Serebryany <k...@google.com> Cc: Alexander Potapenko <gli...@google.com> Cc: James Bottomley <james.bottom...@hansenpartnership.com> Signed-off-by: Andrew Morton <a...@linux-foundation.org> Signed-off-by: Linus Torvalds <torva...@linux-foundation.org> Signed-off-by: Kamal Mostafa <ka...@canonical.com> --- drivers/scsi/sg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c index 9d7b7db..3bbf485 100644 --- a/drivers/scsi/sg.c +++ b/drivers/scsi/sg.c @@ -1255,7 +1255,7 @@ sg_mmap(struct file *filp, struct vm_area_struct *vma) } sfp->mmap_called = 1; - vma->vm_flags |= VM_DONTEXPAND | VM_DONTDUMP; + vma->vm_flags |= VM_IO | VM_DONTEXPAND | VM_DONTDUMP; vma->vm_private_data = sfp; vma->vm_ops = &sg_mmap_vm_ops; return 0; -- 2.7.0