Skip to content

Commit 0103bd1

Browse files
koct9itorvalds
authored andcommitted
mm: prepare VM_DONTDUMP for using in drivers
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>
1 parent e9714ac commit 0103bd1

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

fs/binfmt_elf.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1123,7 +1123,7 @@ static unsigned long vma_dump_size(struct vm_area_struct *vma,
11231123
if (always_dump_vma(vma))
11241124
goto whole;
11251125

1126-
if (vma->vm_flags & VM_NODUMP)
1126+
if (vma->vm_flags & VM_DONTDUMP)
11271127
return 0;
11281128

11291129
/* Hugetlb memory check */

include/linux/mm.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ extern unsigned int kobjsize(const void *objp);
102102
#define VM_HUGETLB 0x00400000 /* Huge TLB Page VM */
103103
#define VM_NONLINEAR 0x00800000 /* Is non-linear (remap_file_pages) */
104104
#define VM_ARCH_1 0x01000000 /* Architecture-specific flag */
105-
#define VM_NODUMP 0x04000000 /* Do not include in the core dump */
105+
#define VM_DONTDUMP 0x04000000 /* Do not include in the core dump */
106106

107107
#define VM_MIXEDMAP 0x10000000 /* Can contain "struct page" and pure PFN pages */
108108
#define VM_HUGEPAGE 0x20000000 /* MADV_HUGEPAGE marked this vma */

mm/madvise.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,14 @@ static long madvise_behavior(struct vm_area_struct * vma,
6969
new_flags &= ~VM_DONTCOPY;
7070
break;
7171
case MADV_DONTDUMP:
72-
new_flags |= VM_NODUMP;
72+
new_flags |= VM_DONTDUMP;
7373
break;
7474
case MADV_DODUMP:
75-
new_flags &= ~VM_NODUMP;
75+
if (new_flags & VM_SPECIAL) {
76+
error = -EINVAL;
77+
goto out;
78+
}
79+
new_flags &= ~VM_DONTDUMP;
7680
break;
7781
case MADV_MERGEABLE:
7882
case MADV_UNMERGEABLE:

0 commit comments

Comments
 (0)