From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.128.47 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796167919; b=nia+b7vm61kFByBt1HJ/vpB3ZWSTyjdcpTe5/+ncntpVp+ZYrZtSE2zMm0OUZ4J1h02/ /JWI0MzuvbcbARdcTgYZS8M4RtMLAr8dw0qyV1qZQgk8RWznlHfItVwtuv3OtgXyAnGxx oUi7VjmBtD6oVSfkH4yaumiMnTyaIz2Crqzj08kGaRH44PUsjVaBZTcgBztHD3yjZ+LoS JMVPuE3p1iTTFQaxYbsMFQUzpEh0SEn0Z10Kvl9YDgYQG+p3lAQmf42aIaKYA+nUQV3XS pVFXX+QxMlvGhY4c3vgieR+ZgE2n+kufVFTY0WZdIZTMag9qnIMZQ0UVvN+NtLcntmw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796167919; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:Date:Subject:MIME-Version:Content-Type:Content-Transfer-Encoding: Message-Id:References:In-Reply-To:To:Cc:X-Mailer; bh=KcDfA4DVNVIlSyyAfo12DDb9nZvNrgsqFpF/JN6UbRE=; b=End8bBRnsCb8IDflqEsUskrJpAA9KC656uheChJD6jsuihVa3kqssrVMxbnVD8Aq6rL6 NaF7TKVphv1yWuDQtvMfZCp8BmCXec6KAoLu9P2S+LoGmEIrjPdu3iq4JICMxCq2uXFjA 0AWzmuPXmMaWdza+WLkEjK8673H95YQFll8fGslvof8YolgWJrkbet+r1OCjufSVw10t0 lBs2gl5HnOnPtW/OypQA2gxdVB6inTYJSth39MsqYET+O4gsI9tY1jdOgco7ER6biIqcR PvYIw+til5uH/qrGeYkVpE9ZlsCcgBWb+tbNwYAt+WAH8ogUYMH3fZpZr4MKYcRv+aA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=HSD2Tiru; arc=none smtp.remote-ip=209.85.128.47 Received: from mail-wm1-f47.google.com (mail-wm1-f47.google.com [209.85.128.47]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BFC83606A320 for ; Tue, 1 Dec 2026 23:31:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org BFC83606A320 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=HSD2Tiru Received: by mail-wm1-f47.google.com with SMTP id 5b1f17b1804b1-4bb69f5b161so82463345e9.0 for ; Tue, 01 Dec 2026 15:31:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796167917; x=1796772717; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=KcDfA4DVNVIlSyyAfo12DDb9nZvNrgsqFpF/JN6UbRE=; b=HSD2TiruI3ArKI5N2Y0JnGdUF570Gj3JSEp2dM18iHxFFcbs42ZheZ82sIDbaQo+QV D5HiKL/gOtJWqKVq2rAvu9EiucAfrLNFGn6yDxUbmNPggOYxVwqGN3VhmgwzuF4/7Z8h qfwNQyCo7PwMCakiWR4z3IbSdMU2ozJPZheGo0XyD8cNjB0sR2RYVtqj2F6Fq0mXHyxM rGEQA66yMNHghEYJ93Uy6cvsAYeU0dbhrEwxbtZe/myozTxjmH8f9/3RSNQ/h7jOGXSw //LHOgjoo/XqxCNtBXE7k9TVUrqXw2lttCfwlwlqweV2XIibxpahuaXQpCfXC9K1lB0I yh3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796167917; x=1796772717; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=KcDfA4DVNVIlSyyAfo12DDb9nZvNrgsqFpF/JN6UbRE=; b=t9Wj5SzIDt6T1c0NuAOQxJ3SsTs2sFBB9QCKhPEEBMpL0giYfcOWnoUh+0U8fi/GD+ D7eI3x4NfDc4IgGoD0G1akSSd2JphOV3ZNtFVSODy7Sz6peyR48qS5jFEd3PdGFVWhY2 M61utb+0fThZNIIBy9OjkwsKx0x/6J/lV11or7BWif7LQW/yP7E30DNZyFIxk7XzCFKD m2SBV4WPFgqSLj2tmHdbzZWZvW+u4JBaiNbk8TqSNNRagj0lEIQTV1RB4F/CKeZYUoSJ WbDSD8CNDI7mtVc5jl5kyEIA9+kh4d4aRE8Q8tAb468AlxA2OMvDuAZYqMtaWWIF69mm K44Q== X-Forwarded-Encrypted: i=1; AL+hErEubP+QVZAYssMm+eo52dhZtjqToaUGiF7RlHt7zJ2JvBlL3JKErYO4lsbsXrSvsMpPWWg/1TkOzoLDsUk=@vger.kernel.org X-Gm-Message-State: APuU4Z9HaDOKMj5btUwnHHkLMiujTYUwApHsxvSP7OVPB0kFRwoZubxf 3VBKzYBXue9j9gN8n732dMT1iZ9Lz6mHNInONDrqJ8hDW9sbBu7xWPRo X-Gm-Gg: AZFdTZeUVLF6zkSM3FHxVY9ANS9XiNjKDztdkm5Qy8+jRmQ9fs6b2yPrngxOabKHIP5 IDbZk5z87AzOU5X9KMUxxFXD8AZECSxHwFc3IGfnH2Pingl99q6zs/Pq7nOfFKBGkGDEUw9YYGx tlRA8ju8uuPCMlBiTtn8DrHM2M5OLxd7CgCAzlkR5byhnUNY2l7xbhxYKUnZUgDaGxjIoKyScwp v4wR6g55bUZwNnJfH5OK72fJSv7k/6OJHstHteD4DEq+WU+ZzB9xlYYqQEuDocPCYlKblNU0QRT oodBopVXPkzlnODn92R9c7DChqaTGk2AvPlWZ7kjQciLTVscn16eYMAQ7fX8ccpJWVZ61r4dk0R JYN6qbqdUpcSadt4yYopTVCs44QinvjcW5rOEhYSbxSwcY6MIRtalXcPVqw0QzQX6Y/a0nzYwq8 c/WaQlxO04YGQ6F6BiqxRk8jogsgWvdUw1E/pfZcOIrAv1aVVWfAmYVj/P8hTHmVeraonxzWAoJ lvyMiOlqnqh1G35vHMxTwvFvY8IJIZYz3vBVHQMEpPMQR3c7Zq4XZuw/URrnoR5lc53aqk1YSoR BYcFlMEhUiwrwJ+ehzc8lzLz/JU= X-Received: by 2002:a05:600c:e558:10b0:4bb:c9f8:aeb with SMTP id 5b1f17b1804b1-4bbc9f80cb1mr83114025e9.1.1796167917084; Tue, 01 Dec 2026 15:31:57 -0800 (PST) Received: from [127.0.1.1] ([85.105.252.11]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4ab6a680483sm73983323f8f.28.2026.12.01.15.31.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Dec 2026 15:31:55 -0800 (PST) From: Bartu Alev Date: Wed, 02 Dec 2026 02:31:42 +0300 Subject: [PATCH 1/3] platform/asus: asus-wmi: Fix NULL deref and integer handling in asus_wmi_evaluate_method_buf() X-Mailing-List: linux-kernel@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: 7bit Message-Id: <20261202-asus-wmi-eval-buf-v1-1-640c12d437dc@gmail.com> References: <20261202-asus-wmi-eval-buf-v1-0-640c12d437dc@gmail.com> In-Reply-To: <20261202-asus-wmi-eval-buf-v1-0-640c12d437dc@gmail.com> To: Corentin Chary , "Luke D. Jones" , Denis Benato , Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= Cc: platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org, Bartu Alev , stable@vger.kernel.org X-Mailer: b4 0.15.2 acpi_evaluate_object() reports AE_OK and leaves output.pointer NULL when the evaluated WMI method returns no object at all, but asus_wmi_evaluate_method_buf() dereferenced the pointer in switch (obj->type) unconditionally, causing an oops during probe via asus_wmi_custom_fan_curve_init() -> fan_curve_check_present() and on writes to pwmN_enable via fan_curve_enable_store(). The ACPI_TYPE_INTEGER case also stored the firmware's u32 reply in the signed int err. A value with bit 31 set therefore aliased a negative errno (0xffffffff became -EPERM) and any other value leaked out as a positive number: a DSTS reply carrying only ASUS_WMI_DSTS_UNKNOWN_BIT (0x2), seen on ASUS hardware for unsupported device IDs, was returned as +2 through fan_curve_enable_store() on writes of 2 and 3 to pwmN_enable, which sysfs treats as a successful write. fan_curve_check_present() swallows the error at probe, so only the NULL dereference is fatal there. Treat a missing object as -ENODATA, decode integer replies via u32 and map ASUS_WMI_UNSUPPORTED_METHOD and 0xffffffff to -ENODEV, matching asus_wmi_get_devstate(), and any other integer to -ENODATA. A survey of 102 ASUS DSDTs and the SMM path of a recent model found unsupported methods answering 0xfffffffe or 0 rather than no object or 0xffffffff, so both defects are latent rather than observed in the field. Fixes: 0f0ac158d28ff ("platform/x86: asus-wmi: Add support for custom fan curves") Cc: stable@vger.kernel.org Link: https://lore.kernel.org/all/228df241-da5e-49cb-b29f-6b9158557f55@gmail.com/ Signed-off-by: Bartu Alev --- drivers/platform/asus/asus-wmi.c | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/drivers/platform/asus/asus-wmi.c b/drivers/platform/asus/asus-wmi.c index 552080ff5be25..4f74fdfd7a0c2 100644 --- a/drivers/platform/asus/asus-wmi.c +++ b/drivers/platform/asus/asus-wmi.c @@ -478,6 +478,7 @@ static int asus_wmi_evaluate_method_buf(u32 method_id, struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL }; acpi_status status; union acpi_object *obj; + u32 retval; int err = 0; status = asus_wmi_evaluate_method_locked(method_id, &input, &output); @@ -492,6 +493,15 @@ static int asus_wmi_evaluate_method_buf(u32 method_id, obj = (union acpi_object *)output.pointer; + /* + * acpi_evaluate_object() reports AE_OK with a NULL buffer when the + * method returned no object at all. + */ + if (!obj) { + err = -ENODATA; + goto out_free; + } + switch (obj->type) { case ACPI_TYPE_BUFFER: if (obj->buffer.length > size) { @@ -506,15 +516,16 @@ static int asus_wmi_evaluate_method_buf(u32 method_id, memcpy(ret_buffer, obj->buffer.pointer, obj->buffer.length); break; case ACPI_TYPE_INTEGER: - err = (u32)obj->integer.value; - - if (err == ASUS_WMI_UNSUPPORTED_METHOD) - err = -ENODEV; + retval = (u32)obj->integer.value; /* - * At least one method returns a 0 with no buffer if no arg - * is provided, such as ASUS_WMI_DEVID_CPU_FAN_CURVE + * ASUS_WMI_UNSUPPORTED_METHOD (0xfffffffe) and 0xffffffff + * mean the device or method is not implemented. Any other + * integer, such as the 0 some methods return when called + * without an argument, is not usable data either. */ - if (err == 0) + if (retval == ASUS_WMI_UNSUPPORTED_METHOD || retval == ~0U) + err = -ENODEV; + else err = -ENODATA; break; default: @@ -522,6 +533,7 @@ static int asus_wmi_evaluate_method_buf(u32 method_id, break; } +out_free: kfree(obj); if (err) { -- 2.56.1