From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f50.google.com (mail-wm1-f50.google.com [209.85.128.50]) (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 A0EC6411FA8 for ; Mon, 3 Aug 2026 14:31:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.50 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785767466; cv=none; b=blbKc6yT3JlMqIPYpXJiUUmeEYTYLNT4znRBRNtvfJvN7aDurKzkOHS5U0lfi0vj9UT60ccbL/10QYU4KYO1snMSTnRTe4ye9EOa8ecub2ZxxBBXH6VqrdzCcYU5+tb/YO6SHWdxmuDM3cnFgmJKfmVw1N8YDb9FCXotSeVZN/8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785767466; c=relaxed/simple; bh=ATKvWl1DnIWOGmblRvXvDZPEp2qoEl7qqfbdLw7wl3E=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QDRQndg2QvDmmqvKdlhT7jaw0EWqeem4PZpU1zbFG3RWDPxuN4NbKbOwTCGGkGmQHledWuB31+vRse44CKPvtqeSGCGch3yH0omoB1idqKy60ocgEGucGd6r3A7xl965H8EA67/V0CToy5J/WD6nop8udQvUUssd4YejCDDMNps= 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=q/kKcjoQ; arc=none smtp.client-ip=209.85.128.50 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="q/kKcjoQ" Received: by mail-wm1-f50.google.com with SMTP id 5b1f17b1804b1-4955de8797cso13013835e9.3 for ; Mon, 03 Aug 2026 07:31:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1785767460; x=1786372260; darn=vger.kernel.org; h=content-transfer-encoding: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=GsPuPtlEtpcGKckM/9mBE7kyPjRyXeXRo57w8zpUvug=; b=q/kKcjoQurIZJba6iduZ88NlhqYGrmWV436lC2J0r0OgfmhlU7HLHy/ChZnQzH0E+0 qbxbaWsVedKx0nfbGxpenB1MLHF2P07CU1sowJP/YxrDtrZ71bDRX+naeA7h7EFExxkL x3955u55v7nCzXii+GD4Q+ItEoYZnUxeO0lDGv7uPxWhIP6SZN8aRMu1dTN59dd1BN8N 5pQuOvoyH7wNcCitaOdcwejW+KZcWUFlxUKqHh2DCMwVTcU363/RytNbOgPHRyS+QO1i buofXTMeGWKRokWQgOv2mMgp6Kt69XtiwdOch7CwZM284irOTQBB7wq7sRaYLj0AlnyI tdpw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785767460; x=1786372260; h=content-transfer-encoding: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=GsPuPtlEtpcGKckM/9mBE7kyPjRyXeXRo57w8zpUvug=; b=Zliis8tej9pgMmcSDCikAbt0o12wJQW2FTcjM72RN8tgXSyRfTecbF2SeKEHXvMrfc mCQTBG4APU75ce4q7rVHCpBUzbhWVHUVO+AII+gBa+xOprn6GaQEEtKHKw+k5omV2DHZ XiWJU0mS+381eTuVe50fEb0oQvW2sH7gekhwp66Dw3aEKNlA0t02md7iK50M9XU8kRg/ l5ey+AY8kWd5IVSk9JNZKAV8mmEiH3KO291TQ2tVOEEsmZX6LmDtGGo/CaG4CiQEdtsX EFvA0Bw3VqOI13+GPW1VfT3wO55uO/2+2emkT4NCrbhGsMh3JF3EsAt45pzpXwWXRipP UXZw== X-Forwarded-Encrypted: i=1; AHgh+Rqi7RAX0SnlipT3a/5bNSPOveyxWWQNz/68lKB7i713DAtW9SQWfqmlXUsouA8L902jMmGwayXhKFlvhXg=@vger.kernel.org X-Gm-Message-State: AOJu0YwIqXnWkt5utjBz1vm/wOQM87fw0r9KnD6HCNwKGegSi9c9yuXc ElR/SysqeB376R8raxrHcjhbxfIItRXZjhpN0iCLS2UULQV+UolmHaWq X-Gm-Gg: AR+sD10XMIeckfLIGRFEiWcHWk7r5pgUTEQ7OvE7LUTJNP/FoiFf46b5IA3HtHTLr18 EKoN7HU53UrvqMd7RX7SIJm+QTrHz6pkk81QdfBIwT+15pHIq7iFt4qJqAPMZhvPve0e8N/cQ5P +mmqLjRIcwsdcpZL1xPl4m61pSqF4Y4047qRMZmRnFzallWCybD/0XWwPVwFV0q9qJDhAPsDBI/ vq8LS3wxPX9vK3pBxx5Db0xsHYeGjv9rCmDRj5lNzs5bIg1gbKdgq2/vfxuaNmpd3BMq8wR17pt GtmfEdUDJFpaXcqBh7oFXM5L8Ck6s5DhHhV34tYGeHMRhHt3ql533Zug2TKVmnsaQ9/CCJ1Vu4B ZKISZAM/I4NV1aCstFPnJV3ftjXk3LTN9SdV9FMxkKGkE30BzK7xEg7jJqfTV8gZ+qYQIO4A4tP fWFK5XDYObzKUcLQA5JmrfgsQL+1h+sUeicypQDM1cCCIZFg2hCggy8aQTnqXQyH1/UqCvA7Nef hTJKUup9MpmAuoMYyvpPKZsIICO7lUUZ2aRmCBolQ== X-Received: by 2002:a05:600c:840f:b0:495:5fdf:2075 with SMTP id 5b1f17b1804b1-4980c5fa29amr206226845e9.0.1785767460389; Mon, 03 Aug 2026 07:31:00 -0700 (PDT) Received: from fedora ([202.47.63.86]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49807b98284sm236575295e9.12.2026.08.03.07.30.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Aug 2026 07:31:00 -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, meatuni001@gmail.com, stable@vger.kernel.org Subject: [PATCH 04/13] platform/x86: hp-bioscfg: fix 16-byte heap overflow for empty auth token Date: Mon, 3 Aug 2026 19:30:27 +0500 Message-ID: <20260803143037.93105-5-meatuni001@gmail.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260803143037.93105-1-meatuni001@gmail.com> References: <20260803143037.93105-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-Transfer-Encoding: 8bit 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, 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 short return for an empty string in hp_calculate_security_buffer() and letting the normal formula run, which already accounts for the UTF_PREFIX correctly for the non-empty case; for an empty string this naturally yields the same 20 bytes that hp_populate_security_buffer() writes. Fixes: b2715aa2e135 ("platform/x86: hp-bioscfg: spmobj-attributes") Cc: stable@vger.kernel.org Signed-off-by: Muhammad Bilal --- drivers/platform/x86/hp/hp-bioscfg/spmobj-attributes.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/platform/x86/hp/hp-bioscfg/spmobj-attributes.c b/drivers/platform/x86/hp/hp-bioscfg/spmobj-attributes.c index 4d94e48c1a4c..2d4a3720f80c 100644 --- a/drivers/platform/x86/hp/hp-bioscfg/spmobj-attributes.c +++ b/drivers/platform/x86/hp/hp-bioscfg/spmobj-attributes.c @@ -48,7 +48,7 @@ size_t hp_calculate_security_buffer(const char *authentication) authlen = strlen(authentication); if (!authlen) - return sizeof(u16) * 2; + return sizeof(u16) + strlen(UTF_PREFIX) * sizeof(u16); size = sizeof(u16) + authlen * sizeof(u16); if (!strstarts(authentication, BEAM_PREFIX)) -- 2.55.0