[3.19.y-ckt stable] Patch "drivers/scsi/sg.c: mark VMA as VM_IO to prevent migration" has been added to the 3.19.y-ckt tree

Kamal Mostafa kamal at canonical.com
Wed Mar 9 00:22:17 UTC 2016


This is a note to let you know that I have just added a patch titled

    drivers/scsi/sg.c: mark VMA as VM_IO to prevent migration

to the linux-3.19.y-queue branch of the 3.19.y-ckt extended stable tree 
which can be found at:

    http://kernel.ubuntu.com/git/ubuntu/linux.git/log/?h=linux-3.19.y-queue

This patch is scheduled to be released in version 3.19.8-ckt16.

If you, or anyone else, feels it should not be added to this tree, please 
reply to this email.

For more information about the 3.19.y-ckt tree, see
https://wiki.ubuntu.com/Kernel/Dev/ExtendedStable

Thanks.
-Kamal

---8<------------------------------------------------------------

>From 1ef2c0583b9ffed0a8d3b42ece5a495838b87c30 Mon Sep 17 00:00:00 2001
From: "Kirill A. Shutemov" <kirill.shutemov at linux.intel.com>
Date: Tue, 2 Feb 2016 16:57:35 -0800
Subject: drivers/scsi/sg.c: mark VMA as VM_IO to prevent migration

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.shutemov at linux.intel.com>
Reported-by: Dmitry Vyukov <dvyukov at google.com>
Acked-by: Vlastimil Babka <vbabka at suse.cz>
Cc: Doug Gilbert <dgilbert at interlog.com>
Cc: David Rientjes <rientjes at google.com>
Cc: Naoya Horiguchi <n-horiguchi at ah.jp.nec.com>
Cc: "Kirill A. Shutemov" <kirill.shutemov at linux.intel.com>
Cc: Shiraz Hashim <shashim at codeaurora.org>
Cc: Hugh Dickins <hughd at google.com>
Cc: Sasha Levin <sasha.levin at oracle.com>
Cc: syzkaller <syzkaller at googlegroups.com>
Cc: Kostya Serebryany <kcc at google.com>
Cc: Alexander Potapenko <glider at google.com>
Cc: James Bottomley <James.Bottomley at HansenPartnership.com>
Signed-off-by: Andrew Morton <akpm at linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds at linux-foundation.org>
Signed-off-by: Kamal Mostafa <kamal at 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 9b6e7cb..58d5fa72 100644
--- a/drivers/scsi/sg.c
+++ b/drivers/scsi/sg.c
@@ -1270,7 +1270,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





More information about the kernel-team mailing list