From patchwork Thu Dec 28 13:14:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrei Otcheretianski X-Patchwork-Id: 1880846 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=mw/S9qR1; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=EQkocp9s; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=patchwork.ozlabs.org) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4T18Bn51D6z1ydb for ; Fri, 29 Dec 2023 00:15:29 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=dHR1T2aIPqp1ruNcSRb0Qr/rpPhI5x04M90ITK+qzc8=; b=mw/S9qR13QuAaa lQHpHhd9wcGBZCY2lm2VadmDrMgQcSpxA86NA3fJj75Sd9FVIvUwbkmPBSKIAAOL6BEtPRfp8T3UN WQUJcEIYaBIQwpiFqi2Ko+hE/KWaxwpvkn/QeEtfgslYsYyor/aTUaOx2qD14dTjcgPkttHvRDyHk bXkvafP/nvUf00uOSWF0FbYTGJvGro7cNxazf3Ekuc7APAuGw+UINJ22slZqtUlgU/ih7spDnSHgJ RroMM5r+EkXAgHOqvULrCITFt4bX62d6Dlepglm3Bad3K3kzHHQ6iA9a/gO5lXEXstKVJi1r02/ck i8DPwuUsMqjkAQsFw1ew==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rIqDs-00GtrZ-0a; Thu, 28 Dec 2023 13:14:52 +0000 Received: from mgamail.intel.com ([134.134.136.126]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rIqDq-00GtrA-0K for hostap@lists.infradead.org; Thu, 28 Dec 2023 13:14:51 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1703769290; x=1735305290; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=G9Kdjx8h6J3S6wOblIJeJNxeCeqVSwtDeX4MlnpOcsI=; b=EQkocp9so0qmnfqINKBpv6YD5Pn+ItMyDNMLNHkCAsqZmJ5/M9c/4kgO ZlFFGS2iJpbMY/abD28vasMPrSSfbokSjffykAk/FBOo9X15ztjMj4sfE Nft71RFR2JjvbDR7+S8KOnl9Ut/OpXo8/7Kvf0P7DGCdvFEq4+G7ftgPn aAELrtV8XcwxJGszZ17tQV9EAWjn9jjCq1d2LHxRzsr/baHJPNgmyC83e wi57yER1qEZ/w6juCpyWhiPY/x4hTVGXzx6zUuaVtTPgh5cWApldQOUWm F9HoBKaFWFN58XUUr6vvuQOd9ds/Cj9ymGdaos3JnlP3BBvRKfmClKBWE w==; X-IronPort-AV: E=McAfee;i="6600,9927,10936"; a="381516655" X-IronPort-AV: E=Sophos;i="6.04,312,1695711600"; d="scan'208";a="381516655" Received: from orviesa002.jf.intel.com ([10.64.159.142]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Dec 2023 05:14:49 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.04,312,1695711600"; d="scan'208";a="20249972" Received: from unknown (HELO WEIS0042.iil.intel.com) ([10.12.217.211]) by orviesa002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Dec 2023 05:14:48 -0800 From: Andrei Otcheretianski To: hostap@lists.infradead.org Cc: Benjamin Berg Subject: [PATCH 1/2] nl80211: Retrieve maxattr via genl for nl80211 Date: Thu, 28 Dec 2023 15:14:05 +0200 Message-ID: <20231228131406.2439640-1-andrei.otcheretianski@intel.com> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231228_051450_209008_88AF68E0 X-CRM114-Status: GOOD ( 14.50 ) X-Spam-Score: -0.4 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: From: Benjamin Berg Older kernel versions may not support all attributes and may refuse commands that include them. To avoid sending too new attributes query the highest supported attribute. This allows adding appropriat [...] Content analysis details: (-0.4 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 SPF_NONE SPF: sender does not publish an SPF Record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.2 DKIMWL_WL_HIGH DKIMwl.org - High trust sender X-BeenThere: hostap@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Hostap" Errors-To: hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org From: Benjamin Berg Older kernel versions may not support all attributes and may refuse commands that include them. To avoid sending too new attributes query the highest supported attribute. This allows adding appropriate checks where needed. Signed-off-by: Benjamin Berg --- src/drivers/driver_nl80211.c | 28 ++++++++++++++++++++++++++++ src/drivers/driver_nl80211.h | 1 + 2 files changed, 29 insertions(+) diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c index a3bb2d5251..b56ca852d3 100644 --- a/src/drivers/driver_nl80211.c +++ b/src/drivers/driver_nl80211.c @@ -16,6 +16,7 @@ #include #include #include +#include #ifdef CONFIG_LIBNL3_ROUTE #include #endif /* CONFIG_LIBNL3_ROUTE */ @@ -1938,6 +1939,8 @@ static int wpa_driver_nl80211_get_country(void *priv, char *alpha2) static int wpa_driver_nl80211_init_nl_global(struct nl80211_global *global) { + struct nl_cache *cache = NULL; + struct genl_family *family = NULL; int ret; global->nl_cb = nl_cb_alloc(NL_CB_DEFAULT); @@ -2009,6 +2012,29 @@ static int wpa_driver_nl80211_init_nl_global(struct nl80211_global *global) /* Continue without vendor events */ } + /* Resolve maxattr for kernel support checks */ + ret = genl_ctrl_alloc_cache(global->nl, &cache); + if (ret < 0) { + wpa_printf(MSG_DEBUG, + "nl80211: Could not allocate genl cache: %d (%s)", + ret, nl_geterror(ret)); + goto err; + } + + family = genl_ctrl_search(cache, global->nl80211_id); + if (!family) { + wpa_printf(MSG_DEBUG, + "nl80211: Could not get nl80211 family from cache: %d (%s)", + ret, nl_geterror(ret)); + goto err; + } + + global->nl80211_maxattr = genl_family_get_maxattr(family); + genl_family_put(family); + family = NULL; + nl_cache_free(cache); + cache = NULL; + nl_cb_set(global->nl_cb, NL_CB_SEQ_CHECK, NL_CB_CUSTOM, no_seq_check, NULL); nl_cb_set(global->nl_cb, NL_CB_VALID, NL_CB_CUSTOM, @@ -2021,6 +2047,8 @@ static int wpa_driver_nl80211_init_nl_global(struct nl80211_global *global) return 0; err: + genl_family_put(family); + nl_cache_free(cache); nl_destroy_handles(&global->nl_event); nl_destroy_handles(&global->nl); nl_cb_put(global->nl_cb); diff --git a/src/drivers/driver_nl80211.h b/src/drivers/driver_nl80211.h index 2b2bc9b117..315b88b01a 100644 --- a/src/drivers/driver_nl80211.h +++ b/src/drivers/driver_nl80211.h @@ -32,6 +32,7 @@ struct nl80211_global { struct nl_cb *nl_cb; struct nl_sock *nl; int nl80211_id; + int nl80211_maxattr; int nlctrl_id; int ioctl_sock; /* socket for ioctl() use */ From patchwork Thu Dec 28 13:14:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrei Otcheretianski X-Patchwork-Id: 1880847 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=PJFodE3E; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=WERwMqeo; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=patchwork.ozlabs.org) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4T18Bt3kZMz23d7 for ; Fri, 29 Dec 2023 00:15:34 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=byIphgec2w9v7QBK9Ww4gk7ds7XziSFTP7MIDtft9eM=; b=PJFodE3Ec1FVFz s7kM3j3uI8r6mRo0BJm8q4x5pYYqePd6O+LhE7NFb3szuWsNzBCVn0cBcVjghOgvJrWfaXLUCmU5F xXgBeRv1y1GxHNqH9P1u/nhYcSkJPWwRXN852bHTgyxjkq9dSPACJDJ7vY1Z8Q9gxK7mC/i0RG3fi ICQgeklvP+1sp8ob9wOsFYeZKzSzggEcwtJ+/RTrAgDzkjjnkx7M5FDqdF22GoUCUVrL5ssPo0VEV lzS4Zw1BGvdRUVhj/vbfl5+Gp4mmonKjhs1CrAbRS4paB0hj7gYIyFsSz6NKu7it7HM2l8rXGp+Qd XpTMp48GGdj9mgkrmFUg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rIqDz-00GtsV-0w; Thu, 28 Dec 2023 13:14:59 +0000 Received: from mgamail.intel.com ([134.134.136.126]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rIqDx-00Gtry-0T for hostap@lists.infradead.org; Thu, 28 Dec 2023 13:14:58 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1703769297; x=1735305297; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=kg0MhIwOcz5VLc7BnFfWpC3JmKkmTMkuqOWEYttzjVQ=; b=WERwMqeoA/hYof0z4agLkm3ael1kIgGF4KfnwKSs6+rYVGACrrJU7Npc jyw3pWJ7w6gx1/oWCyHoenOOxeDw+rbMSvCd2JTRZHpFOhT8d1PoxUUDe 5LEq83XvlLxJBSU5ueMdOidessxMBgjKNhk5/TKcLq/nBGke3nXAKaD26 d0DUaIqeXbygxpPFHWi/ls95uPY/nQFt6ncvnmLitnlnA/Bh447OpvT1H elTfAJo4j7Wb2W/KW+J+B1Z96S5LwX+ENnx/plHgO3IA8R/5PXJX9i/en M/PDY6R2ROdYSj1ooV7pDW7/MiMdoV1Ybqs6miJsnSe5265quJhDPxvWY Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10936"; a="381516659" X-IronPort-AV: E=Sophos;i="6.04,312,1695711600"; d="scan'208";a="381516659" Received: from orviesa002.jf.intel.com ([10.64.159.142]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Dec 2023 05:14:56 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.04,312,1695711600"; d="scan'208";a="20249994" Received: from unknown (HELO WEIS0042.iil.intel.com) ([10.12.217.211]) by orviesa002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Dec 2023 05:14:56 -0800 From: Andrei Otcheretianski To: hostap@lists.infradead.org Cc: Benjamin Berg Subject: [PATCH 2/2] nl80211: Avoid sending unsupported attributes Date: Thu, 28 Dec 2023 15:14:06 +0200 Message-ID: <20231228131406.2439640-2-andrei.otcheretianski@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231228131406.2439640-1-andrei.otcheretianski@intel.com> References: <20231228131406.2439640-1-andrei.otcheretianski@intel.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231228_051457_225646_F60728E4 X-CRM114-Status: GOOD ( 11.51 ) X-Spam-Score: -0.4 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: From: Benjamin Berg The kernel will reject commands if newer attributes are included even though they should not be. Add appropriate checks in set_ap. Signed-off-by: Benjamin Berg --- src/drivers/driver_nl80211.c | 6 ++++-- src/drivers/driver_nl80211.h | 5 +++++ 2 files changed, 9 insertions(+), 2 deletions(-) Content analysis details: (-0.4 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 SPF_NONE SPF: sender does not publish an SPF Record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.2 DKIMWL_WL_HIGH DKIMwl.org - High trust sender X-BeenThere: hostap@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Hostap" Errors-To: hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org From: Benjamin Berg The kernel will reject commands if newer attributes are included even though they should not be. Add appropriate checks in set_ap. Signed-off-by: Benjamin Berg --- src/drivers/driver_nl80211.c | 6 ++++-- src/drivers/driver_nl80211.h | 5 +++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c index b56ca852d3..27129c94ef 100644 --- a/src/drivers/driver_nl80211.c +++ b/src/drivers/driver_nl80211.c @@ -5189,7 +5189,8 @@ static int wpa_driver_nl80211_set_ap(void *priv, flags |= NL80211_AP_SETTINGS_SA_QUERY_OFFLOAD_SUPPORT; - if (nla_put_u32(msg, NL80211_ATTR_AP_SETTINGS_FLAGS, flags)) + if (nl80211_attr_supported(drv, NL80211_ATTR_AP_SETTINGS_FLAGS) && + nla_put_u32(msg, NL80211_ATTR_AP_SETTINGS_FLAGS, flags)) goto fail; } @@ -5323,7 +5324,8 @@ static int wpa_driver_nl80211_set_ap(void *priv, if (params->freq && nl80211_put_freq_params(msg, params->freq) < 0) goto fail; - if (params->freq && params->freq->he_enabled) { + if (params->freq && params->freq->he_enabled && + nl80211_attr_supported(drv, NL80211_ATTR_HE_BSS_COLOR)) { struct nlattr *bss_color; bss_color = nla_nest_start(msg, NL80211_ATTR_HE_BSS_COLOR); diff --git a/src/drivers/driver_nl80211.h b/src/drivers/driver_nl80211.h index 315b88b01a..ccfc98ec33 100644 --- a/src/drivers/driver_nl80211.h +++ b/src/drivers/driver_nl80211.h @@ -375,6 +375,11 @@ int wpa_driver_set_ap_wps_p2p_ie(void *priv, const struct wpabuf *beacon, #endif /* ANDROID_P2P */ #endif /* ANDROID */ +static inline bool +nl80211_attr_supported(struct wpa_driver_nl80211_data *drv, int attr) +{ + return attr <= drv->global->nl80211_maxattr; +} /* driver_nl80211_scan.c */