From mboxrd@z Thu Jan 1 00:00:00 1970 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=1796392519; b=W3gJbJVHrYXDxdwETgaP+mLhU3j6BBEJj4rdSH7FuUh2KnLAYMwMN2WrA+LbmQqvWFje jiva8r+WuMk/ja9tl1sdI7VNBywP1CmFfbP3ov5WL0K25JFq6hoXna6bepLcL3MG5ynYT FpHfIeLJ4YW2unGFVQgoiEtA8cEmiLSeja/7RHROola8v5Sxg4GlX9ImQ9ctU1jKODfZO DEpeRvJd16ijiWUfsMSHkFxOsk/GL1u5qJVzrq3xIozeMCO2OxtNRgs8pnq9YuoyoEvnX Xgx6burYh7BGYura+3ppf2oegrvtNydT9UmBzq71nMSMC+e+B3Mgx0qzbQhwSUwxcng== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796392519; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:MIME-Version:Content-Transfer-Encoding; bh=BHqZCGZ87HUje8IDvOt6KgVatcIGp6IwYJVWLRFytLo=; b=34GlOyPZlpytSRL3Uw/Hfsc6kb58Xg50oXxUvSiwjWrmg1bcgnXORJUH7aM+L3473vDZ e17lEyT4ycvbQxxDvyeDCoE4tAMR1F84kNunWH6VsiTlHMnackEUHmN/ZzxKMTFrhfML7 fZWjFVr6jmNkyKwO5xwGwCqsBo1VhHHd2CuHES9pQuz64z6lj4mNSD6McNL8nSZDr2Nqt dgdeRjrqcRFHW8PHugLOx/oulUeA0Ojm574VHWkzdXZb1KDPTSRfStQ4DTIULK/owgAhS Cwc3sxsDnv5744+bUNu2dWX9kvYi74NdJwPwJJFlGEe3VSGcocUgdryXckIhJUVeHFg== 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=oYNrYYwv; 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 CC967606A33E for ; Fri, 4 Dec 2026 13:55:19 +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=oYNrYYwv Received: by smtp.kernel.org (Postfix) with ESMTPSA id C0ABA1F00939; Fri, 4 Dec 2026 13:55:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796392519; bh=BHqZCGZ87HUje8IDvOt6KgVatcIGp6IwYJVWLRFytLo=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=oYNrYYwv+42GTT4Vl7iLoZPHRyeMpRmUGZvpVK2yy3h5bup0oDQqNZ+tLQvc8aY8L Py9VYCH4yRTPPVNYDA9NbXxXohouF2C4s7REgIlET/ugITC+nxFlnuFcPQWXRt0Ln4 oWKOKv4G2/0Hd2piQwyObb44kSIvMEhwQr+u8y/rnDQWRXxJGoGCg5j5zdnVU2VwgO pLyWDlmFcgtCpVkMJoIZQ/PZaC3FbGcmRjlXjBgExGAkIpAJ8lZJZA2MovC9g4wUS9 wN719ZZNZ3U6kDxL34JHJoh/uw1JTFjI4rWuVNBdPFUQ9zPZqg+fGVu7agGjkLmnf3 tvcLD+2WUdhgQ== From: Sasha Levin To: stable@vger.kernel.org Cc: Rosen Penev , Guenter Roeck , Sasha Levin Subject: [PATCH 6.1.y] hwmon: (dell-smm) Reject a fan_max that the BIOS cannot take Date: Fri, 4 Dec 2026 08:55:17 -0500 Message-ID: <20261204134541.3190996-1-sashal@kernel.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <2026120340-germless-unfold-0b35@gregkh> References: <2026120340-germless-unfold-0b35@gregkh> 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-Transfer-Encoding: 8bit From: Rosen Penev [ Upstream commit 69624d7d821ec7d3f9801e86acf555a8edc82f99 ] The fan_max module parameter is used without any range check, unlike fan_mult. dell_smm_init_hwmon() allocates the nominal speed table with devm_kmalloc_array(dev, data->i8k_fan_max + 1, ...) and fan_max=4294967295 wraps the count to 0. devm_kmalloc() then returns ZERO_SIZE_PTR, which the first successful nominal speed call writes through. Values above 255 are also meaningless: the fan state is passed to the BIOS as fan | (speed << 8), so the higher bits end up in other parts of the request. Large values that do not wrap still cost one SMM call per state and fan while probing. Fail probing if the maximum fan state does not fit in a byte, like the existing check for fan_mult. Fixes: 81474fc2fae9 ("i8k: Add support for configurable maximum fan speed value") cc: stable@vger.kernel.org Signed-off-by: Rosen Penev Link: https://patch.msgid.link/6d3b86acf6713e9286e60ecf788582e840946238.1794633179.git.rosenp@gmail.com Signed-off-by: Guenter Roeck [ sashal: adapted the range check to dell_smm_probe(), using pdev->dev instead of the dev parameter since dell_smm_init_data() doesn't exist here ] Signed-off-by: Sasha Levin --- drivers/hwmon/dell-smm-hwmon.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/hwmon/dell-smm-hwmon.c b/drivers/hwmon/dell-smm-hwmon.c index 357aad3d009b4..4110c144e4f8a 100644 --- a/drivers/hwmon/dell-smm-hwmon.c +++ b/drivers/hwmon/dell-smm-hwmon.c @@ -1408,6 +1408,12 @@ static int __init dell_smm_probe(struct platform_device *pdev) /* All options must not be 0 */ data->i8k_fan_mult = fan_mult ? : I8K_FAN_MULT; data->i8k_fan_max = fan_max ? : I8K_FAN_HIGH; + /* The BIOS takes the fan state in a single byte */ + if (data->i8k_fan_max > U8_MAX) { + dev_err(&pdev->dev, "maximum fan state %u is too large (max %u)\n", + data->i8k_fan_max, U8_MAX); + return -EINVAL; + } data->i8k_pwm_mult = DIV_ROUND_UP(255, data->i8k_fan_max); fan_control = dmi_first_match(i8k_whitelist_fan_control); -- 2.53.0