diff options
| author | Grigory Bazilevich <g.bazilevich@ispras.ru> | 2025-10-23 22:28:25 +0300 |
|---|---|---|
| committer | Grigory Bazilevich <g.bazilevich@ispras.ru> | 2026-03-12 11:30:09 +0300 |
| commit | a14de05e829526775e7b5a267e991f4a95e2f876 (patch) | |
| tree | e2ad6c6e927f7afa347968ef7bcf9f35feeabfca /executor/common_linux.h | |
| parent | c3f888da7b0ec713f26b753611d3b9c62b900c53 (diff) | |
executor: fix fd leaks
Close file descriptors in read_btf_vmlinux, find_vf_interface and
syz_usbip_server_init.
Otherwise sykaller fails when executor exeeds a limit for available fds.
Signed-off-by: Pavel Nikulshin <p.nikulshin@ispras.ru>
Diffstat (limited to 'executor/common_linux.h')
| -rw-r--r-- | executor/common_linux.h | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/executor/common_linux.h b/executor/common_linux.h index c1368f292..9fbccbd7a 100644 --- a/executor/common_linux.h +++ b/executor/common_linux.h @@ -242,6 +242,7 @@ static void find_vf_interface(void) } address = address->ifa_next; } + close(fd); freeifaddrs(addresses); if (!vf_intf.ppid) { memset(&vf_intf, 0, sizeof(struct vf_intf)); @@ -2084,6 +2085,8 @@ static long syz_usbip_server_init(volatile long a0) int available_port_num = __atomic_fetch_add(&port_alloc[usb3], 1, __ATOMIC_RELAXED); if (available_port_num > VHCI_HC_PORTS) { debug("syz_usbip_server_init : no more available port for : %d\n", available_port_num); + close(client_fd); + close(server_fd); return -1; } @@ -2208,8 +2211,10 @@ static char* read_btf_vmlinux() ssize_t ret = read(fd, buf + bytes_read, VMLINUX_MAX_SUPPORT_SIZE - bytes_read); - if (ret < 0 || bytes_read + ret == VMLINUX_MAX_SUPPORT_SIZE) + if (ret < 0 || bytes_read + ret == VMLINUX_MAX_SUPPORT_SIZE) { + close(fd); return NULL; + } if (ret == 0) break; @@ -2217,6 +2222,7 @@ static char* read_btf_vmlinux() bytes_read += ret; } + close(fd); is_read = true; return buf; } |
