forked from pwndbg/pwndbg
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'pwndbg:dev' into debugsyms_fallback
- Loading branch information
Showing
6 changed files
with
199 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -93,3 +93,6 @@ gdb.txt | |
|
||
# Nix build stuff | ||
result-* | ||
|
||
# Vim | ||
*.swp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#include <assert.h> | ||
#include <stdint.h> | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include <string.h> | ||
#include <sys/mman.h> | ||
#include <unistd.h> | ||
|
||
void break_here(void) {} | ||
|
||
#define ADDR (void *)0xcafe0000 | ||
#define PGSZ 0x1000 | ||
|
||
void *xmmap(void *addr, size_t length, int prot, int flags, int fd, | ||
off_t offset) { | ||
void *p = mmap(addr, length, prot, flags, fd, offset); | ||
if (MAP_FAILED == p) { | ||
printf("Failed to map fixed address at %p\n", (void *)addr); | ||
perror("mmap"); | ||
exit(EXIT_FAILURE); | ||
} | ||
return p; | ||
} | ||
|
||
int main(void) { | ||
// We want to allocate multiple adjacent regions, too confirm that vmmap | ||
// --gaps detects them properly. So iensure we have adjacent allocation, | ||
// unmapped holes, as well as some guard page with no permissions. | ||
|
||
uint64_t address = (uint64_t)ADDR; | ||
void *p; | ||
|
||
// 2 adjacent pages | ||
p = xmmap((void *)address, PGSZ, PROT_READ, | ||
MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED, -1, 0); | ||
address += PGSZ; | ||
p = xmmap((void *)address, PGSZ, PROT_READ | PROT_WRITE, | ||
MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED, -1, 0); | ||
address += PGSZ; | ||
|
||
// GUARD page | ||
p = xmmap((void *)address, PGSZ, PROT_NONE, | ||
MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED, -1, 0); | ||
mprotect(p, 0x1000, PROT_NONE); | ||
address += PGSZ; | ||
|
||
p = xmmap((void *)address, PGSZ, PROT_READ | PROT_WRITE | PROT_EXEC, | ||
MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED, -1, 0); | ||
address += PGSZ; | ||
|
||
break_here(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters