[PATCH 1/4] tty: hvsi: fix stack overread in hvsi_version_respond()

From: Praneeth Balasubramanian

Date: Sat Dec 05 2026 - 01:36:00 EST


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@xxxxxxxxxxxxxxx
Signed-off-by: Praneeth Balasubramanian <praneethb2002@xxxxxxxxx>
---

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