mm: prepare VM_DONTDUMP for using in drivers
authorKonstantin Khlebnikov <khlebnikov@openvz.org>
Mon, 8 Oct 2012 23:28:59 +0000 (16:28 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Tue, 9 Oct 2012 07:22:18 +0000 (16:22 +0900)
Rename VM_NODUMP into VM_DONTDUMP: this name matches other negative flags:
VM_DONTEXPAND, VM_DONTCOPY.  Currently this flag used only for
sys_madvise.  The next patch will use it for replacing the outdated flag
VM_RESERVED.

Also forbid madvise(MADV_DODUMP) for special kernel mappings VM_SPECIAL
(VM_IO | VM_DONTEXPAND | VM_RESERVED | VM_PFNMAP)

Signed-off-by: Konstantin Khlebnikov <khlebnikov@openvz.org>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>
Cc: Carsten Otte <cotte@de.ibm.com>
Cc: Chris Metcalf <cmetcalf@tilera.com>
Cc: Cyrill Gorcunov <gorcunov@openvz.org>
Cc: Eric Paris <eparis@redhat.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Hugh Dickins <hughd@google.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: James Morris <james.l.morris@oracle.com>
Cc: Jason Baron <jbaron@redhat.com>
Cc: Kentaro Takeda <takedakn@nttdata.co.jp>
Cc: Matt Helsley <matthltc@us.ibm.com>
Cc: Nick Piggin <npiggin@kernel.dk>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Robert Richter <robert.richter@amd.com>
Cc: Suresh Siddha <suresh.b.siddha@intel.com>
Cc: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Cc: Venkatesh Pallipadi <venki@google.com>
Acked-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
fs/binfmt_elf.c
include/linux/mm.h
mm/madvise.c

index 28a64e76952788146d24b4fe0e0069918c0b9584..2b72d26e2e4b5da6809d5dc9fad2783aa2d99475 100644 (file)
@@ -1123,7 +1123,7 @@ static unsigned long vma_dump_size(struct vm_area_struct *vma,
        if (always_dump_vma(vma))
                goto whole;
 
-       if (vma->vm_flags & VM_NODUMP)
+       if (vma->vm_flags & VM_DONTDUMP)
                return 0;
 
        /* Hugetlb memory check */
index 25ef49c1f2bd553f00f4357d6c515baaebf9623a..dc08d558e058d8a5e2ea94564edd2da42add2b76 100644 (file)
@@ -102,7 +102,7 @@ extern unsigned int kobjsize(const void *objp);
 #define VM_HUGETLB     0x00400000      /* Huge TLB Page VM */
 #define VM_NONLINEAR   0x00800000      /* Is non-linear (remap_file_pages) */
 #define VM_ARCH_1      0x01000000      /* Architecture-specific flag */
-#define VM_NODUMP      0x04000000      /* Do not include in the core dump */
+#define VM_DONTDUMP    0x04000000      /* Do not include in the core dump */
 
 #define VM_MIXEDMAP    0x10000000      /* Can contain "struct page" and pure PFN pages */
 #define VM_HUGEPAGE    0x20000000      /* MADV_HUGEPAGE marked this vma */
index 14d260fa0d17939a2279c244df91789cd30720e4..03dfa5c7adb3c41acdf672b6504516073866c996 100644 (file)
@@ -69,10 +69,14 @@ static long madvise_behavior(struct vm_area_struct * vma,
                new_flags &= ~VM_DONTCOPY;
                break;
        case MADV_DONTDUMP:
-               new_flags |= VM_NODUMP;
+               new_flags |= VM_DONTDUMP;
                break;
        case MADV_DODUMP:
-               new_flags &= ~VM_NODUMP;
+               if (new_flags & VM_SPECIAL) {
+                       error = -EINVAL;
+                       goto out;
+               }
+               new_flags &= ~VM_DONTDUMP;
                break;
        case MADV_MERGEABLE:
        case MADV_UNMERGEABLE: