void toggle_syscall_biarch(const char *arg, bool state) { int specific_syscall32 = 0; int specific_syscall64 = 0; char *arg_name = NULL; bool only_32bit = TRUE; bool only_64bit = TRUE; check_user_specified_arch(arg, &arg_name, &only_64bit, &only_32bit); /* If we found a 64bit syscall, validate it. */ specific_syscall64 = search_syscall_table(syscalls_64bit, max_nr_64bit_syscalls, arg_name); toggle_syscall_biarch_n(specific_syscall64, syscalls_64bit, only_64bit, do_64_arch, state, &activate_syscall64, 0, arg_name); /* Search for and validate 32bit */ specific_syscall32 = search_syscall_table(syscalls_32bit, max_nr_32bit_syscalls, arg_name); toggle_syscall_biarch_n(specific_syscall32, syscalls_32bit, only_32bit, do_32_arch, state, &activate_syscall32, 0, arg_name); if ((!only_32bit) && (!only_64bit)) { outputerr("No idea what architecture for syscall (%s) is.\n", arg); exit(EXIT_FAILURE); } if ((specific_syscall64 == -1) && (specific_syscall32 == -1)) { outputerr("No idea what syscall (%s) is.\n", arg); exit(EXIT_FAILURE); } if ((specific_syscall64 != -1) && (specific_syscall32 != -1)) { output(0, "Marking syscall %s (64bit:%d 32bit:%d) as to be %sabled.\n", arg_name, specific_syscall64, specific_syscall32, state ? "en" : "dis"); goto out; } if (specific_syscall64 != -1) { output(0, "Marking 64-bit syscall %s (%d) as to be %sabled.\n", arg, specific_syscall64, state ? "en" : "dis"); goto out; } if (specific_syscall32 != -1) { output(0, "Marking 32-bit syscall %s (%d) as to be %sabled.\n", arg, specific_syscall32, state ? "en" : "dis"); } out: clear_check_user_specified_arch(arg, &arg_name); return; }
static void sanitise_socketcall(int childno) { unsigned long *args; args = malloc(6 * sizeof(unsigned long)); shm->a1[childno] = rand() % 20; switch (shm->a1[childno]) { case SYS_SOCKET: sanitise_socket(childno); shm->syscallno[childno] = search_syscall_table(syscalls, max_nr_syscalls, "socket"); break; case SYS_BIND: break; case SYS_CONNECT: break; case SYS_LISTEN: break; case SYS_ACCEPT: break; case SYS_GETSOCKNAME: break; case SYS_GETPEERNAME: break; case SYS_SOCKETPAIR: break; case SYS_SEND: break; case SYS_RECV: break; case SYS_SENDTO: break; case SYS_RECVFROM: break; case SYS_SHUTDOWN: break; case SYS_SETSOCKOPT: break; case SYS_GETSOCKOPT: break; case SYS_SENDMSG: break; case SYS_RECVMSG: break; case SYS_ACCEPT4: break; case SYS_RECVMMSG: break; case SYS_SENDMMSG: break; default: break; } shm->a2[childno] = (unsigned long) args; }
void toggle_syscall(const char *arg, bool state) { int specific_syscall = 0; char * arg_name = NULL; if (biarch == TRUE) { toggle_syscall_biarch(arg, state); return; } /* non-biarch case. */ check_user_specified_arch(arg, &arg_name, NULL, NULL); //We do not care about arch here, just to get rid of arg flags. specific_syscall = search_syscall_table(syscalls, max_nr_syscalls, arg_name); toggle_syscall_n(specific_syscall, state, arg, arg_name); clear_check_user_specified_arch(arg, &arg_name); }
void toggle_syscall(const char *arg, bool state) { int specific_syscall = 0; char * arg_name = NULL; if (biarch == TRUE) { toggle_syscall_biarch(arg, state); return; } /* non-biarch case. */ check_user_specified_arch(arg, &arg_name, NULL, NULL); //We do not care about arch here, just to get rid of arg flags. specific_syscall = search_syscall_table(syscalls, max_nr_syscalls, arg_name); if (specific_syscall == -1) { outputerr("No idea what syscall (%s) is.\n", arg); goto out; } toggle_syscall_n(specific_syscall, state, arg, arg_name); out: clear_check_user_specified_arch(arg, &arg_name); }
void enable_random_syscalls_biarch(void) { unsigned int call32 = NOTFOUND, call64 = NOTFOUND; retry: //Search for 64 bit version if (do_64_arch) { struct syscallentry *entry = NULL; call64 = rnd() % max_nr_64bit_syscalls; if (validate_specific_syscall_silent(syscalls_64bit, call64) == FALSE) goto retry; entry = syscalls_64bit[call64].entry; if (entry->flags & TO_BE_DEACTIVATED) { call64 = NOTFOUND; goto try32bit; } if (entry->active_number != 0) { call64 = NOTFOUND; goto try32bit; } // If we got so far, then activate it. toggle_syscall_biarch_n(call64, syscalls_64bit, TRUE, do_64_arch, TRUE, &activate_syscall64, 64, entry->name); } try32bit: //Search for 32 bit version if (do_32_arch) { struct syscallentry *entry = NULL; /* If we enabled a 64bit syscall above, enable its 32-bit counter-part too */ if (do_64_arch) { if (call64 == NOTFOUND) { goto just32; } else { call32 = search_syscall_table(syscalls_32bit, max_nr_32bit_syscalls, syscalls_64bit[call64].entry->name); if (call32 == NOTFOUND) return; // syscall is 64-bit only. } } else { just32: call32 = rnd() % max_nr_32bit_syscalls; } if (validate_specific_syscall_silent(syscalls_32bit, call32) == FALSE) return; entry = syscalls_32bit[call32].entry; if ((entry->flags & TO_BE_DEACTIVATED) || (entry->active_number != 0)) return; //If we got so far, then active it. toggle_syscall_biarch_n(call32, syscalls_32bit, TRUE, do_32_arch, TRUE, &activate_syscall32, 32, entry->name); } }