diff options
Diffstat (limited to 'executor')
| -rw-r--r-- | executor/common_linux.h | 39 |
1 files changed, 18 insertions, 21 deletions
diff --git a/executor/common_linux.h b/executor/common_linux.h index 329d865d0..8f38fabd7 100644 --- a/executor/common_linux.h +++ b/executor/common_linux.h @@ -557,7 +557,7 @@ static void initialize_tun(void) } #endif -#if SYZ_EXECUTOR || __NR_syz_init_net_socket || SYZ_DEVLINK_PCI || SYZ_VHCI_INJECTION +#if SYZ_EXECUTOR || __NR_syz_init_net_socket || SYZ_DEVLINK_PCI const int kInitNetNsFd = 239; // see kMaxFd #endif @@ -1950,7 +1950,7 @@ static long syz_open_pts(volatile long a0, volatile long a1) } #endif -#if SYZ_EXECUTOR || __NR_syz_init_net_socket || SYZ_VHCI_INJECTION +#if SYZ_EXECUTOR || __NR_syz_init_net_socket #if SYZ_EXECUTOR || SYZ_SANDBOX_NONE || SYZ_SANDBOX_SETUID || SYZ_SANDBOX_NAMESPACE || SYZ_SANDBOX_ANDROID #include <fcntl.h> #include <sched.h> @@ -2207,9 +2207,9 @@ static void initialize_vhci() return; #endif - int hci_sock = syz_init_net_socket(AF_BLUETOOTH, SOCK_RAW, BTPROTO_HCI); + int hci_sock = socket(AF_BLUETOOTH, SOCK_RAW, BTPROTO_HCI); if (hci_sock < 0) - fail("syz_init_net_socket failed"); + fail("socket(AF_BLUETOOTH, SOCK_RAW, BTPROTO_HCI) failed"); vhci_fd = open("/dev/vhci", O_RDWR); if (vhci_fd == -1) @@ -3281,7 +3281,7 @@ static void sandbox_common() setpgrp(); setsid(); -#if SYZ_EXECUTOR || __NR_syz_init_net_socket || SYZ_DEVLINK_PCI || SYZ_VHCI_INJECTION +#if SYZ_EXECUTOR || __NR_syz_init_net_socket || SYZ_DEVLINK_PCI int netns = open("/proc/self/ns/net", O_RDONLY); if (netns == -1) fail("open(/proc/self/ns/net) failed"); @@ -3413,6 +3413,9 @@ static int do_sandbox_none(void) return wait_for_loop(pid); setup_common(); +#if SYZ_EXECUTOR || SYZ_VHCI_INJECTION + initialize_vhci(); +#endif sandbox_common(); drop_caps(); #if SYZ_EXECUTOR || SYZ_NET_DEVICES @@ -3430,9 +3433,6 @@ static int do_sandbox_none(void) #if SYZ_EXECUTOR || SYZ_NET_DEVICES initialize_netdevices(); #endif -#if SYZ_EXECUTOR || SYZ_VHCI_INJECTION - initialize_vhci(); -#endif loop(); doexit(1); } @@ -3454,6 +3454,9 @@ static int do_sandbox_setuid(void) return wait_for_loop(pid); setup_common(); +#if SYZ_EXECUTOR || SYZ_VHCI_INJECTION + initialize_vhci(); +#endif sandbox_common(); #if SYZ_EXECUTOR || SYZ_NET_DEVICES initialize_netdevices_init(); @@ -3470,9 +3473,6 @@ static int do_sandbox_setuid(void) #if SYZ_EXECUTOR || SYZ_NET_DEVICES initialize_netdevices(); #endif -#if SYZ_EXECUTOR || SYZ_VHCI_INJECTION - initialize_vhci(); -#endif const int nobody = 65534; if (setgroups(0, NULL)) @@ -3533,11 +3533,6 @@ static int namespace_sandbox_proc(void* arg) #if SYZ_EXECUTOR || SYZ_NET_DEVICES initialize_netdevices(); #endif -#if SYZ_EXECUTOR || SYZ_VHCI_INJECTION - // This will fail and we only have it here to avoid complains about the - // function being unused. - initialize_vhci(); -#endif if (mkdir("./syz-tmp", 0777)) fail("mkdir(syz-tmp) failed"); @@ -3600,6 +3595,10 @@ static int do_sandbox_namespace(void) int pid; setup_common(); +#if SYZ_EXECUTOR || SYZ_VHCI_INJECTION + // HCIDEVUP requires CAP_ADMIN, so this needs to happen early. + initialize_vhci(); +#endif real_uid = getuid(); real_gid = getgid(); mprotect(sandbox_stack, 4096, PROT_NONE); // to catch stack underflows @@ -3735,6 +3734,9 @@ static void syz_setfilecon(const char* path, const char* context) static int do_sandbox_android(void) { setup_common(); +#if SYZ_EXECUTOR || SYZ_VHCI_INJECTION + initialize_vhci(); +#endif sandbox_common(); drop_caps(); @@ -3754,11 +3756,6 @@ static int do_sandbox_android(void) // and try to reinitialize them as other test processes use them. initialize_netdevices(); #endif -#if SYZ_EXECUTOR || SYZ_VHCI_INJECTION - // This will fail and we only have it here to avoid complains about the - // function being unused. - initialize_vhci(); -#endif if (chown(".", UNTRUSTED_APP_UID, UNTRUSTED_APP_UID) != 0) fail("chmod failed"); |
