aboutsummaryrefslogtreecommitdiffstats
path: root/executor/common_linux.h
diff options
context:
space:
mode:
authorCameron Finucane <eep@google.com>2024-06-12 18:11:30 -0700
committerDmitry Vyukov <dvyukov@google.com>2024-06-17 07:01:44 +0000
commit74f1336878a51a83415b920087b0b28480354f15 (patch)
treeb1ad2384a38a45e1a6a3c67c91e61e9c6a3f3b42 /executor/common_linux.h
parentf429ab00b60520c365d122f14c46235ca0aa11ef (diff)
executor: handle errors from netlink_query_family_id
There were some cases where the return value was not checked, allowing errors to propagate. This fixes them to return early with a message.
Diffstat (limited to 'executor/common_linux.h')
-rw-r--r--executor/common_linux.h17
1 files changed, 17 insertions, 0 deletions
diff --git a/executor/common_linux.h b/executor/common_linux.h
index 615879699..15ad0ce69 100644
--- a/executor/common_linux.h
+++ b/executor/common_linux.h
@@ -1121,6 +1121,8 @@ static void initialize_wifi_devices(void)
fail("initialize_wifi_devices: failed to create socket");
int hwsim_family_id = netlink_query_family_id(&nlmsg, sock, "MAC80211_HWSIM", true);
int nl80211_family_id = netlink_query_family_id(&nlmsg, sock, "nl80211", true);
+ if (hwsim_family_id < 0 || nl80211_family_id < 0)
+ fail("netlink_query_family_id failed");
uint8 ssid[] = WIFI_IBSS_SSID;
uint8 bssid[] = WIFI_IBSS_BSSID;
struct join_ibss_props ibss_props = {
@@ -5108,6 +5110,11 @@ static const char* setup_802154()
}
{
int nl802154_family_id = netlink_query_family_id(&nlmsg, sock_generic, "nl802154", true);
+ if (nl802154_family_id < 0) {
+ error = "netlink_query_family_id failed";
+ goto fail;
+ }
+
for (int i = 0; i < 2; i++) {
// wpan0/1 are created by CONFIG_IEEE802154_HWSIM.
// sys/linux/socket_ieee802154.txt knowns about these names and consts.
@@ -5504,6 +5511,11 @@ static long syz_80211_inject_frame(volatile long a0, volatile long a1, volatile
}
int hwsim_family_id = netlink_query_family_id(&tmp_msg, sock, "MAC80211_HWSIM", false);
+ if (hwsim_family_id < 0) {
+ debug("syz_80211_inject_frame: failed to query family id\n");
+ close(sock);
+ return -1;
+ }
int ret = hwsim_register_socket(&tmp_msg, sock, hwsim_family_id);
if (ret < 0) {
debug("syz_80211_inject_frame: failed to register socket, ret %d\n", ret);
@@ -5558,6 +5570,11 @@ static long syz_80211_join_ibss(volatile long a0, volatile long a1, volatile lon
}
int nl80211_family_id = netlink_query_family_id(&tmp_msg, sock, "nl80211", false);
+ if (nl80211_family_id < 0) {
+ debug("syz_80211_join_ibss: netlink_query_family_id failed\n");
+ close(sock);
+ return -1;
+ }
struct join_ibss_props ibss_props = {
.wiphy_freq = WIFI_DEFAULT_FREQUENCY,
.wiphy_freq_fixed = (mode == WIFI_JOIN_IBSS_NO_SCAN || mode == WIFI_JOIN_IBSS_BG_NO_SCAN),