From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f52.google.com (mail-wm1-f52.google.com [209.85.128.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 885E3378D74 for ; Mon, 3 Aug 2026 14:30:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.52 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785767461; cv=none; b=s4rkGhhXtRTXK8hxny3C8dJcPUsbbyjTyOM56xxoiIThHSX481ioUdBmOivzvMTHHErbd08tJVbVyfMhLNBk2uCMGUU/L4TQ3c69W/EP6coYkk19qKhQvjNArJeGdZ1ZBHiKocUOQrOovuOCR0MnIdVTx5ygRGtfDaQkeJ14F1Y= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785767461; c=relaxed/simple; bh=GXnVaGcOYcGeGF51vfhkksxSxm5iT6MduRJD27H8KxI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fiOzrXqnNhgsVR8QMLNJnr3YiinlE7wOShNLTuWTkTU2Ep8fKN7kxd5mpcTjf2ecv1mjkHGYBI3z9Fgq21ATsrlrik7hcA/kGx3NdG8gx6xAJBpAVnILSSDl8q1Eo3r4Pb6FsLlOKAt0nmBm/mJmNf7X3v0IfAwX7WscJRn/O08= 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=cMgunFXV; arc=none smtp.client-ip=209.85.128.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="cMgunFXV" Received: by mail-wm1-f52.google.com with SMTP id 5b1f17b1804b1-4980dc26022so13781915e9.1 for ; Mon, 03 Aug 2026 07:30:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1785767455; x=1786372255; 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=cMgunFXVWhAQ0qA/a8BWNqAE4aMvnXbCv+t2appMzu75LJ6iLzHYzH4FrpXyv6xGvu 3lyZWCK1VE0nU6bVgCsWufB5ElqeEzSEU4s3ZO2gFDWkAPNYfMh/eldeTQO40U3Nv1By ut0WeWBmoWOeod3dBUQWsbu9AGV9Smfe1GZfsdu/3jXYzk+cDRzO2pJEKNs4tD+MIcFL zxL4ZOoX+1ZYpsMXJhwaR3c6xhVJ3Z/nFgotwoQLlkAh1v/t2yoFn7auBmbDDWaagifI 6nywVuzr4zB4QNzezEq7c12+c8H/OBPYEfyposjxzs70p1xySaFcKffkBnGqoANG/LnG /Xdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785767455; x=1786372255; 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=dcaPPpc2jiHfI6mwe9AM37LTpZ6pjFYAB+sxJa8SYKosjrkOCH9wTGv6pTfGu3kcDn KIcE28ZyzfYXPnBc4MkJsBe+Jo3Nlguue3vXuM2cX18wZ0D6/GE2cGXGvMyN+kKhnbyk NYNWJTKfQI/gjb6IYM7NKMow5phFg+MF72xfU9xWnLQ1vVlVmDBjjQ/PPBaEt2Xdg7+8 Y1f8j2QV1JnZCl58zO1R1mfSLNj7okEGF+iXCg3W4uim13lz3OFka5Ew61UyNQDTdLUz L/hhHY8lBJef9Z8HKitqx0leWFgTItT/ewX/oBM1L/EEwpt0JlXDPoJ5zOqd6j3K7KdK yjXQ== X-Forwarded-Encrypted: i=1; AHgh+RpiA+6BhwofbkBv8ig07XX6/wPm/f/K+HGBKncTriOlNG6T+t1FyLn9qTc6vZByHQU19YAgWOgXG2OP9c0=@vger.kernel.org X-Gm-Message-State: AOJu0Yz0DPfTe747RWYHxUgM3E+Z3/stmyXllmmBJpd+zQ5pHLYVnEqt AllU/xIIvwhZHTVXefL0MUCVAFhfRwVKUv8zXeP152rnA01gS1i5feWm X-Gm-Gg: AR+sD11LqpkQf1gtlew9ECPkPAJu1Snl7x+wBiLcnRdz2RJNk/J1Uwm/QfrV1ogKgsx i1Z4m6unlInnFW8+eKnZtTkHKCUywV87VEgj7Bmmny+u5DlBlyEJvm3rgMuXtsITmjittKQQF6j Bio8JKyrFvztnE3smRZY7Tpuds/nxfKsz9xnucEgIjA2UCVecm+lpSDlIZDK4CrGCEZk5Cj5Toy Yhb7FK50M0Gis7HOi55HKLGWXiAGBzcCcDsLo+ZIMtuGz3SHyfpaivoVFFGrAvsiMBIxcFggNSd MJef6xI+DB7/8Ed3NWIdm6XU91TnWGx1yh1HkKRSsPN+l3Q0yhtNH/jjLrs552sZ+PxqMhg/5Kl LC+v0BNZwvhC2pLmikSShplj5PaYxVIM1eXeSrnVvJD0lTLCbBwMOQQcj9mPXoWd3mwJC/YnSmS dD6SFRpWQrDzmwLHPmu1DAeqOmREowCcBXJUoeNbQscZf8dzjNWH6TfcxeB6TPNIY2YXvve0Tmm TWKGTD7fqvKJNCQYsanksCNFaYuFx6EdpYc7g1WdQ== X-Received: by 2002:a05:600c:840f:b0:493:b6ee:fcb7 with SMTP id 5b1f17b1804b1-4980c6507e7mr211322355e9.14.1785767454564; Mon, 03 Aug 2026 07:30:54 -0700 (PDT) Received: from fedora ([202.47.63.86]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49807b98284sm236575295e9.12.2026.08.03.07.30.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Aug 2026 07:30:54 -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 02/13] platform/x86: hp-bioscfg: fix heap OOB read in sk_store and kek_store Date: Mon, 3 Aug 2026 19:30:25 +0500 Message-ID: <20260803143037.93105-3-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 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