Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1794327384; b=YFfXsrGRhr3j8jelKDl/gwdXVZlEJkqdwr9cIrZIN6qc/2mkxvslQmH5HScqvPRoLvU4 cKM6ZBe+RH0fpVLT30Nepiq6dIQjqGQu2K3/dsbA/x6AcKery9unkuYGCUnQiK67NfzDV kv9JkVm36ZHrGofKsmwopDYQf94qK2TmxHByvHn5zXjOj59KEi5EnulSogkazlYjdhqk/ VG4iAaS/lq7WpSNOEWg904euxyYAFm+9UkWYjyC+wAriI2UC9oG4IQj8oACvPrJ2p7rKH cgMDHw9fY8W3NPwFpgZ/POHs/6vZmELp/WnVFPLbOA6AbuVVLMUovvOYDLkd12EviyQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794327384; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:MIME-Version:Content-Type: Content-Transfer-Encoding; bh=ki1AnwoQSlpOUgD1szlwo8Tppp0EFgb4VZqfaOMgzco=; b=acTgYGomBOqhUPjn3QCxrc8zdG8sOF/qVbAG2XFy8tJKXDxre9dAfrIgeUmJnB8y79C1 fvVlzlZeVoos8dk0gpUkFcwhaRmDdRGSrxCLMITyYTXETLJbNk8ZHM9WwQzLC97pGilZb Im1lfrSYJpFrtZ+nticLFcLbYejIYzQvQoBn7zURGNdsq+/m/Ix9N1Ch4JGB1yC3Y3Bog j2eHlkKoTfso06yughk7QNJ6DPsYpm9iCSsH7nEqT6HtZhJW8luGAuGpRxasbfBv0dBMn nmlOTZklSyjPDQZYz+s0I2ozTFZzUSlrqPzvmrYRtcdYptLR7kAgw2z5yISMSySTjZg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Ow84pEKA; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 25B6C606A326 for ; Tue, 10 Nov 2026 16:16:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Ow84pEKA Received: by smtp.kernel.org (Postfix) with ESMTPSA id 28F961F008A2; Tue, 10 Nov 2026 16:16:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1794327383; bh=ki1AnwoQSlpOUgD1szlwo8Tppp0EFgb4VZqfaOMgzco=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Ow84pEKAonP9xJag31uBJQaxjWA65HNgIMNrvsA/CSPqKYkH97JPEYQU49qtUm/zr L2psYFc3JzQTA+Gh0+YuYQCyi1jYrlYZxvnQNr28QvVAd1mwPinBl6rhdBZau1OC46 5K9QYwCJ1YrduR/PAHKaGB9SROOtpLvy/EtK8UlHluVp1wVm14eVmvGU3Ph+mbaMXy g991vvx8qYAIu35cFb4zQXDa+e7xDKtDfM1VvZUgJ9i6+C6hZ2gpnuLyESOy0wmAf1 nAW/+ZSvCxCN/N31BmT6INn65hqHvcCFE+MkGlLWzsBgnmPJ+tEgy5RcCt98gZRmCg fpl8352QhzTvw== From: Sasha Levin To: stable@vger.kernel.org Cc: Marco Scardovi , Denis Benato , Armin Wolf , =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= , Sasha Levin Subject: [PATCH 6.18.y 2/2] platform/x86: asus-wmi: Serialize WMI method evaluations with a mutex Date: Tue, 10 Nov 2026 11:16:20 -0500 Message-ID: <20261110161539.2394981-2-sashal@kernel.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20261110161539.2394981-1-sashal@kernel.org> References: <20261107051051-failed-6.18-b9428edaf410@kernel.org> <20261110161539.2394981-1-sashal@kernel.org> X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Marco Scardovi [ Upstream commit b9428edaf4109e86a97254228d831767d0acc1f8 ] Concurrent evaluations of ASUS WMI management methods (from ACPI notify, HID, userspace daemons, and debugfs) enter the BIOS ACPI/SMM interface simultaneously, triggering re-entrant SMIs or EC mailbox buffer corruption. Fix this at the root by introducing a centralized evaluation helper (asus_wmi_evaluate_method_locked()) protected by a global mutex (asus_wmi_eval_lock) using guard(mutex). Route all evaluations of ASUS_WMI_MGMT_GUID (method3, method5, method_buf, and show_call) through this helper. A static mutex is required because asus_wmi_evaluate_method() is an exported symbol used by external modules (such as hid-asus and asus-armoury) that lack access to struct asus_wmi drvdata, and the underlying ASUS ACPI/EC management method is a single physical platform resource. The mutex is non-recursive: nested ACPI/WMI notify handlers must not call back into evaluate on the same task (defer via workqueue, as asus_rfkill_notify already does). The sysfs-versus-notify race predates the later export of asus_wmi_evaluate_method(), so Fixes points at the original shared evaluate helper rather than that export. Link: https://github.com/OpenGamingCollective/asusctl/issues/328 Fixes: d33da3b68669 ("asus-wmi: factorise wmi_evaluate_method call") Cc: stable@vger.kernel.org Signed-off-by: Marco Scardovi Reviewed-by: Denis Benato Reviewed-by: Armin Wolf Link: https://patch.msgid.link/b6a1981777e63f0c28bd719d8203ebbda57d6957.1789722252.git.scardracs@disroot.org Reviewed-by: Ilpo Järvinen Signed-off-by: Ilpo Järvinen [ sashal: Adjusted include-block context because the bits.h header was absent. ] Signed-off-by: Sasha Levin --- drivers/platform/x86/asus-wmi.c | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c index 07525698dace8..82874abd57fcc 100644 --- a/drivers/platform/x86/asus-wmi.c +++ b/drivers/platform/x86/asus-wmi.c @@ -15,6 +15,7 @@ #include #include +#include #include #include #include @@ -27,6 +28,7 @@ #include #include #include +#include #include #include #include @@ -341,6 +343,20 @@ static enum asus_ally_mcu_hack use_ally_mcu_hack = ASUS_WMI_ALLY_MCU_HACK_INIT; /* WMI ************************************************************************/ +/* + * Concurrent evaluations of ASUS WMI methods can re-enter firmware + * SMI/EC mailbox handling and corrupt the mailbox. + */ +static DEFINE_MUTEX(asus_wmi_eval_lock); + +static acpi_status asus_wmi_evaluate_method_locked(u32 method_id, + struct acpi_buffer *input, + struct acpi_buffer *output) +{ + guard(mutex)(&asus_wmi_eval_lock); + return wmi_evaluate_method(ASUS_WMI_MGMT_GUID, 0, method_id, input, output); +} + static int asus_wmi_evaluate_method3(u32 method_id, u32 arg0, u32 arg1, u32 arg2, u32 *retval) { @@ -355,8 +371,7 @@ static int asus_wmi_evaluate_method3(u32 method_id, union acpi_object *obj; u32 tmp = 0; - status = wmi_evaluate_method(ASUS_WMI_MGMT_GUID, 0, method_id, - &input, &output); + status = asus_wmi_evaluate_method_locked(method_id, &input, &output); pr_debug("%s called (0x%08x) with args: 0x%08x, 0x%08x, 0x%08x\n", __func__, method_id, arg0, arg1, arg2); @@ -407,8 +422,7 @@ static int asus_wmi_evaluate_method5(u32 method_id, union acpi_object *obj; u32 tmp = 0; - status = wmi_evaluate_method(ASUS_WMI_MGMT_GUID, 0, method_id, - &input, &output); + status = asus_wmi_evaluate_method_locked(method_id, &input, &output); pr_debug("%s called (0x%08x) with args: 0x%08x, 0x%08x, 0x%08x, 0x%08x, 0x%08x\n", __func__, method_id, arg0, arg1, arg2, arg3, arg4); @@ -455,8 +469,7 @@ static int asus_wmi_evaluate_method_buf(u32 method_id, union acpi_object *obj; int err = 0; - status = wmi_evaluate_method(ASUS_WMI_MGMT_GUID, 0, method_id, - &input, &output); + status = asus_wmi_evaluate_method_locked(method_id, &input, &output); pr_debug("%s called (0x%08x) with args: 0x%08x, 0x%08x\n", __func__, method_id, arg0, arg1); @@ -4696,9 +4709,8 @@ static int show_call(struct seq_file *m, void *data) union acpi_object *obj; acpi_status status; - status = wmi_evaluate_method(ASUS_WMI_MGMT_GUID, - 0, asus->debug.method_id, - &input, &output); + status = asus_wmi_evaluate_method_locked(asus->debug.method_id, + &input, &output); if (ACPI_FAILURE(status)) return -EIO; -- 2.53.0