From nobody Mon Sep 28 18:33:29 2026 Received: from mail-ej1-f43.google.com (mail-ej1-f43.google.com [209.85.218.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3029B48422C for ; Tue, 18 Aug 2026 19:11:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787080314; cv=none; b=YlMB9ZwKwHCdBuIhsI6AV5lFxgVMIATZvMC+ul+HmhBjusUc6tHKwfbYEOZRJSKDDQu3To7xd/01qKAMmZyWQiJhei67X5JIzfmvg6yT9qmOmgX9ZHivnZ0f2GDQrReap05LCuIpz9YgGRtxfGymqPwC8/OfF56HQQHdtpTUP+8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787080314; c=relaxed/simple; bh=9Q5eGR71QZ3FJ3qEs4Sx5aEi6jeXzBGzd9U+NtEODO4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=bqwUAupNndIYKLdkTxgVwGMWLKGblS1urgQsYe0u6072dCRYWkEG/dENYExhWfr5KBbSmgkK0c84AEq0Kh8nnYqdr9upzeG4f++b3UcOoRKN91VtKBr+uglmIk7pVtn+D0e1IeqeWZDF5+kTa+7J98IUswQciDgHyKS4QEidcWk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=kal4Nwrj; arc=none smtp.client-ip=209.85.218.43 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.b="kal4Nwrj" Received: by mail-ej1-f43.google.com with SMTP id a640c23a62f3a-c15e592da74so20773866b.1 for ; Tue, 18 Aug 2026 12:11:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1787080310; x=1787685110; darn=vger.kernel.org; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to:content-type; bh=73lLASQPtBYGFw7DMYZ0GmbUquwvaiOv1unAL4Q7bq8=; b=kal4NwrjvV58EH2gWR+tjOeU5UG5eOg4VwBd/JqPCE+wPsYjCujvFCLA/7uhnEvMjO JsrluKJ8wdCSO8TWpqqt1fkUCylZca2sAcGAkbgosioXd0T3Tf9aFKhujD1n69EUdgat RKLaa5hvaZHqWXC75bdg6igySZCcugKYyKjo7FdznxCG+HzIKIozFXGxuwKvBEauO0eQ wvGhQuCL+FnoWuVTOOXbxPgzd/I0hzWt3b1f3Ha9RTxMo5EJim9IxhUKu8cClG8k5IYT KFtjwvz6P3IRvb5/V/rbLd3dm9CSxK1ttHQUPSgjXRu/q04dmP5rjeDEYzekHCNSCaC9 uRbA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787080310; x=1787685110; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=73lLASQPtBYGFw7DMYZ0GmbUquwvaiOv1unAL4Q7bq8=; b=hfa8nbV30zVXZh6uICg90b3pP0oZSSYMRo3XmqLCnUdpsi7WSpSD1OQ2eMFd6Ewhe0 cP+3X35J0mrElPFoGDHPrCttBGYXqlzh7M0ICvKEtfUbeBJbIRohRRoAfzXr1HRPF/e9 +Yre7rA2kMQCnh4dUQxH9Z3cM/s3mQdhiBDjogcgeZNSykYh+Ov0KjF00XSotUoc/hnj vRcUonrh6yoPDfNnpxoxcpIMkfj5I/Wu6Se7GCRSEYWIlC/ZPiILv1Xm5UcTC3iWOt/G m0V394v/ub8jjyZLRjvc38o3bkzad8zHi9lvQoCvaxhtz2PvUtnTbAIi+kd6wagVBggi HWpg== X-Forwarded-Encrypted: i=1; AHgh+RoiB7vfHBwyT1rhvZEg1FwOFb6vw9A4pY8z+lmBy8FH0pQYObirF/ABpTv6EJsXyrykEMeBaPM4CXJ6rqg=@vger.kernel.org X-Gm-Message-State: AOJu0YxN1qB9kpv2yuV5re1S1KcJq463cnyXgFSl2NtiRSctcaYiXyuP SKVsSTTZibjZU4XIaLL+sq8CxKtFSRmRnD4SkYqH6iO8brv3sqlQlUZM X-Gm-Gg: AR+sD13HTYUP6L0ditpEtdbFgY0iFvoIiHSCD7GfJCYOkiyDt4RpawoW8CswdiDN5yH pTGIDLCR+3p+LjrFuL+QSoCkmR5uY1RHx6g4niTtFRo6oh4PmvIykwyTDwbGT8OfLPfWXE3/BMp yatuYL2Y8w0BQ+A9jPD2dxQ7obnclgY8Ibvnlgg/kPHe+/pVm/CecnAkHm/+/HkDJh3LRdgLATi D/EEZhnKuaROJvAUsfPk+Sx1fnHmoPtVNai1TAW+1qIS0dgeoJ/1epTzQBYyCsMrV9d69KKlP4W WEwSAtXv+TJ1n5ayhQH6c9MU1OgOTOQgX75O9KL+JFtzp6WMwu2hcyREZ4/LXHGdZMD3eNATRS9 kwpp/oJ+8vRijrjxwKMstL1nSYqsqLqEe2xxAtPbFfU2cPrr01cEsibsLPDDfzSvxovlxCTRFjJ QjTuZWm9zYnqRjamvxVq9bIYQSjtX9wlVlG5wc845SV+G68scdCNmsK9YQXiEsZ45/Me0jiOpG9 Gzsl1Aet9Gr/VnZv1p7zA== X-Received: by 2002:a17:907:94c7:b0:c21:f41:e192 with SMTP id a640c23a62f3a-c222a0ee20bmr31270166b.26.1787080310180; Tue, 18 Aug 2026 12:11:50 -0700 (PDT) Received: from fedora ([2a00:7c80:0:3b5::11]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-6a3d8531694sm2291552a12.11.2026.08.18.12.11.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Aug 2026 12:11:49 -0700 (PDT) From: Muhammad Bilal To: platform-driver-x86@vger.kernel.org Cc: jorge.lopez2@hp.com, hansg@kernel.org, ilpo.jarvinen@linux.intel.com, linux@weissschuh.net, linux-kernel@vger.kernel.org, stable@vger.kernel.org, Muhammad Bilal , Josh Snyder Subject: [PATCH v3 1/2] platform/x86: hp-bioscfg: fix 16-byte heap overflow for empty auth token Date: Wed, 19 Aug 2026 00:11:07 +0500 Message-ID: <20260818191120.38556-2-meatuni001@gmail.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260818191120.38556-1-meatuni001@gmail.com> References: <20260818191120.38556-1-meatuni001@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable hp_calculate_security_buffer() special-cases an empty authentication string and returns a fixed 4 bytes (sizeof(u16) * 2). But hp_populate_security_buffer() does not special-case that same input: for any authentication string that does not start with BEAM_PREFIX, including the empty string, it always builds "UTF_PREFIX + authentication" and converts the result to UTF-16, writing a 2-byte length header plus 2 bytes per character of "" (9 characters), 20 bytes total, regardless of how long "authentication" itself is. The caller, hp_set_attribute(), sizes its kmalloc() buffer using hp_calculate_security_buffer()'s return value, so for an empty authentication token it allocates 4 bytes for the security area but hp_populate_security_buffer() then writes 20 bytes into it, causing a 16-byte heap buffer overflow. The authentication token used here is the current admin/setup password, which is an empty string by default until one is configured. Any write to a writable BIOS attribute while no admin password has been set reaches this path. Fix by removing the special-case early return for an empty string in hp_calculate_security_buffer(). The generic calculation that follows already accounts for the UTF_PREFIX correctly, which naturally yields the same 20 bytes that hp_populate_security_buffer() writes for an empty string, avoiding duplicate logic for special cases. Fixes: b2715aa2e135 ("platform/x86: hp-bioscfg: spmobj-attributes") Reported-by: Josh Snyder Closes: https://lore.kernel.org/platform-driver-x86/20260402-hp-bioscfg-ove= rflow-v1-1-6985f8c9e67c@code406.com/ Cc: stable@vger.kernel.org Signed-off-by: Muhammad Bilal --- Changes in v3: - Remove the special-case return entirely instead of adjusting its formula, avoiding code duplication as suggested by Ilpo J=C3=A4rvinen. - Credit Josh Snyder who previously noted this approach. Changes in v2: - None for this patch; resubmitted as part of the v2 series. Link: https://lore.kernel.org/r/20260803143037.93105-1-meatuni001@gmail.com= [v1] Link: https://lore.kernel.org/r/20260812111829.172273-1-meatuni001@gmail.co= m [v2] --- drivers/platform/x86/hp/hp-bioscfg/spmobj-attributes.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/platform/x86/hp/hp-bioscfg/spmobj-attributes.c b/drive= rs/platform/x86/hp/hp-bioscfg/spmobj-attributes.c index 4d94e48c1a4c..136585141e6e 100644 --- a/drivers/platform/x86/hp/hp-bioscfg/spmobj-attributes.c +++ b/drivers/platform/x86/hp/hp-bioscfg/spmobj-attributes.c @@ -47,10 +47,6 @@ size_t hp_calculate_security_buffer(const char *authenti= cation) if (!authentication) return sizeof(u16) * 2; =20 - authlen =3D strlen(authentication); - if (!authlen) - return sizeof(u16) * 2; - authlen =3D strlen(authentication); size =3D sizeof(u16) + authlen * sizeof(u16); if (!strstarts(authentication, BEAM_PREFIX)) --=20 2.43.0 From nobody Mon Sep 28 18:33:29 2026 Received: from mail-ed1-f44.google.com (mail-ed1-f44.google.com [209.85.208.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EDEC63A7F41 for ; Tue, 18 Aug 2026 19:11:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787080317; cv=none; b=doAgow88pbC/YVuTvekthqTSyOheJuCKypJYoEePmydtqFIg2EWqKHQW+4pGs1BHIhUGJZ5SS5qddPashzuarzw0HLXK3cBSmgvDOL4o0rf6R9MfGw3wj7KJcAldlJ17IkUEyNXW0rLbODyNZ88DUc9g/WUa5ieRgrtUw3EkwB8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787080317; c=relaxed/simple; bh=prE0cxZeAxUrFNCwuGQT3qOCxUJi84Egaqgt5CsozWw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=rkTcb/0Jfp5kFxBNp6C5B1XLgvjx8xYG3yGVb3GEJNaiOr7kx2PVMUlv7Yg1KEgXCrZm2G8gfkPJFED7l8Kz2ihJv9nzxJVuL8sNGEJxLOh7xcorRObKt8sDGlBnq3mN7gTA+6LHzO6K4uPbFGg7Z1AhB9sudzISWCGcb2+1B3s= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=fYgjWFln; arc=none smtp.client-ip=209.85.208.44 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.b="fYgjWFln" Received: by mail-ed1-f44.google.com with SMTP id 4fb4d7f45d1cf-6a386a34603so251879a12.1 for ; Tue, 18 Aug 2026 12:11:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1787080314; x=1787685114; darn=vger.kernel.org; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to:content-type; bh=CXD7tc6oMBFEmd9i6wgkKuOD03Mu31Lz4UBhvt5Ho/Q=; b=fYgjWFlnQeLQuMHfOq7WtkXNwV3pEcfK9oUDZDgqwkiXpUM4uJl/fI32jGYMw+gO2X 14Tr4HVN/9zeBEB2eEJ+JYx3Crf0MJ7kI/vyEMwAmJb3yXv36pL6O/yRO9/YNMPKH5lm CzonU0d+HYAK2srMK48GTqYIVkiNAQUJHE0+qAc6j9cOp+mmZjG7i+PXD1WymsZZSyKJ opTmOrUxr5nlSZA6lmcCDZZq/7OSX3ipzJ5RyGi0THrIDl9IE6n81vW0PwGS2+kvoiXQ jHXK60TgLS0Ycigs6jDu62WiqkTNGQ+JEclEis3eL8GwFzil4457KTUweuhdmK/KaEyM zO1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787080314; x=1787685114; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=CXD7tc6oMBFEmd9i6wgkKuOD03Mu31Lz4UBhvt5Ho/Q=; b=sFI/RK4N3HVIyu+qUmkYLdX7gAGjNWFDQNNdy9yT8FRAjEAkwO3BFjSJQ8KAVtaxFU GB6z0rgZCcf6VrVN3mufx9iHOtYSduYN5mNUgUw4nb2zQHQunFGLzu3Ph+zIOx+5upmc pBQdaUHXTHRbTAhA3ILCMIt//ntSh8S48BjO4mOKc0eZCbUMGtGmx9YJYrA2Z5UQzcCY ZBzfu07hsyvOP8o3aUcU3wGYtuluZbV00cYU9r0EGQc5vRLpaUSSGQEcTo4/Co7LOc8O bh7SyNhVoFoVFaUV5wBz6TCWbWN9m4rPoh+F62ZxC5dpvXkLD3EAeIHdltAb4//NGGx0 S/8Q== X-Forwarded-Encrypted: i=1; AHgh+RpNXzmd/0qQyjBzOzyoKE+6NJuQQiIvb6Smz1iOvnYj3AgeCDY87TjjfQcGGlQGBFE+WqhLLPxzqGcmihI=@vger.kernel.org X-Gm-Message-State: AOJu0YyvXWA1cOKMvjg5OAgeMAYhAnXyuenMvPzS9ld8qOyJJOzb4Knk 4MF+M2ecw+vytDzfbPajnlMYzad2nHinG9HZN/x/sP52BLbIvbZ+jqxY X-Gm-Gg: AR+sD12eCPaBiiVUEa56ueR8q+iUZSGSoQ5OpsvCkW1Lh2S4ChxWLjXQZ604225KdXy f8UCDD9KQsF//J5ymIXd8zyWtbpK2ypYFzWdxNgkFYgZxGac4hhbo0qo58P58vkq5nNI+jVd5Xz tYv+onfGhUls3PRyVUIrOG+cag7BJkkKFhjkYkxD1boNDlq9RezPeesD2amFQTa3QRisL4TsHhs +JDr1ygTR52e5wRp4ZPVzr59MjxFnRpslkvoS87P/IokYb5fJXy3KgmwNh3/Tv5HSwoATDJ72RK fiqxw79Hp1S+YeKTk/7tS5stHB4prb8Bj+rDGOKAte9zmdcf1vDpkqDVwOHo6VvZx6aXgNPgs6g 3uRsk6TaFD029kDdIFlMIFBzxWP5JUsYDt3DjxxCwC59frmn5zR9l5BRhvPpEYxtO7Mov/RJ4On JjznM7+BMaN14i2DOrUwYBZZKRbPHOk6OaI/YCDyHMTMLN6OwK60N1qlccTDn/QuOJJ+dyFIbwM RJw+4g0FgteVlhTO+Z5iA== X-Received: by 2002:a05:6402:24cd:b0:6a0:9ce5:3f5c with SMTP id 4fb4d7f45d1cf-6a3e3c986f2mr4530938a12.7.1787080314075; Tue, 18 Aug 2026 12:11:54 -0700 (PDT) Received: from fedora ([2a00:7c80:0:3b5::11]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-6a3d8531694sm2291552a12.11.2026.08.18.12.11.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Aug 2026 12:11:53 -0700 (PDT) From: Muhammad Bilal To: platform-driver-x86@vger.kernel.org Cc: jorge.lopez2@hp.com, hansg@kernel.org, ilpo.jarvinen@linux.intel.com, linux@weissschuh.net, linux-kernel@vger.kernel.org, stable@vger.kernel.org, Muhammad Bilal Subject: [PATCH v3 2/2] platform/x86: hp-bioscfg: remove dead bounds check in audit_log_entries_show Date: Wed, 19 Aug 2026 00:11:08 +0500 Message-ID: <20260818191120.38556-3-meatuni001@gmail.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260818191120.38556-1-meatuni001@gmail.com> References: <20260818191120.38556-1-meatuni001@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable audit_log_entries_show() checks "count * LOG_ENTRY_SIZE > PAGE_SIZE" prior to entering the loop. Because "count" is already bounded to fit within PAGE_SIZE, the inner loop check "(LOG_ENTRY_SIZE * i) > PAGE_SIZE" can never be reached and is dead code. Remove the redundant inner bounds check and eliminate the unnecessary "else" block after "break" to clean up the loop control flow. Signed-off-by: Muhammad Bilal --- Changes in v3: - Remove the dead inner loop check completely instead of adjusting the boundary arithmetic, as noted by Ilpo J=C3=A4rvinen. - Remove the redundant else block after break. Changes in v2: - None for this patch; resubmitted as part of the v2 series. Link: https://lore.kernel.org/r/20260803143037.93105-1-meatuni001@gmail.com= [v1] Link: https://lore.kernel.org/r/20260812111829.172273-1-meatuni001@gmail.co= m [v2] --- drivers/platform/x86/hp/hp-bioscfg/surestart-attributes.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/platform/x86/hp/hp-bioscfg/surestart-attributes.c b/dr= ivers/platform/x86/hp/hp-bioscfg/surestart-attributes.c index b57e42f29282..3b20757a3e74 100644 --- a/drivers/platform/x86/hp/hp-bioscfg/surestart-attributes.c +++ b/drivers/platform/x86/hp/hp-bioscfg/surestart-attributes.c @@ -93,15 +93,12 @@ static ssize_t audit_log_entries_show(struct kobject *k= obj, HPWMI_SURESTART, audit_log_buffer, 1, 128); =20 - if (ret < 0 || (LOG_ENTRY_SIZE * i) > PAGE_SIZE) { - /* - * Encountered a failure while reading - * individual logs. Only a partial list of - * audit log will be returned. - */ + /* + * Encountered a failure while reading individual logs. + * Only a partial list of audit log will be returned. + */ + if (ret < 0) break; - } else { - memcpy(buf, audit_log_buffer, LOG_ENTRY_SIZE); - buf +=3D LOG_ENTRY_SIZE; - } + + memcpy(buf, audit_log_buffer, LOG_ENTRY_SIZE); + buf +=3D LOG_ENTRY_SIZE; } =20 return i * LOG_ENTRY_SIZE; --=20 2.43.0