From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.180 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796452549; b=ABf4ANclHsUxcgtySK1jp4DC7Pi6kK5loKWXL0AWmeJouzJSi2kG9X9kLoW0RqFJw3+U qD19mPs9rTh+uIbRmlfcSpCKpIP8qOfID0oWHlMkfwBbbLMveqwq7IHQCqD9IGKmcs90H SoJSWIQithzBDWL49u1BbEEUfPdN5FAtMAFOxuOSKfepVxtoZ7iasEofB+Fm6irRVqndL Gw1Mbay0pzRx2zsGWoqNiz/Wz1meNGroeeuq0FhKYmiMAS42Da49babJh3nTQkX50zC9V e1tvVwosnw051DfxGV8lpraZeB1qOJAcZolo3OnsaTZSgy+2kl0Z9m/LTkiE2jXqfwQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796452549; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:To:Cc:Subject:Date:Message-Id:X-Mailer:In-Reply-To:References: MIME-Version:Content-Transfer-Encoding; bh=VU95cFkSAn69TuDw0TbCdkBN67NMzMRSRJdSDSIjX+Q=; b=S8OLglASXqp6cyg6IWQHq/kxo26j0vKcn1uRiAjRVlnkYllhZo9oTI7oDdrcusqhjU1M RIF1icJNrB+PlvPKHauWCDiQdsu742D4NAzJ/ezhx+TATnTK3oxGfA6Ps7l355Ru8jl7N qQdbCL3tnkeWL8aiSMmRABpJgT1cT7uBsRJHiRwF1hqqYeT6SAVqK1uSHSDIe/DSzLPgJ e3gN2T+6xTrSqs0Erw+cxMHT40jlqkFakyg1OEmkc2TEYbJ5iNmbXO3cayOdmtBufzDJK BM2fwXyZxcT2JGM6uzc+xprqPIMXm2Oilf4rl9SJa2OF5eZjTDGKAcjukOo36NjxrIw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=yHn4w1Gv; arc=none smtp.remote-ip=74.125.82.180 Received: from mail-dy1-f180.google.com (mail-dy1-f180.google.com [74.125.82.180]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C1A0E606A338 for ; Sat, 5 Dec 2026 06:35:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org C1A0E606A338 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.a=rsa-sha256 header.s=20260707 header.b=yHn4w1Gv Received: by mail-dy1-f180.google.com with SMTP id 5a478bee46e88-387486ad5abso2649893eec.0 for ; Fri, 04 Dec 2026 22:35:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796452548; x=1797057348; 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=VU95cFkSAn69TuDw0TbCdkBN67NMzMRSRJdSDSIjX+Q=; b=yHn4w1GvbZnx3X5tVbJojoJTnsucR3NISZ05p/TwN4WS+Zq9DxO5S0Cwn/b1cvnKFT 2qpnZHYLjWednXKx0E5Pdp7Jfu1KMhVkkrKhtmlwN1fI7Py32zvSxXF+JluR8XfofIrR ObszqfqjCnHb8YBhtz2AsRUoR+/1HSilLze7esPDnOdRVhGLCf15QnEdW01QAKUT6ZFp jgJmHAmdvY+IY0sE7zZzsIKUaqm1H+zPZ4U8Zx5ERebj3hUANRLr7jJ7lV1e8jQAJLL6 KVJe6oJyaU8H6kEpfT6dkUY8QJ34kaMJlau+WF8oIUmxqApMenaj04rv8G0tUYy94cwV 3CeQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796452548; x=1797057348; 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=VU95cFkSAn69TuDw0TbCdkBN67NMzMRSRJdSDSIjX+Q=; b=wl9F/SEWWDrb/9YiZWqEKnqLdwoiOo2wTPsZdY5gjUksRkMFLD4qjJcUAZmLzMjOwd Koa5IqbkFwebZVGnKelCiLYYHlTz2lF1MNBkAk+yAvk6ySbvJse/LF+HrqmaWDNUKq2W bcPHOaXZDXPKLElhtZ4vDFceXbHytO2Pee/wjKU7OzgzFA1dPV5WxMMgJI82RBPfhzOv GcClbPzXdu9MbfhubNnBQFodz/P/ESlod+PBgTAuyjanTgjXdsG5Vt5sV4xd9M+hsRet RfsdfbMklOkCnq8yes+WNuT8RjgHER7D45hGR69bSZDCap9R/VeOpm6PMx66SaRshrHk NOeA== X-Forwarded-Encrypted: i=1; AL+hErFArT1s1egIPcpO930l7N8FOjSCaxgV0ntVssRQp9kJ7kSrD2GBPXV0ISc91fijnx/uchjVH14=@vger.kernel.org X-Gm-Message-State: AB4q+uEGAyJgKP4GPyZsfHmld3vYbDmkBl/NOYR7etV3wNZJZSy+SHhs O3tWfdiV8V0YJJ44nGT8F8SSZYMOP+aVM0cw79qk8He6kFElMYXZ6owE X-Gm-Gg: AZFdTZfltu6cNMUb1zg0eF4SG7c4AcyFQfqhdr2QIct7H8Lg0cXNG6ThunCkt4IfrgS LBh4i9KwCTSQQbO7IXNwYMrg8ChKZwbplJjysPaF99FXlZz0APNem/FO++wrZJ4836oHHbDbbJs 6R+jR8sI+Zi/UXLjm6etnCOqFa1yLYd/N9sNiYm9Jqrm/r+6UZwudHXeHrlFCrzR8Z5Fxp4dRLA X3ZJJqPmOm6A/2H3SZSgeEM8IRwe3l57+5/pb5N7Vb1NTXWo8+W5Wcm0Uvhp397UK2osPEJZzAW KS6KHYqs7HVYBQ4VFn8ypscX5yWUVQou3BP3k7gP8U1F8fyWNqvy75FOB1AezIkzWtcL2DqQkpr /uwjOmLiERPQrLbDlxkNhfT/JVaf2QhtaeJBewtLHrzY5Z5/3dEvTs9bDONK0j6heXt3iJ8hZ8v WTUrj/q7NIXEdcj903Ysgqa0Kdru240gmE0WbvkcC9FOQ2syoVU4LD1B2FtlBl2bOecq7OUUsDw nKYe4/2mgWsobwReWhDvP7fMhLHgh2yqwmF0aCvNT+s9+B5OG3+5pYTC7NMDGT5E7V5zwk+bC5E y6A+SS77+Zg6NVZ6prQ0lxmZsGqnTob0xPpP3XsQZNWtiXY4JHAtdEVStv+jHYbPqkY= X-Received: by 2002:a05:7301:5158:b0:386:f868:8caf with SMTP id 5a478bee46e88-3875216043dmr3461551eec.8.1796452547855; Fri, 04 Dec 2026 22:35:47 -0800 (PST) Received: from localhost.localdomain (wood.seclab.cs.ucsb.edu. [128.111.49.37]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-3875218c602sm20884183eec.7.2026.12.04.22.35.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Dec 2026 22:35:47 -0800 (PST) From: Praneeth Balasubramanian To: Greg Kroah-Hartman , Jiri Slaby Cc: Praneeth Balasubramanian , stable@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org Subject: [PATCH 1/4] tty: hvsi: fix stack overread in hvsi_version_respond() Date: Fri, 4 Dec 2026 22:35:33 -0800 Message-Id: <20261205063536.2519566-2-praneethb2002@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20261205063536.2519566-1-praneethb2002@gmail.com> References: <20261205063536.2519566-1-praneethb2002@gmail.com> X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit hvc_put_chars() always loads two unsigned long words from the buffer, 16 bytes in total, whatever count its caller passes. Its comment says the buffer must be at least 16 bytes. hvsi_version_respond() passes a struct hvsi_query_response, which is only 12 bytes. The load of the second word reads 4 bytes past the end of the stack object. This happens on every HVSI handshake, when the port answers the version query of the service processor. Copy the packet into a zeroed, aligned 16 byte buffer and pass that to hvc_put_chars(). The 4 bytes after the packet are then zero instead of stack contents. The count stays packet.hdr.len, so the service processor sees the same bytes as before. This was found by an LLM-based audit that checks code against the rules stated in kernel comments. Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Cc: stable@vger.kernel.org Signed-off-by: Praneeth Balasubramanian --- Notes: This was found by an LLM-based audit, part of research at UCSB SecLab. An LLM turned a kernel comment into a rule, and three LLM votes checked the code against it. The fix and changelog were drafted with GLM-5.3, then checked against the source and partly rewritten with Claude Opus 5.5. I reviewed the patch and take responsibility for it. Testing: builds without new warnings with W=1 (x86_64 allmodconfig; powerpc pseries_defconfig), clang 23. checkpatch.pl is clean. Not runtime-tested, and there is no reproducer. I do not have this hardware. drivers/tty/hvc/hvsi.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/tty/hvc/hvsi.c b/drivers/tty/hvc/hvsi.c index a94068bce76f..ec91ee42ad8c 100644 --- a/drivers/tty/hvc/hvsi.c +++ b/drivers/tty/hvc/hvsi.c @@ -279,7 +279,9 @@ static void hvsi_recv_response(struct hvsi_struct *hp, uint8_t *packet) /* respond to service processor's version query */ static int hvsi_version_respond(struct hvsi_struct *hp, uint16_t query_seqno) { - struct hvsi_query_response packet __ALIGNED__; + struct hvsi_query_response packet; + /* hvc_put_chars() reads 16 bytes even if count is smaller. */ + uint8_t buf[16] __ALIGNED__ = {}; int wrote; packet.hdr.type = VS_QUERY_RESPONSE_PACKET_HEADER; @@ -292,7 +294,8 @@ static int hvsi_version_respond(struct hvsi_struct *hp, uint16_t query_seqno) pr_debug("%s: sending %i bytes\n", __func__, packet.hdr.len); dbg_dump_hex((uint8_t*)&packet, packet.hdr.len); - wrote = hvc_put_chars(hp->vtermno, (char *)&packet, packet.hdr.len); + memcpy(buf, &packet, sizeof(packet)); + wrote = hvc_put_chars(hp->vtermno, buf, packet.hdr.len); if (wrote != packet.hdr.len) { printk(KERN_ERR "hvsi%i: couldn't send query response!\n", hp->index); -- 2.25.1