From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f42.google.com (mail-wr1-f42.google.com [209.85.221.42]) (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 F070A435AAA for ; Wed, 12 Aug 2026 11:18:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.42 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786533529; cv=none; b=cvaUj12lWr+SsINo1uyiobS7Ila73AX4mUow2ATvxbtpqdkUr8Z28zmq82gq3fiXh7UrRphcN+lbKnOF2DYOQQiJA0KZRAaci5tE0P6ezC8ALsqNJmZSCn05sISC5o4xtd81oT6lqx5ibxh4F3z7kwCvndmD5qBG197MltA0sBY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786533529; c=relaxed/simple; bh=ATKvWl1DnIWOGmblRvXvDZPEp2qoEl7qqfbdLw7wl3E=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=egzDvCflUzwl3YJoTVd8Q9JjXhSnXKtcm/vzs315e8rVzJDZVplmsEZAzk+HesKBUMQojTX4cyJsBzth71SNOu79xVYB/MkShG+glabr/q6TrV4bYM+7UQVHbXDhBVsJ5Dxr1rR5RpRiUcFoo8ilmZ35XVeexYdmlo1DIwCtAJA= 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=UPoC98/8; arc=none smtp.client-ip=209.85.221.42 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="UPoC98/8" Received: by mail-wr1-f42.google.com with SMTP id ffacd0b85a97d-4798bea72f9so404458f8f.1 for ; Wed, 12 Aug 2026 04:18:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1786533525; x=1787138325; 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=UPoC98/8UNWIKkpjNwtvUiOxBBvc4dwZSjOxGo02t+ZvsUrufig+2dJGuYtqljphic LwpkDLlXJIZTnlPwuA7MnKUm/+ZCbZw7XcSwlkqCqEEeVZHp/o2LDXqtqTXAfd2eauYj IZw8UCvL0oF+Qa1rNY9DYvxqnuZXQIjocG2Bz2Rs3tfFKyGHMO4KQjwU7AZOxERacwHn zwB9D16yxn7sfDybvIgNZXPL5UWgafQfBJOJlgW0CiMxK9+8VChVO2sOkiv4AhP4DlUx 0JEBThkNVcmkk6OpTawx0RQ/J19ccdm7tw6Sde/gHojH1BAnDTK+3A504aDg2Lmcm1ct D26Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786533525; x=1787138325; 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=T+4NmvcQBNuPcngqM3gL5ANxxG1o8DYCCrYcsH/xEu3ULGt1iZn0L9zyRi6+D+O1Yf HuK0NYsovGSyQ34758eJWZARV3JTwErDYhY3ime84eARp9g63mtEHiTelPT8iShpNZYo teiqllrAcNYuRm1rs5lrX/q+Meh91v792sSPHQ3dLv4IzRur34138s7n7yIY7Ry2ePGg x8MMCvo9ECIBjjUPuWOL5+4kISG21+W0rKrAgrMqOIAOsPNO93SD9ppmULQNp88FHGDO qLHmO81i/7wFndB8c0XhED+dd+zy1RjoWbivlXelccHvdSEkIIqdiBs3RMpiIYoIuaSS rJag== X-Forwarded-Encrypted: i=1; AHgh+Rr9nuOtPajSTABcwljuj+yAiVtIUZbazzOxrPdoLXQcaXl7qvxncHuKpLpfTDsf2U5vV2O1oMHDjhrzYwk=@vger.kernel.org X-Gm-Message-State: AOJu0Yw+0LDDFhDXDv+tgVBudZ3D3BoNWZyaBWT3Wph42WCyOCEXwDyl aZDjVKvVcMnt/6b3qyAxeCu6P+N7JWhEM02Z/A0KtAnR92p3T1RwGWnt X-Gm-Gg: AR+sD10fxHxfavJwP9Bd8vtmKZkkDsxhea+11mc63GGW79EHUnsIFmsgnh6NrysiTsZ gILLyOw1WZl5wcNp0Wf4PsfnmmoNH2mcBU8gAbOssUBZXuQGBlfJJ4BbUgOla345AZLCT+oeLHP 8irhKuFTBS7b9Okjsa3nDs9lUWsuNk5VvQa7MYjx2oijINb5GqJTUVEXlZXIX9faHGC37QRE/Zr A8iaxfIckBPmBsaHaX4kLv3FJZpbq6Dx5WgJtgqD34RHisljumRFzYGCUjPU9KZgDoRZcoB2lWA 7+BbxpS7n4IYWbzEsAEDhWFQxOUNM3zK5JHi6cGjlQ14WTQDrdQ+OzIKALSvDwv6geTgfhWKfiK 748VxCVOlpAua41tzsNfhtUMxqkJb57WoqzF9aWdoAKGAyiWhA3g4dsKB1414Ta7gPBipMFXcu4 aZvo3duQj9ecd9bpG9KDMC8VfoU1C3RX0bzqBaTteYrVrPY4/NVqQ19aGyreh1qOzvR+0OZjqyk leAyQ/HnQOPJr5xzCp5Xsf5bzze8L6yexQ+2IW6Yg== X-Received: by 2002:a05:6000:2a89:b0:47f:e729:c588 with SMTP id ffacd0b85a97d-481528d77cbmr4832014f8f.14.1786533524857; Wed, 12 Aug 2026 04:18:44 -0700 (PDT) Received: from fedora ([202.47.63.86]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-48150d702c9sm6670072f8f.34.2026.08.12.04.18.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Aug 2026 04:18:44 -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 v2 4/9] platform/x86: hp-bioscfg: fix 16-byte heap overflow for empty auth token Date: Wed, 12 Aug 2026 16:18:24 +0500 Message-ID: <20260812111829.172273-5-meatuni001@gmail.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260812111829.172273-1-meatuni001@gmail.com> References: <20260812111829.172273-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