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 E2FBC4334C3 for ; Wed, 12 Aug 2026 11:18:41 +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=1786533524; cv=none; b=V7JqsNfYBxe9Sfm9ju1rDgmO2GXTozWfGBolyCrwtzRH79o2e0g2uPyQ3DjTlcVie4nmxnsG9jYSgRnZngVQ8RfqR3Jzg5jDutdH/6HQgHa3zU/hs4PPrgrhKbNw8zbttPuMe/w/lXRT7vul/vWTZNDP9zleL0UfZ/vho9FLF8o= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786533524; c=relaxed/simple; bh=GXnVaGcOYcGeGF51vfhkksxSxm5iT6MduRJD27H8KxI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=nz2UImnGbVoyIV7E09yj//vWj12OgcvWAkW7tLR43bh+DaOG6t8uuMyWYZUUOm46fU9xnU0P5jJal8Txq50NPKn2h3G9Capu/1XUH8dfTmqH27/nJ/1N/y/SR3rLju2Okt/vyxvEmVeu4jIbdUvqpguuPQEBHg+EcxVwxZuSQm8= 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=NBLpEhoH; 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="NBLpEhoH" Received: by mail-wr1-f42.google.com with SMTP id ffacd0b85a97d-47f93b2fe4cso450054f8f.0 for ; Wed, 12 Aug 2026 04:18:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1786533520; x=1787138320; 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=jRznYyon0XGUdVgbipyEvsqHsHiyM4eqeCRczfbwZQQ=; b=NBLpEhoHisei3vTNn620D1jR8HVSu9eBlNFN5zSLwKEICdz1JIF+tsgwOr9ueDu3c0 D2rTx7iFOFnWn8HqO4aendeFaiZ3QAX/Gw+lhmrVDHH653d8lpTCTpn2KZwpwoZAaSuj MknykyhSrcllnMxRCgzQbYR8EJoDHLB93eBCNe8p7HmfiPeJDll90CHlAoUSwHObS+zM BN02A6ffudM+7YKi510eVnBM/2UXM49cQzBZP0WFIGcEw3++xzvIGuYCD0tn4FAj+0of tGYFoI8c0yDbqZo7eTohHw++CzZBGEbiRPGzkV1j9rIuLjcK9in+H3hji83bNORDVZVU IZWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786533520; x=1787138320; 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=jRznYyon0XGUdVgbipyEvsqHsHiyM4eqeCRczfbwZQQ=; b=PG0PYm6e+4Bzm5vDc1yOuntERmnJ7rH7ZmzTmK51AZAr98HJrkAwaS1Q9YI7Aer9fB yGsK466cWCCFwktqLcQybDeqozG3RmMbtehabZ2ag7xjqamdfWamOCExToxiD5TIlEuX X42650hqLrXMd9kr40Qv3yBkCD6dR6klMrGsMXZHVLkg3Sr3EBIb9jDYCoUlzO9UcDmc 0TNm4gaqcibOGYrGIIbUBJvU3bW/wFMGcU/GYZltKla8gUp3BMpT5ej7ZG54Tc9MRtxm eXnwgPDJrJyGprNuSrq5OhG7rSaNL/tU4n0v+2Q0z2F2MzGhe08vyZfFJGfwax4+EKaM 6F0w== X-Forwarded-Encrypted: i=1; AHgh+RpkMLCdrlnbt7BLqe6HG2HttrS+qA4CbF1cW5Xfjwj05sPRvB2Atpv5cBJU1tcj20MJeUnjB6ZnNrJIsNM=@vger.kernel.org X-Gm-Message-State: AOJu0YySC8WObq55FSgW3Y9Z8yqpYgw1gBZhL4nOeg/1TFY3Bygl1Vie BYITjiRSOl5pH/AVw1FfWbQig8+B/5AR7m1r+o0WZfezjj1fEPLh87up X-Gm-Gg: AR+sD1355F579GUMLYTmyXJqFg+5zZhqNtpewdGPxGT4lzbPHrM60Y3S/Ush8ShwIL/ K740YSBpYFAilEh0/my5zS9estSz6mJgMDwR/nCpMyn/wab/opD+hbzXPHMPFUsyT+kpMRadNxY a4Y19rRq5JumXgLSnWRQd9LPNna3v1syz3V/nhzHmFzEEJrNhW/qjUymYmUuUCEDXLKNXUXL2UN 4I1ISM1oP/s8XlLoS7anyadpF0UB2PPlcOzYpJukOXtF3BLU4ESAvQ+okNRg9dgwdwe3ImKjARs K4UuR4d2Ed3+wPbVX7cUd8Z2davmSq9xjZ8YkbfTwBb1rVq7AvbJuIi91/A6GZquY8t1KzrlKHk yJ9ho1Dd0Sl2XjMUBc2BD5LyUCnACgWtRvhh0yXGAWcSaiKjZCyYa1Yuf5CM+F9/iSRMFkcJ8x2 jiJGaR2b1hyt2y7pIEOJAWMbNRirwzOIZotxK/W8pGN34KvJaCDsWkTbXpE2G4Bp0Ej1hrxu6zO LKw4Gl9SQcpwSGydhrPaH1bdftu4rAZo6ZaYlbNJw== X-Received: by 2002:a05:6000:470b:b0:481:5657:5299 with SMTP id ffacd0b85a97d-481565752a7mr2352055f8f.0.1786533519885; Wed, 12 Aug 2026 04:18:39 -0700 (PDT) Received: from fedora ([202.47.63.86]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-48150d702c9sm6670072f8f.34.2026.08.12.04.18.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Aug 2026 04:18:39 -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 2/9] platform/x86: hp-bioscfg: fix heap OOB read in sk_store and kek_store Date: Wed, 12 Aug 2026 16:18:22 +0500 Message-ID: <20260812111829.172273-3-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 sk_store() and kek_store() strip a trailing newline from the sysfs write before allocating the key buffer: length = count; if (buf[length - 1] == '\n') length--; bioscfg_drv.spm_data.signing_key = kmemdup(buf, length, GFP_KERNEL); but then pass the original "count" (not "length") as the copy size to hp_wmi_perform_query(), which memcpy()s that many bytes out of the "length"-sized allocation, reading one byte past it whenever the write ends in a newline, the normal case for a shell "echo" into sysfs. KASAN confirms this directly: BUG: KASAN: slab-out-of-bounds in hp_wmi_perform_query+0x1e9/0x460 [hp_bioscfg] Read of size 28 at addr ffff88813c8e2b80 by task python3/16022 ... sk_store+0xa7/0x240 [hp_bioscfg] kernfs_fop_write_iter+0x3e1/0x5d0 ... The buggy address is located 0 bytes inside of allocated 27-byte region [ffff88813c8e2b80, ffff88813c8e2b9b) Reproduced identically for kek_store, and at multiple write sizes (28, 57, 201 bytes), each time reading exactly one byte past a kmemdup() allocation one byte smaller than the write. Fix by passing "length" instead of "count" to hp_wmi_perform_query() in both functions. 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 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/platform/x86/hp/hp-bioscfg/spmobj-attributes.c b/drivers/platform/x86/hp/hp-bioscfg/spmobj-attributes.c index 2b00a14792e9..4d94e48c1a4c 100644 --- a/drivers/platform/x86/hp/hp-bioscfg/spmobj-attributes.c +++ b/drivers/platform/x86/hp/hp-bioscfg/spmobj-attributes.c @@ -238,7 +238,7 @@ static ssize_t sk_store(struct kobject *kobj, ret = hp_wmi_perform_query(HPWMI_SECUREPLATFORM_SET_SK, HPWMI_SECUREPLATFORM, (void *)bioscfg_drv.spm_data.signing_key, - count, 0); + length, 0); if (!ret) { bioscfg_drv.spm_data.mechanism = SIGNING_KEY; @@ -274,7 +274,7 @@ static ssize_t kek_store(struct kobject *kobj, ret = hp_wmi_perform_query(HPWMI_SECUREPLATFORM_SET_KEK, HPWMI_SECUREPLATFORM, (void *)bioscfg_drv.spm_data.endorsement_key, - count, 0); + length, 0); if (!ret) { bioscfg_drv.spm_data.mechanism = ENDORSEMENT_KEY; -- 2.55.0