Message ID | 20221013153823.332707-1-raphael.melotte@mind.be |
---|---|
State | New |
Headers | show
Return-Path: <openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org> X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.openwrt.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=<UNKNOWN>) 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=Bd+1Lxsu; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=mind.be header.i=@mind.be header.a=rsa-sha256 header.s=google header.b=HiUMI/Vr; dkim-atps=neutral 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 (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4MpDLc4TCzz23k3 for <incoming@patchwork.ozlabs.org>; Fri, 14 Oct 2022 02:43:02 +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=uUsE5PM7BdmW74x5U646Zm5GlcUx6DMpUGLLbom4nq8=; b=Bd+1LxsuIWZyEc LfVbhKry05aZXdXAAGttIWFXQIyth7xri7ODlMXqM1KzVFHzHN4QDi6PrZig4db6nPjVigHmETJ9r HJPpBsmqNVN8Czxn76Cg09f/Q7lUxjn/7HV2ymD9VkY2Am8ObFLRmFVjlmAdumrwL1glBFOG9tZRN aO1080gyw6TjqYI1zillsS0wlz3vvQplPFBfDX7eL62LoX9qcTOuVUh3R0+IJAu+cw80iAsslyvTq dozn9oY48BZaXw/iaRTysj3Z/axVCmlzkkDHL7xIXHEHM7EaRFgfRfPIt3CRI2cipHyaLAx74yQNP Mj8hturDu63ditrqF5lw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oj0J3-00CKIX-7b; Thu, 13 Oct 2022 15:39:33 +0000 Received: from mail-ej1-x62c.google.com ([2a00:1450:4864:20::62c]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oj0Iw-00CKHQ-Lw for openwrt-devel@lists.openwrt.org; Thu, 13 Oct 2022 15:39:28 +0000 Received: by mail-ej1-x62c.google.com with SMTP id b2so4778026eja.6 for <openwrt-devel@lists.openwrt.org>; Thu, 13 Oct 2022 08:39:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mind.be; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=2X8w8IdcQOtjwa6BWYW7UHBS+pVUdTmSYfJ5a2V0VHc=; b=HiUMI/Vr9PaF3pjHcH+0tp5ytoVjGDpZsPE/djjcaWauhyE04BdWOeFvE4GHLd7upa iGUiZRvULG6RvCDA7CCdTBO1KaOTchCZXKNVWlu5ShE8zc1WwQo73U4ORjNBq38jFWON Sm+JggZMmGpqQ07ru7HOuan/z1WA+diUhj0ExH7nZ0Y26Vd3LBNFVdqfVD8tPUaFJPki Gl0X2Vxzxtt1JhY11Qp+x7vuu12RGqTKqR9MYamIWZvYtoEHWTX+Q/avtxfTYnsUyYAq KZooI/r+syZPgoPTWZ3bJckrVU9qcU/t9hz/qr7Etdrzg/m8LjPDdwxYvUbQVDLNoW6C J2TQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=2X8w8IdcQOtjwa6BWYW7UHBS+pVUdTmSYfJ5a2V0VHc=; b=TvRC8Rb7k3D6WhSdv+HhXkJp8aMBMEy8OsdVgJXPsYgx6d3P0aCRx9FgUD/oyjWFaO JzqyjZOvOkTdzrpqRJlzzepr6QQYPSS/qHiNM6sC8MVW6bzDLkW44A6b72j/Gncx5rA9 aqu2oOZ+pvgSYb2oSmNUo2EqAU5P98irjkA4gR8ahJA3FWtvuHU9UQSmvamZ4eWGHE6W 8l6q1IbErJ+VxOnfFk9JCSq9mIaqzwvkBqRo1yYGov4+EpIBKKffWM2WT7Y95lEc+evb aXKKRYcseha+EEHBtrs39LCt5FAvb+eeNlMmyoTgsstkokhXumtDZX3Q2EKhzULdCqvb 3Aog== X-Gm-Message-State: ACrzQf0TN6VoaBLyUDLE1s4fwCot8OEAei27FFXPvBbCJgpDuT2bTUzC 3/+rNdZiwqKPrniX9Dh2tS+Hisp0KXmjoQ== X-Google-Smtp-Source: AMsMyM7tG2lAX0yWOkFm6w8Argrsa8fYnBJBt3MAW2hAeVqVld17DwNcLYPFmRR8JCPruRzcsILUag== X-Received: by 2002:a17:907:16a7:b0:78d:f5d4:a74e with SMTP id hc39-20020a17090716a700b0078df5d4a74emr260159ejc.9.1665675563692; Thu, 13 Oct 2022 08:39:23 -0700 (PDT) Received: from localhost.localdomain (ip-188-118-3-185.reverse.destiny.be. [188.118.3.185]) by smtp.gmail.com with ESMTPSA id o2-20020a170906768200b0074150f51d86sm3227670ejm.162.2022.10.13.08.39.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Oct 2022 08:39:23 -0700 (PDT) From: =?utf-8?b?UmFwaGHDq2wgTcOpbG90dGU=?= <raphael.melotte@mind.be> To: openwrt-devel@lists.openwrt.org Cc: =?utf-8?b?UmFwaGHDq2wgTcOpbG90dGU=?= <raphael.melotte@mind.be> Subject: [PATCH] hostapd: fix race condition with wpa_supplicant_prepare_interface() Date: Thu, 13 Oct 2022 17:38:23 +0200 Message-Id: <20221013153823.332707-1-raphael.melotte@mind.be> X-Mailer: git-send-email 2.37.3 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221013_083927_018321_5E24CDE2 X-CRM114-Status: GOOD ( 13.51 ) X-Spam-Score: 0.1 (/) 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: wpa_supplicant_prepare_interface() manually removes wpa_supplicant's control interface, by calling wpa_supplicant_teardown_interface(). With the introduction of dynamic wifi configuration in commit a5 [...] Content analysis details: (0.1 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:62c listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.2 HEADER_FROM_DIFFERENT_DOMAINS From and EnvelopeFrom 2nd level mail domains are different -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 X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: OpenWrt Development List <openwrt-devel.lists.openwrt.org> List-Unsubscribe: <https://lists.openwrt.org/mailman/options/openwrt-devel>, <mailto:openwrt-devel-request@lists.openwrt.org?subject=unsubscribe> List-Archive: <http://lists.openwrt.org/pipermail/openwrt-devel/> List-Post: <mailto:openwrt-devel@lists.openwrt.org> List-Help: <mailto:openwrt-devel-request@lists.openwrt.org?subject=help> List-Subscribe: <https://lists.openwrt.org/mailman/listinfo/openwrt-devel>, <mailto:openwrt-devel-request@lists.openwrt.org?subject=subscribe> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: base64 Sender: "openwrt-devel" <openwrt-devel-bounces@lists.openwrt.org> Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org |
Series |
hostapd: fix race condition with wpa_supplicant_prepare_interface()
|
expand
|
diff --git a/package/network/services/hostapd/files/hostapd.sh b/package/network/services/hostapd/files/hostapd.sh index 7eeb74e984..e20725d62b 100644 --- a/package/network/services/hostapd/files/hostapd.sh +++ b/package/network/services/hostapd/files/hostapd.sh @@ -1196,11 +1196,6 @@ _wpa_supplicant_common() { _config="${_rpath}-$ifname.conf" } -wpa_supplicant_teardown_interface() { - _wpa_supplicant_common "$1" - rm -rf "$_rpath/$1" "$_config" -} - wpa_supplicant_prepare_interface() { local ifname="$1" _w_driver="$2" @@ -1245,7 +1240,6 @@ wpa_supplicant_prepare_interface() { else [ -e "$multiap_flag_file" ] && rm "$multiap_flag_file" fi - wpa_supplicant_teardown_interface "$ifname" cat > "$_config" <<EOF ${scan_list:+freq_list=$scan_list} $ap_scan
wpa_supplicant_prepare_interface() manually removes wpa_supplicant's control interface, by calling wpa_supplicant_teardown_interface(). With the introduction of dynamic wifi configuration in commit a5bc9787d4ef89c9e2593a191b3c4cf8702b41a3, we now call ubus to add a new supplicant configuration if there is no wpa_supplicant.ifname object yet, or if the list of interfaces to configure has changed (see mac80211.sh). If the network re-configuration is triggered multiple times in a row successively, there are cases where the supplicant ubus object already exists so we don't call config_add, but the supplicant control interface is nevertheless always removed (as wpa_supplicant_prepare_interface is always called). As a consequence, this leaves the supplicant running without a control interface. One way to reproduce the problem is: - Configure 1 radio with 2 APs and one station interface. - Check /var/run/wpa_supplicant: it contains the global interface and the control interface for our station. - Use the following command to trigger the bug: " /etc/init.d/network restart ; wifi ; sleep 10 ; /etc/init.d/network restart ; wifi " - Check /var/run/wpa_supplicant/ and see that it only contains the global interface, no interface is created for our station. While users are not expected to trigger reconfigurations so quickly, in practice it might happen due to unfortunate chains of actions. When this happens, it leaves the supplicant unusable for other processes that want to use the control interface. To fix it, remove wpa_supplicant_teardown_interface() entirely. The config_remove and config_add ubus calls will anyway create and remove the control interface as needed, so there is no need to remove it manually. Signed-off-by: Raphaël Mélotte <raphael.melotte@mind.be> --- package/network/services/hostapd/files/hostapd.sh | 6 ------ 1 file changed, 6 deletions(-)