Untitled attachment
https://mstdn.starnix.network/system/media_attachments/files/113/157/860/838/297/647/original/8d3b7cd05798e65b.png
Even though NULL is the holy cow of C programmers, treated very specially by C compilers, technically nothing stops you from doing this.
~ sudo sysctl vm.mmap_min_addr=0
vm.mmap_min_addr = 0
~ cat null.c
#include
#include
#include
int main(void) {
char *addr = mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_SHARED|MAP_FIXED|MAP_ANONYMOUS, -1, 0);
if (addr == MAP_FAILED) {
perror("mmap");
return 1;
}
printf("We have successfully mapped %p\n", addr);
strcpy(addr, "ON NOES YOU HAVE WORMS IN YOUR NULL");
printf("%s\n", NULL);
}
~ gcc null.c -o null
~ ./null
We have successfully mapped (nil)
ON NOES YOU HAVE WORMS IN YOUR NULL
WHERE IS YOUR GOD NOW?
GNU social JP is a social network, courtesy of GNU social JP管理人. It runs on GNU social, version 2.0.2-dev, available under the GNU Affero General Public License.
All GNU social JP content and data are available under the Creative Commons Attribution 3.0 license.