aboutsummaryrefslogtreecommitdiffstats
path: root/executor/common_linux.h
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2021-02-21 12:32:11 +0100
committerDmitry Vyukov <dvyukov@google.com>2021-02-21 16:43:26 +0100
commita659b3f1dc889d5ab5ead017b877765b3d042379 (patch)
tree8df03976c96285623e94f39e7a44773170b0a9d8 /executor/common_linux.h
parente894953c0c45c8a6d676292a81da90a615133b1c (diff)
pkg/report: detect executor failures
Currently all executor fail errors go into "lost connection" bucket. This is not very useful. First, there are different executor failures. Second, it's not possible to understand what failures happen how frequently. Third, there are not authentic lost connection. Create separate SYZFAIL: bugs for them. Update #573 Update #502 Update #318
Diffstat (limited to 'executor/common_linux.h')
-rw-r--r--executor/common_linux.h176
1 files changed, 83 insertions, 93 deletions
diff --git a/executor/common_linux.h b/executor/common_linux.h
index a6a117c5b..1d3500a57 100644
--- a/executor/common_linux.h
+++ b/executor/common_linux.h
@@ -186,7 +186,7 @@ static int netlink_send_ext(struct nlmsg* nlmsg, int sock,
ssize_t n = sendto(sock, nlmsg->buf, hdr->nlmsg_len, 0, (struct sockaddr*)&addr, sizeof(addr));
if (n != (ssize_t)hdr->nlmsg_len) {
if (dofail)
- fail("netlink_send_ext: short netlink write: %zd/%d", n, hdr->nlmsg_len);
+ failmsg("netlink_send_ext: short netlink write", "wrote=%zd, want=%d", n, hdr->nlmsg_len);
debug("netlink_send_ext: short netlink write: %zd/%d errno=%d\n", n, hdr->nlmsg_len, errno);
return -1;
}
@@ -195,14 +195,14 @@ static int netlink_send_ext(struct nlmsg* nlmsg, int sock,
*reply_len = 0;
if (n < 0) {
if (dofail)
- fail("netlink_send_ext: netlink read failed: %zd", n);
- debug("netlink_send_ext: netlink read failed: %zd errno=%d\n", n, errno);
+ fail("netlink_send_ext: netlink read failed");
+ debug("netlink_send_ext: netlink read failed: errno=%d\n", errno);
return -1;
}
if (n < (ssize_t)sizeof(struct nlmsghdr)) {
errno = EINVAL;
if (dofail)
- fail("netlink_send_ext: short netlink read: %zd", n);
+ failmsg("netlink_send_ext: short netlink read", "read=%zd", n);
debug("netlink_send_ext: short netlink read: %zd\n", n);
return -1;
}
@@ -215,14 +215,14 @@ static int netlink_send_ext(struct nlmsg* nlmsg, int sock,
if (n < (ssize_t)(sizeof(struct nlmsghdr) + sizeof(struct nlmsgerr))) {
errno = EINVAL;
if (dofail)
- fail("netlink_send_ext: short netlink read: %zd", n);
+ failmsg("netlink_send_ext: short netlink read", "read=%zd", n);
debug("netlink_send_ext: short netlink read: %zd\n", n);
return -1;
}
if (hdr->nlmsg_type != NLMSG_ERROR) {
errno = EINVAL;
if (dofail)
- fail("netlink_send_ext: short netlink ack: %d", hdr->nlmsg_type);
+ failmsg("netlink_send_ext: bad netlink ack type", "type=%d", hdr->nlmsg_type);
debug("netlink_send_ext: short netlink ack: %d\n", hdr->nlmsg_type);
return -1;
}
@@ -1011,7 +1011,7 @@ static void initialize_wifi_devices(void)
mac_addr[5] = device_id;
int ret = hwsim80211_create_device(&nlmsg, sock, hwsim_family_id, mac_addr);
if (ret < 0)
- fail("initialize_wifi_devices: failed to create device #%d", device_id);
+ failmsg("initialize_wifi_devices: failed to create device", "device=%d", device_id);
// For each device, unless HWSIM_ATTR_NO_VIF is passed, a network interface is created
// automatically. Such interfaces are named "wlan0", "wlan1" and so on.
@@ -1019,7 +1019,7 @@ static void initialize_wifi_devices(void)
interface[4] += device_id;
if (nl80211_setup_ibss_interface(&nlmsg, sock, nl80211_family_id, interface, &ibss_props) < 0)
- fail("initialize_wifi_devices: failed set up IBSS network for #%d", device_id);
+ failmsg("initialize_wifi_devices: failed set up IBSS network", "device=%d", device_id);
}
// Wait for all devices to join the IBSS network
@@ -1028,7 +1028,8 @@ static void initialize_wifi_devices(void)
interface[4] += device_id;
int ret = await_ifla_operstate(&nlmsg, interface, IF_OPER_UP);
if (ret < 0)
- fail("initialize_wifi_devices: get_ifla_operstate failed for #%d, ret %d", device_id, ret);
+ failmsg("initialize_wifi_devices: get_ifla_operstate failed",
+ "device=%d, ret=%d", device_id, ret);
}
close(sock);
@@ -1561,7 +1562,7 @@ static int read_tun(char* data, int size)
// Tun sometimes returns EBADFD, unclear if it's a kernel bug or not.
if (errno == EAGAIN || errno == EBADFD)
return -1;
- fail("tun: read failed with %d", rv);
+ fail("tun read failed");
}
return rv;
}
@@ -1856,8 +1857,6 @@ static long syz_io_uring_submit(volatile long a0, volatile long a1, volatile lon
static long syz_usbip_server_init(volatile long a0)
{
- int socket_pair[2];
- char buffer[100];
// port_alloc[0] corresponds to ports which can be used by usb2 and
// port_alloc[1] corresponds to ports which can be used by usb3.
static int port_alloc[2];
@@ -1865,9 +1864,9 @@ static long syz_usbip_server_init(volatile long a0)
int speed = (int)a0;
bool usb3 = (speed == USB_SPEED_SUPER);
- int rc = socketpair(AF_UNIX, SOCK_STREAM, 0, socket_pair);
- if (rc < 0)
- fail("syz_usbip_server_init : socketpair failed: %d", rc);
+ int socket_pair[2];
+ if (socketpair(AF_UNIX, SOCK_STREAM, 0, socket_pair))
+ fail("syz_usbip_server_init: socketpair failed");
int client_fd = socket_pair[0];
int server_fd = socket_pair[1];
@@ -1887,6 +1886,7 @@ static long syz_usbip_server_init(volatile long a0)
// Under normal USB/IP usage, devid represents the device ID on the server.
// When fuzzing with syzkaller we don't have an actual server or an actual device, so use 0 for devid.
+ char buffer[100];
sprintf(buffer, "%d %d %s %d", port_num, client_fd, "0", speed);
write_file("/sys/devices/platform/vhci_hcd.0/attach", buffer);
@@ -2495,7 +2495,7 @@ static bool process_command_pkt(int fd, char* buf, ssize_t buf_size)
struct hci_command_hdr* hdr = (struct hci_command_hdr*)buf;
if (buf_size < (ssize_t)sizeof(struct hci_command_hdr) ||
hdr->plen != buf_size - sizeof(struct hci_command_hdr)) {
- fail("invalid size: %zx", buf_size);
+ failmsg("process_command_pkt: invalid size", "suze=%zx", buf_size);
}
switch (hdr->opcode) {
@@ -3078,7 +3078,7 @@ static void checkpoint_iptables(struct ipt_table_desc* tables, int num_tables, i
case ENOPROTOOPT:
return;
}
- fail("iptable checkpoint %d: socket failed", family);
+ failmsg("iptable checkpoint: socket(SOCK_STREAM, IPPROTO_TCP) failed", "family=%d", family);
}
for (int i = 0; i < num_tables; i++) {
struct ipt_table_desc* table = &tables[i];
@@ -3092,25 +3092,26 @@ static void checkpoint_iptables(struct ipt_table_desc* tables, int num_tables, i
case ENOPROTOOPT:
continue;
}
- fail("iptable checkpoint %s/%d: getsockopt(IPT_SO_GET_INFO)", table->name, family);
+ failmsg("iptable checkpoint: getsockopt(IPT_SO_GET_INFO) failed",
+ "table=%s, family=%d", table->name, family);
}
debug("iptable checkpoint %s/%d: checkpoint entries=%d hooks=%x size=%d\n",
table->name, family, table->info.num_entries,
table->info.valid_hooks, table->info.size);
if (table->info.size > sizeof(table->replace.entrytable))
- fail("iptable checkpoint %s/%d: table size is too large: %u",
- table->name, family, table->info.size);
+ failmsg("iptable checkpoint: table size is too large", "table=%s, family=%d, size=%u",
+ table->name, family, table->info.size);
if (table->info.num_entries > XT_MAX_ENTRIES)
- fail("iptable checkpoint %s/%d: too many counters: %u",
- table->name, family, table->info.num_entries);
+ failmsg("iptable checkpoint: too many counters", "table=%s, family=%d, counters=%d",
+ table->name, family, table->info.num_entries);
struct ipt_get_entries entries;
memset(&entries, 0, sizeof(entries));
strcpy(entries.name, table->name);
entries.size = table->info.size;
optlen = sizeof(entries) - sizeof(entries.entrytable) + table->info.size;
if (getsockopt(fd, level, IPT_SO_GET_ENTRIES, &entries, &optlen))
- fail("iptable checkpoint %s/%d: getsockopt(IPT_SO_GET_ENTRIES)",
- table->name, family);
+ failmsg("iptable checkpoint: getsockopt(IPT_SO_GET_ENTRIES) failed",
+ "table=%s, family=%d", table->name, family);
table->replace.valid_hooks = table->info.valid_hooks;
table->replace.num_entries = table->info.num_entries;
table->replace.size = table->info.size;
@@ -3130,7 +3131,7 @@ static void reset_iptables(struct ipt_table_desc* tables, int num_tables, int fa
case ENOPROTOOPT:
return;
}
- fail("iptable %d: socket failed", family);
+ failmsg("iptable: socket(SOCK_STREAM, IPPROTO_TCP) failed", "family=%d", family);
}
for (int i = 0; i < num_tables; i++) {
struct ipt_table_desc* table = &tables[i];
@@ -3141,7 +3142,8 @@ static void reset_iptables(struct ipt_table_desc* tables, int num_tables, int fa
strcpy(info.name, table->name);
socklen_t optlen = sizeof(info);
if (getsockopt(fd, level, IPT_SO_GET_INFO, &info, &optlen))
- fail("iptable %s/%d: getsockopt(IPT_SO_GET_INFO)", table->name, family);
+ failmsg("iptable: getsockopt(IPT_SO_GET_INFO) failed",
+ "table=%s, family=%d", table->name, family);
if (memcmp(&table->info, &info, sizeof(table->info)) == 0) {
struct ipt_get_entries entries;
memset(&entries, 0, sizeof(entries));
@@ -3149,7 +3151,8 @@ static void reset_iptables(struct ipt_table_desc* tables, int num_tables, int fa
entries.size = table->info.size;
optlen = sizeof(entries) - sizeof(entries.entrytable) + entries.size;
if (getsockopt(fd, level, IPT_SO_GET_ENTRIES, &entries, &optlen))
- fail("iptable %s/%d: getsockopt(IPT_SO_GET_ENTRIES)", table->name, family);
+ failmsg("iptable: getsockopt(IPT_SO_GET_ENTRIES) failed",
+ "table=%s, family=%d", table->name, family);
if (memcmp(table->replace.entrytable, entries.entrytable, table->info.size) == 0)
continue;
}
@@ -3159,7 +3162,8 @@ static void reset_iptables(struct ipt_table_desc* tables, int num_tables, int fa
table->replace.counters = counters;
optlen = sizeof(table->replace) - sizeof(table->replace.entrytable) + table->replace.size;
if (setsockopt(fd, level, IPT_SO_SET_REPLACE, &table->replace, optlen))
- fail("iptable %s/%d: setsockopt(IPT_SO_SET_REPLACE)", table->name, family);
+ failmsg("iptable: setsockopt(IPT_SO_SET_REPLACE) failed",
+ "table=%s, family=%d", table->name, family);
}
close(fd);
}
@@ -3173,7 +3177,7 @@ static void checkpoint_arptables(void)
case ENOPROTOOPT:
return;
}
- fail("arptable checkpoint: socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)");
+ fail("arptable checkpoint: socket(AF_INET, SOCK_STREAM, IPPROTO_TCP) failed");
}
for (unsigned i = 0; i < sizeof(arpt_tables) / sizeof(arpt_tables[0]); i++) {
struct arpt_table_desc* table = &arpt_tables[i];
@@ -3187,23 +3191,23 @@ static void checkpoint_arptables(void)
case ENOPROTOOPT:
continue;
}
- fail("arptable checkpoint %s: getsockopt(ARPT_SO_GET_INFO)", table->name);
+ failmsg("arptable checkpoint: getsockopt(ARPT_SO_GET_INFO) failed", "table=%s", table->name);
}
debug("arptable checkpoint %s: entries=%d hooks=%x size=%d\n",
table->name, table->info.num_entries, table->info.valid_hooks, table->info.size);
if (table->info.size > sizeof(table->replace.entrytable))
- fail("arptable checkpoint %s: table size is too large: %u",
- table->name, table->info.size);
+ failmsg("arptable checkpoint: table size is too large",
+ "table=%s, size=%u", table->name, table->info.size);
if (table->info.num_entries > XT_MAX_ENTRIES)
- fail("arptable checkpoint %s: too many counters: %u",
- table->name, table->info.num_entries);
+ failmsg("arptable checkpoint: too many counters",
+ "table=%s, counters=%u", table->name, table->info.num_entries);
struct arpt_get_entries entries;
memset(&entries, 0, sizeof(entries));
strcpy(entries.name, table->name);
entries.size = table->info.size;
optlen = sizeof(entries) - sizeof(entries.entrytable) + table->info.size;
if (getsockopt(fd, SOL_IP, ARPT_SO_GET_ENTRIES, &entries, &optlen))
- fail("arptable checkpoint %s: getsockopt(ARPT_SO_GET_ENTRIES)", table->name);
+ failmsg("arptable checkpoint: getsockopt(ARPT_SO_GET_ENTRIES) failed", "table=%s", table->name);
table->replace.valid_hooks = table->info.valid_hooks;
table->replace.num_entries = table->info.num_entries;
table->replace.size = table->info.size;
@@ -3234,7 +3238,7 @@ static void reset_arptables()
strcpy(info.name, table->name);
socklen_t optlen = sizeof(info);
if (getsockopt(fd, SOL_IP, ARPT_SO_GET_INFO, &info, &optlen))
- fail("arptable %s:getsockopt(ARPT_SO_GET_INFO)", table->name);
+ failmsg("arptable: getsockopt(ARPT_SO_GET_INFO) failed", "table=%s", table->name);
if (memcmp(&table->info, &info, sizeof(table->info)) == 0) {
struct arpt_get_entries entries;
memset(&entries, 0, sizeof(entries));
@@ -3242,7 +3246,7 @@ static void reset_arptables()
entries.size = table->info.size;
optlen = sizeof(entries) - sizeof(entries.entrytable) + entries.size;
if (getsockopt(fd, SOL_IP, ARPT_SO_GET_ENTRIES, &entries, &optlen))
- fail("arptable %s: getsockopt(ARPT_SO_GET_ENTRIES)", table->name);
+ failmsg("arptable: getsockopt(ARPT_SO_GET_ENTRIES) failed", "table=%s", table->name);
if (memcmp(table->replace.entrytable, entries.entrytable, table->info.size) == 0)
continue;
debug("arptable %s: data changed\n", table->name);
@@ -3255,7 +3259,8 @@ static void reset_arptables()
table->replace.counters = counters;
optlen = sizeof(table->replace) - sizeof(table->replace.entrytable) + table->replace.size;
if (setsockopt(fd, SOL_IP, ARPT_SO_SET_REPLACE, &table->replace, optlen))
- fail("arptable %s: setsockopt(ARPT_SO_SET_REPLACE)", table->name);
+ failmsg("arptable: setsockopt(ARPT_SO_SET_REPLACE) failed",
+ "table=%s", table->name);
}
close(fd);
}
@@ -3328,19 +3333,21 @@ static void checkpoint_ebtables(void)
case ENOPROTOOPT:
continue;
}
- fail("ebtable checkpoint %s: getsockopt(EBT_SO_GET_INIT_INFO)", table->name);
+ failmsg("ebtable checkpoint: getsockopt(EBT_SO_GET_INIT_INFO) failed",
+ "table=%s", table->name);
}
debug("ebtable checkpoint %s: entries=%d hooks=%x size=%d\n",
table->name, table->replace.nentries, table->replace.valid_hooks,
table->replace.entries_size);
if (table->replace.entries_size > sizeof(table->entrytable))
- fail("ebtable checkpoint %s: table size is too large: %u",
- table->name, table->replace.entries_size);
+ failmsg("ebtable checkpoint: table size is too large", "table=%s, size=%u",
+ table->name, table->replace.entries_size);
table->replace.num_counters = 0;
table->replace.entries = table->entrytable;
optlen = sizeof(table->replace) + table->replace.entries_size;
if (getsockopt(fd, SOL_IP, EBT_SO_GET_INIT_ENTRIES, &table->replace, &optlen))
- fail("ebtable checkpoint %s: getsockopt(EBT_SO_GET_INIT_ENTRIES)", table->name);
+ failmsg("ebtable checkpoint: getsockopt(EBT_SO_GET_INIT_ENTRIES) failed",
+ "table=%s", table->name);
}
close(fd);
}
@@ -3365,7 +3372,7 @@ static void reset_ebtables()
strcpy(replace.name, table->name);
socklen_t optlen = sizeof(replace);
if (getsockopt(fd, SOL_IP, EBT_SO_GET_INFO, &replace, &optlen))
- fail("ebtable %s: getsockopt(EBT_SO_GET_INFO)", table->name);
+ failmsg("ebtable: getsockopt(EBT_SO_GET_INFO)", "table=%s", table->name);
replace.num_counters = 0;
table->replace.entries = 0;
for (unsigned h = 0; h < NF_BR_NUMHOOKS; h++)
@@ -3376,7 +3383,7 @@ static void reset_ebtables()
replace.entries = entrytable;
optlen = sizeof(replace) + replace.entries_size;
if (getsockopt(fd, SOL_IP, EBT_SO_GET_ENTRIES, &replace, &optlen))
- fail("ebtable %s: getsockopt(EBT_SO_GET_ENTRIES)", table->name);
+ failmsg("ebtable: getsockopt(EBT_SO_GET_ENTRIES) failed", "table=%s", table->name);
if (memcmp(table->entrytable, entrytable, replace.entries_size) == 0)
continue;
}
@@ -3391,7 +3398,7 @@ static void reset_ebtables()
table->replace.entries = table->entrytable;
optlen = sizeof(table->replace) + table->replace.entries_size;
if (setsockopt(fd, SOL_IP, EBT_SO_SET_ENTRIES, &table->replace, optlen))
- fail("ebtable %s: setsockopt(EBT_SO_SET_ENTRIES)", table->name);
+ failmsg("ebtable: setsockopt(EBT_SO_SET_ENTRIES) failed", "table=%s", table->name);
}
close(fd);
}
@@ -3978,19 +3985,18 @@ const size_t UNTRUSTED_APP_NUM_GROUPS = sizeof(UNTRUSTED_APP_GROUPS) / sizeof(UN
// - No library dependency
// - No dynamic memory allocation
// - Uses fail() instead of returning an error code
-static void syz_getcon(char* context, size_t context_size)
+static void getcon(char* context, size_t context_size)
{
int fd = open(SELINUX_CONTEXT_FILE, O_RDONLY);
-
if (fd < 0)
- fail("getcon: Couldn't open %s", SELINUX_CONTEXT_FILE);
+ fail("getcon: couldn't open context file");
ssize_t nread = read(fd, context, context_size);
close(fd);
if (nread <= 0)
- fail("getcon: Failed to read from %s", SELINUX_CONTEXT_FILE);
+ fail("getcon: failed to read context file");
// The contents of the context file MAY end with a newline
// and MAY not have a null terminator. Handle this here.
@@ -4002,7 +4008,7 @@ static void syz_getcon(char* context, size_t context_size)
// - No library dependency
// - No dynamic memory allocation
// - Uses fail() instead of returning an error code
-static void syz_setcon(const char* context)
+static void setcon(const char* context)
{
char new_context[512];
@@ -4010,7 +4016,7 @@ static void syz_setcon(const char* context)
int fd = open(SELINUX_CONTEXT_FILE, O_WRONLY);
if (fd < 0)
- fail("setcon: Could not open %s", SELINUX_CONTEXT_FILE);
+ fail("setcon: could not open context file");
ssize_t bytes_written = write(fd, context, strlen(context));
@@ -4019,45 +4025,29 @@ static void syz_setcon(const char* context)
close(fd);
if (bytes_written != (ssize_t)strlen(context))
- fail("setcon: Could not write entire context. Wrote %zi, expected %zu", bytes_written, strlen(context));
+ failmsg("setcon: could not write entire context", "wrote=%zi, expected=%zu", bytes_written, strlen(context));
// Validate the transition by checking the context
- syz_getcon(new_context, sizeof(new_context));
+ getcon(new_context, sizeof(new_context));
if (strcmp(context, new_context) != 0)
- fail("setcon: Failed to change to %s, context is %s", context, new_context);
-}
-
-// Similar to libselinux getfilecon(3), but:
-// - No library dependency
-// - No dynamic memory allocation
-// - Uses fail() instead of returning an error code
-static int syz_getfilecon(const char* path, char* context, size_t context_size)
-{
- int length = getxattr(path, SELINUX_XATTR_NAME, context, context_size);
-
- if (length == -1)
- fail("getfilecon: getxattr failed");
-
- return length;
+ failmsg("setcon: failed to change", "want=%s, context=%s", context, new_context);
}
// Similar to libselinux setfilecon(3), but:
// - No library dependency
// - No dynamic memory allocation
// - Uses fail() instead of returning an error code
-static void syz_setfilecon(const char* path, const char* context)
+static void setfilecon(const char* path, const char* context)
{
char new_context[512];
if (setxattr(path, SELINUX_XATTR_NAME, context, strlen(context) + 1, 0) != 0)
fail("setfilecon: setxattr failed");
-
- if (syz_getfilecon(path, new_context, sizeof(new_context)) <= 0)
- fail("setfilecon: getfilecon failed");
-
+ if (getxattr(path, SELINUX_XATTR_NAME, new_context, sizeof(new_context)) < 0)
+ fail("setfilecon: getxattr failed");
if (strcmp(context, new_context) != 0)
- fail("setfilecon: could not set context to %s, currently %s", context, new_context);
+ failmsg("setfilecon: could not set context", "want=%s, got=%s", context, new_context);
}
#define SYZ_HAVE_SANDBOX_ANDROID 1
@@ -4088,13 +4078,13 @@ static int do_sandbox_android(void)
#endif
if (chown(".", UNTRUSTED_APP_UID, UNTRUSTED_APP_UID) != 0)
- fail("chmod failed");
+ fail("do_sandbox_android: chmod failed");
if (setgroups(UNTRUSTED_APP_NUM_GROUPS, UNTRUSTED_APP_GROUPS) != 0)
- fail("setgroups failed");
+ fail("do_sandbox_android: setgroups failed");
if (setresgid(UNTRUSTED_APP_GID, UNTRUSTED_APP_GID, UNTRUSTED_APP_GID) != 0)
- fail("setresgid failed");
+ fail("do_sandbox_android: setresgid failed");
#if GOARCH_arm || GOARCH_arm64 || GOARCH_386 || GOARCH_amd64
// Will fail() if anything fails.
@@ -4104,13 +4094,13 @@ static int do_sandbox_android(void)
#endif
if (setresuid(UNTRUSTED_APP_UID, UNTRUSTED_APP_UID, UNTRUSTED_APP_UID) != 0)
- fail("setresuid failed");
+ fail("do_sandbox_android: setresuid failed");
// setresuid and setresgid clear the parent-death signal.
prctl(PR_SET_PDEATHSIG, SIGKILL, 0, 0, 0);
- syz_setfilecon(".", SELINUX_LABEL_APP_DATA_FILE);
- syz_setcon(SELINUX_CONTEXT_UNTRUSTED_APP);
+ setfilecon(".", SELINUX_LABEL_APP_DATA_FILE);
+ setcon(SELINUX_CONTEXT_UNTRUSTED_APP);
loop();
doexit(1);
@@ -4454,7 +4444,7 @@ static void setup_fault()
if (!write_file(files[i].file, files[i].val)) {
debug("failed to write %s: %d\n", files[i].file, errno);
if (files[i].fatal)
- fail("failed to write %s", files[i].file);
+ failmsg("failed to write fault injection file", "file=%s", files[i].file);
}
}
}
@@ -4473,12 +4463,12 @@ static void setup_leak()
{
// Flush boot leaks.
if (!write_file(KMEMLEAK_FILE, "scan"))
- fail("failed to write %s", KMEMLEAK_FILE);
+ fail("failed to write(kmemleak, \"scan\")");
sleep(5); // account for MSECS_MIN_AGE
if (!write_file(KMEMLEAK_FILE, "scan"))
- fail("failed to write %s", KMEMLEAK_FILE);
+ fail("failed to write(kmemleak, \"scan\")");
if (!write_file(KMEMLEAK_FILE, "clear"))
- fail("failed to write %s", KMEMLEAK_FILE);
+ fail("failed to write(kmemleak, \"clear\")");
}
#define SYZ_HAVE_LEAK_CHECK 1
@@ -4490,7 +4480,7 @@ static void check_leaks(void)
{
int fd = open(KMEMLEAK_FILE, O_RDWR);
if (fd == -1)
- fail("failed to open(\"%s\")", KMEMLEAK_FILE);
+ fail("failed to open(kmemleak)");
// KMEMLEAK has false positives. To mitigate most of them, it checksums
// potentially leaked objects, and reports them only on the next scan
// iff the checksum does not change. Because of that we do the following
@@ -4501,28 +4491,28 @@ static void check_leaks(void)
// hopefully these are true positives during the previous testing cycle.
uint64 start = current_time_ms();
if (write(fd, "scan", 4) != 4)
- fail("failed to write(%s, \"scan\")", KMEMLEAK_FILE);
+ fail("failed to write(kmemleak, \"scan\")");
sleep(1);
// Account for MSECS_MIN_AGE
// (1 second less because scanning will take at least a second).
while (current_time_ms() - start < 4 * 1000)
sleep(1);
if (write(fd, "scan", 4) != 4)
- fail("failed to write(%s, \"scan\")", KMEMLEAK_FILE);
+ fail("failed to write(kmemleak, \"scan\")");
static char buf[128 << 10];
ssize_t n = read(fd, buf, sizeof(buf) - 1);
if (n < 0)
- fail("failed to read(%s)", KMEMLEAK_FILE);
+ fail("failed to read(kmemleak)");
int nleaks = 0;
if (n != 0) {
sleep(1);
if (write(fd, "scan", 4) != 4)
- fail("failed to write(%s, \"scan\")", KMEMLEAK_FILE);
+ fail("failed to write(kmemleak, \"scan\")");
if (lseek(fd, 0, SEEK_SET) < 0)
- fail("failed to lseek(%s)", KMEMLEAK_FILE);
+ fail("failed to lseek(kmemleak)");
n = read(fd, buf, sizeof(buf) - 1);
if (n < 0)
- fail("failed to read(%s)", KMEMLEAK_FILE);
+ fail("failed to read(kmemleak)");
buf[n] = 0;
char* pos = buf;
char* end = buf + n;
@@ -4552,7 +4542,7 @@ static void check_leaks(void)
}
}
if (write(fd, "clear", 5) != 5)
- fail("failed to write(%s, \"clear\")", KMEMLEAK_FILE);
+ fail("failed to write(kmemleak, \"clear\")");
close(fd);
if (nleaks)
doexit(1);
@@ -4589,7 +4579,7 @@ static void setup_kcsan_filterlist(char** frames, int nframes, bool suppress)
{
int fd = open(KCSAN_DEBUGFS_FILE, O_WRONLY);
if (fd == -1)
- fail("failed to open(\"%s\")", KCSAN_DEBUGFS_FILE);
+ fail("failed to open kcsan debugfs file");
printf("%s KCSAN reports in functions: ",
suppress ? "suppressing" : "only showing");