From: Jason Baron <jbaron@redhat.com>
To: mcgrathr@google.com
Cc: akpm@linux-foundation.org, avi@redhat.com,
linux-kernel@vger.kernel.org, qemu-devel@nongnu.org
Subject: [PATCH 2/2] core dump: add a new VM_DONTDUMP flag
Date: Wed, 7 Mar 2012 12:00:53 -0500 [thread overview]
Message-ID: <fcc863c3e95eb29cd60360d84fbc85ebd07ef843.1331137504.git.jbaron@redhat.com> (raw)
In-Reply-To: <cover.1331137504.git.jbaron@redhat.com>
Since we no longer need the VM_ALWAYSDUMP flag, let's use the freed bit for
'VM_DONTDUMP' flag. The idea is to add a new madvise() flag: MADV_DONTDUMP,
which can be set by applications to specifically request memory regions which
should not dump core. The specific application I have in mind is qemu: we
can add a flag there that wouldn't dump all of guest memory when qemu dumps
core. This flag might also be useful for security sensitive apps that want to
absolutely make sure that parts of memory are not dumped.
Signed-off-by: Jason Baron <jbaron@redhat.com>
---
fs/binfmt_elf.c | 3 +++
include/asm-generic/mman-common.h | 3 +++
include/linux/mm.h | 1 +
mm/madvise.c | 8 ++++++++
4 files changed, 15 insertions(+), 0 deletions(-)
diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
index 320cc01..df3f950 100644
--- a/fs/binfmt_elf.c
+++ b/fs/binfmt_elf.c
@@ -1122,6 +1122,9 @@ static unsigned long vma_dump_size(struct vm_area_struct *vma,
if (always_dump_vma(vma))
goto whole;
+ if (vma->vm_flags & VM_DONTDUMP)
+ return 0;
+
/* Hugetlb memory check */
if (vma->vm_flags & VM_HUGETLB) {
if ((vma->vm_flags & VM_SHARED) && FILTER(HUGETLB_SHARED))
diff --git a/include/asm-generic/mman-common.h b/include/asm-generic/mman-common.h
index 787abbb..0016ce3 100644
--- a/include/asm-generic/mman-common.h
+++ b/include/asm-generic/mman-common.h
@@ -48,6 +48,9 @@
#define MADV_HUGEPAGE 14 /* Worth backing with hugepages */
#define MADV_NOHUGEPAGE 15 /* Not worth backing with hugepages */
+#define MADV_DUMP 16
+#define MADV_DONTDUMP 17
+
/* compatibility flags */
#define MAP_FILE 0
diff --git a/include/linux/mm.h b/include/linux/mm.h
index a296709..23684cf 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -111,6 +111,7 @@ extern unsigned int kobjsize(const void *objp);
#define VM_HUGEPAGE 0x01000000 /* MADV_HUGEPAGE marked this vma */
#endif
#define VM_INSERTPAGE 0x02000000 /* The vma has had "vm_insert_page()" done on it */
+#define VM_DONTDUMP 0x04000000 /* Do not include in core dump */
#define VM_CAN_NONLINEAR 0x08000000 /* Has ->fault & does nonlinear pages */
#define VM_MIXEDMAP 0x10000000 /* Can contain "struct page" and pure PFN pages */
diff --git a/mm/madvise.c b/mm/madvise.c
index 74bf193..10b52f8 100644
--- a/mm/madvise.c
+++ b/mm/madvise.c
@@ -65,6 +65,12 @@ static long madvise_behavior(struct vm_area_struct * vma,
}
new_flags &= ~VM_DONTCOPY;
break;
+ case MADV_DONTDUMP:
+ new_flags |= VM_DONTDUMP;
+ break;
+ case MADV_DUMP:
+ new_flags &= ~VM_DONTDUMP;
+ break;
case MADV_MERGEABLE:
case MADV_UNMERGEABLE:
error = ksm_madvise(vma, start, end, behavior, &new_flags);
@@ -293,6 +299,8 @@ madvise_behavior_valid(int behavior)
case MADV_HUGEPAGE:
case MADV_NOHUGEPAGE:
#endif
+ case MADV_DUMP:
+ case MADV_DONTDUMP:
return 1;
default:
--
1.7.7.6
next prev parent reply other threads:[~2012-03-07 17:01 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-07 17:00 [PATCH 0/2] core dump: re-purpose VM_ALWAYSDUMP to user controlled VM_DONTDUMP Jason Baron
2012-03-07 17:00 ` [PATCH 1/2] core dump: drop VM_ALWAYSDUMP flag Jason Baron
2012-03-07 17:59 ` Roland McGrath
2012-03-07 18:50 ` Jason Baron
2012-03-07 19:43 ` Roland McGrath
2012-03-07 21:19 ` Jason Baron
2012-03-07 21:26 ` Chris Metcalf
2012-03-07 21:36 ` Jason Baron
2012-03-07 21:41 ` Roland McGrath
2012-03-07 17:00 ` Jason Baron [this message]
2012-03-07 22:30 ` [PATCH 0/2] core dump: re-purpose VM_ALWAYSDUMP to user controlled VM_DONTDUMP Andrew Morton
2012-03-08 1:32 ` Jason Baron
2012-04-23 22:42 ` Michael Kerrisk
2012-04-27 18:43 ` Jason Baron
2012-04-28 7:29 ` Michael Kerrisk (man-pages)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=fcc863c3e95eb29cd60360d84fbc85ebd07ef843.1331137504.git.jbaron@redhat.com \
--to=jbaron@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=avi@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mcgrathr@google.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®