mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 22:57:44 +00:00
Map pages in read-only ELF sections as non-writable.
This is so cool! :^) Now you'll crash if you try to write into your .text or .rodata segments.
This commit is contained in:
parent
aa6d06b47e
commit
da13c9a264
4 changed files with 26 additions and 6 deletions
|
@ -65,6 +65,18 @@ static int sh_fef(int, const char**)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int sh_wt(int, const char**)
|
||||
{
|
||||
const char* rodata_ptr = "foo";
|
||||
printf("Writing to rodata=%p...\n", rodata_ptr);
|
||||
*(char*)rodata_ptr = 0;
|
||||
|
||||
char* text_ptr = (char*)sh_fef;
|
||||
printf("Writing to text=%p...\n", text_ptr);
|
||||
*text_ptr = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int sh_exit(int, const char**)
|
||||
{
|
||||
printf("Good-bye!\n");
|
||||
|
@ -135,6 +147,10 @@ static bool handle_builtin(int argc, const char** argv, int& retval)
|
|||
retval = sh_fef(argc, argv);
|
||||
return true;
|
||||
}
|
||||
if (!strcmp(argv[0], "wt")) {
|
||||
retval = sh_wt(argc, argv);
|
||||
return true;
|
||||
}
|
||||
if (!strcmp(argv[0], "fork")) {
|
||||
retval = sh_fork(argc, argv);
|
||||
return true;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue