Skip to content

Support madvise(MADV_DONTDUMP) when creating core dumps for qemu-user #114

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions include/exec/page-protection.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@
*/
#define PAGE_PASSTHROUGH 0x0800

/*
* For linux-user, indicates that the page should not be included in a core
* dump.
*/
#define PAGE_DONTDUMP 0x1000

#ifdef CONFIG_USER_ONLY

void TSA_NO_TSA mmap_lock(void);
Expand Down
4 changes: 4 additions & 0 deletions linux-user/elfload.c
Original file line number Diff line number Diff line change
Expand Up @@ -4068,6 +4068,10 @@ static size_t vma_dump_size(target_ulong start, target_ulong end,
return 0;
}

if (flags & PAGE_DONTDUMP) {
return 0;
}

/*
* Usually we don't dump executable pages as they contain
* non-writable code that debugger can read directly from
Expand Down
5 changes: 5 additions & 0 deletions linux-user/mmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -1246,6 +1246,11 @@ abi_long target_madvise(abi_ulong start, abi_ulong len_in, int advice)
*/
mmap_lock();
switch (advice) {
case MADV_DONTDUMP:
if (len > 0) {
page_set_flags(start, start + len - 1, PAGE_DONTDUMP);
}
break;
case MADV_WIPEONFORK:
case MADV_KEEPONFORK:
ret = -EINVAL;
Expand Down
Loading