From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f52.google.com (mail-wr1-f52.google.com [209.85.221.52]) (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 A61ED4334C7 for ; Wed, 12 Aug 2026 11:18:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.52 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786533528; cv=none; b=PBPuhRW3iN8U0j+NhACbph4mee2AVzYN9bW7aq1XfUvZXtJk5ag1n9n5XpMJiohrkEVzUpcR1dWnldDXTqoTdwS5qcUTmy9uZ0xdslJripYoy4Hx6bwCeZH5bt+xN/5YXTGA39gNeeMIUS5iHefAktoHdnfWw6kurYSV3BNYTpw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786533528; c=relaxed/simple; bh=r6Cbjl4OVGNVNoYln0kbEziovWGUtHxY0z02La/a0yE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gZ+YBPiLVXsKkJCFbo20T9/P3+zuxahx/m8EbRrBkyFfLFyXek7ByeK8uMN6mC5PP+1n6H0cpmuadwKWuDzY+hd1FZ36HQFQE3yWoEZ50Y5RI6a7rXwCqR7TFAGNtg6jfvTBuMzH3mF66kPMet+uhEuRwiQFSPvZTcI3Sf1wJrg= 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=UzbaZC71; arc=none smtp.client-ip=209.85.221.52 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="UzbaZC71" Received: by mail-wr1-f52.google.com with SMTP id ffacd0b85a97d-47f703a9e5dso388125f8f.0 for ; Wed, 12 Aug 2026 04:18:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1786533522; x=1787138322; 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=PdRDhdZcnRfVrf9wRzs0djvfPZrw61+L7S7NLduJJu4=; b=UzbaZC71OTzWsdFtBndbCNf8UETNfC/ScfpZqz/Z0qKGPrAqzPGw7gO8LnVLyHnqiW 5pYRqLghuVmA8xy9oGb6Z8F/s1cjyej5Zy1UaLmbt1PcHGXAf12QYO2CKQExxqjjffTA H7eO/dhrZZAozvNdbvrOLlJlTMouVUvhg9v54yQXG6wVWXmRlLRrMRMhrYOKvERi8q/l Op9s2WtGXhjRmeZgSHMti/JyrECACdHsYuaATrnDr21OBr1tAI/Kbxdrx3S4NA7UwVPm fl3PJ9AVRqUvd8XZ31FNkzrEcfmKqIB/6JYjEIyaaTzOAkxxKJaDQV0p/ix93xYm3HYx JGyw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786533522; x=1787138322; 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=PdRDhdZcnRfVrf9wRzs0djvfPZrw61+L7S7NLduJJu4=; b=K8LT0xz6/2GNNQWfgMp7HvISmqDEeu2vPvHSRy5w8v622CizE6ox22M/E0q2HhMgpV bj1uDLJzSnw7pfpyBBcq7RMIVJ3k4sejonppz3Sy0BZbiZOHOeFcSrwkyUD58gJkGl48 gIlz80uo8sXBiYdEgSKb4YSrqYhXzxa3jOg1s3sGhZ2/knLlwzhWn1d8jiHbDQEVr4N2 R6h1/h6HMTPHY5Xpr363xkLNnVwaTen7KfJUOaKDlH/IuxCKsD/0JsCTV1C0DkyyEUzl QxRFPt2IbARM1J27JQBsv+hlNleLIKjm0x8FlTHh11+BxYTN08ugNEc6UhW/OpyAtNMR wjRA== X-Forwarded-Encrypted: i=1; AHgh+RrAASfYiXyM8lqyybXgGuwmLOQx9NNevq4VECuc742ZYbWatUXbMJB2UkbtJRf1WqQCTUi7KcIqGERRR2Q=@vger.kernel.org X-Gm-Message-State: AOJu0YyfEpNiGPlRrv0BBZOUSfXOIR/1I747D3mED4IMKuT/n3IyIBNQ XQAdryYYTv4fNrAaY9KhSsxkaV1hkm8L+W3O8ge9UQloDKiLz+vYXQEl X-Gm-Gg: AR+sD105crYhbG7b4S1csiJBn3lOSyoylf/0XfvS2865kNIhU3CmWYGnfw9GrxLb57R g2n/oq0QfJjNYZ/4ZmmIpRHeLrRat6Z4x9yPglLJx97wIKeS94HJD290GIFdq3kXv3t7sHEA4/j K9ssOQmm+KuBvRaCPAx8qL7ZZkLwkVZCCPmUFTgX4PV1fyGTsRmSyFqvCM5a/pIHC2q0NnAcueS /wC9dHGptgKdaFpD7atCz+w1lNhGnqCBAq/1p04uRglqg3MPAiB0gqq24j2VJLwEN7Ir0VQ9Z1a ilmYJ24Dw8Y24yYHIQMW7U8N9JKiN9klyeKotIoP0TUA2j786s9OsINzOijpyXc8H1BClE2fY/o +wYra/TH3aHFnBrwuYMUI+7qR/61nKRrLb6kkVkvZQTDd87NYK/QkeVErel+2qPpvH70aiZH1kS dMw6KdqZ7y6v8wT3ZCz5Vr19Gec1U0n5W0xm+1w2xJt+WFadFo2mtsS68ivkWmkDznXtRn5vAdh K+mNTK1cAC0R+fHgfZYR0IVrnPHSChlHbxRWJdMOA== X-Received: by 2002:a05:6000:982:b0:47e:9f16:c0bf with SMTP id ffacd0b85a97d-48152c892c8mr5968232f8f.30.1786533522478; Wed, 12 Aug 2026 04:18:42 -0700 (PDT) Received: from fedora ([202.47.63.86]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-48150d702c9sm6670072f8f.34.2026.08.12.04.18.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Aug 2026 04:18:42 -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 3/9] platform/x86: hp-bioscfg: fix heap OOB read on empty password write Date: Wed, 12 Aug 2026 16:18:23 +0500 Message-ID: <20260812111829.172273-4-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 validate_password_input() computes length = strlen(buf) and then checks buf[length - 1] to strip a trailing newline, without checking that length is nonzero first. Writing an empty string (a bare '\n') to current_password or new_password gives length == 0, and buf[length - 1] reads buf[-1], one byte before the heap allocation holding the copied input. KASAN confirms this directly: BUG: KASAN: slab-out-of-bounds in store_password_instance.constprop.0+0x223/0x2a0 [hp_bioscfg] Read of size 1 at addr ffff88811bd8da9f by task sh/13740 ... store_password_instance.constprop.0+0x223/0x2a0 [hp_bioscfg] current_password_store+0x14/0x20 [hp_bioscfg] ... The buggy address is located 23 bytes to the right of allocated 8-byte region [ffff88811bd8da80, ffff88811bd8da88) Reproduced identically via new_password_store. Execution continues past the bad read (the garbage byte only affects whether "length" is decremented by one), so the write completes and returns success; this is a pure information read past the buffer, not a crash, but it is still an out-of-bounds access KASAN correctly flags. Fix by only checking buf[length - 1] when length is nonzero. Fixes: 8646a3b5ee3a ("platform/x86: hp-bioscfg: passwdobj-attributes") Cc: stable@vger.kernel.org Signed-off-by: Muhammad Bilal --- drivers/platform/x86/hp/hp-bioscfg/passwdobj-attributes.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/platform/x86/hp/hp-bioscfg/passwdobj-attributes.c b/drivers/platform/x86/hp/hp-bioscfg/passwdobj-attributes.c index 4d79eb8056a5..86fa03a5ee9a 100644 --- a/drivers/platform/x86/hp/hp-bioscfg/passwdobj-attributes.c +++ b/drivers/platform/x86/hp/hp-bioscfg/passwdobj-attributes.c @@ -66,7 +66,7 @@ static int validate_password_input(int instance_id, const char *buf) struct password_data *password_data = &bioscfg_drv.password_data[instance_id]; length = strlen(buf); - if (buf[length - 1] == '\n') + if (length > 0 && buf[length - 1] == '\n') length--; if (length > MAX_PASSWD_SIZE) -- 2.55.0