Skip to content

Instantly share code, notes, and snippets.

@ryo
Last active September 28, 2021 10:46
Show Gist options
  • Save ryo/4d402b0dd2323fe5cd9357f49caf728d to your computer and use it in GitHub Desktop.
Save ryo/4d402b0dd2323fe5cd9357f49caf728d to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <unistd.h>
#include <sys/mman.h>
#include <sys/syscall.h>
#include <sys/futex.h>
#include <sys/wait.h>
int
main(int argc, char *argv[])
{
u_long *p = mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_ANONYMOUS, -1, 0);
syscall(SYS___futex_set_robust_list, p, _FUTEX_ROBUST_HEAD_SIZE);
#if 1
execl("/bin/ls", "ls", NULL);
#else
munmap(p, 4096);
#endif
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment