From mboxrd@z Thu Jan 1 00:00:00 1970 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: 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, 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-overflow-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ärvinen. - 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.com [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/drivers/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 *authentication) if (!authentication) return sizeof(u16) * 2; - authlen = strlen(authentication); - if (!authlen) - return sizeof(u16) * 2; - authlen = strlen(authentication); size = sizeof(u16) + authlen * sizeof(u16); if (!strstarts(authentication, BEAM_PREFIX)) -- 2.43.0