From: sashiko-bot@kernel.org
To: "Praneeth Balasubramanian" <praneethb2002@gmail.com>
Cc: linux-serial@vger.kernel.org
Subject: Re: [PATCH 1/4] tty: hvsi: fix stack overread in hvsi_version_respond()
Date: Sat, 05 Dec 2026 06:53:13 +0000 [thread overview]
Message-ID: <sashiko-outbox-251156@kernel.org> (raw)
In-Reply-To: <20261205063536.2519566-2-praneethb2002@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] tty: hvsi: incomplete fix leaves stack overreads in
hvc_put_chars() callers
--
commit b74704ec7a06e3ab6946c94e8953559355686fee
Author: Praneeth Balasubramanian <praneethb2002@gmail.com>
tty: hvsi: fix stack overread in hvsi_version_respond()
This commit copies the 12-byte struct hvsi_query_response packet in
hvsi_version_respond() into a zeroed, aligned 16-byte stack buffer before
passing it to hvc_put_chars().
> diff --git a/drivers/tty/hvc/hvsi.c b/drivers/tty/hvc/hvsi.c
> index a94068bce76f3..ec91ee42ad8c0 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, uint8_t *packet)
> 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);
[Severity: Medium]
Should this be fixed in hvc_put_chars() instead of working around it in
hvsi_version_respond() alone?
Patching only this call site leaves the same stack out-of-bounds read in
other callers of hvc_put_chars(): hvsi_query() (6 bytes), hvsi_set_mctrl()
and hvsi_close_protocol() (14 bytes) in this file, hvsi_send_packet() in
drivers/tty/hvc/hvsi_lib.c, and hvc_poll_put_char() (1 byte).
On every HVSI handshake, hvsi_query() still triggers a 10-byte stack
overread, causing KASAN stack-out-of-bounds reports and loading adjacent
stack bytes into H_PUT_TERM_CHAR hypercall registers.
Copying count bytes (clamped to MAX_VIO_PUT_CHARS) into a zeroed, aligned
16-byte local buffer in hvc_put_chars() in
arch/powerpc/platforms/pseries/hvconsole.c would fix all callers at once.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261205063536.2519566-1-praneethb2002@gmail.com?part=1
next prev parent reply other threads:[~2026-12-05 6:53 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-05 6:35 [PATCH 0/4] tty: fix a stack overread and missing locking in serial drivers Praneeth Balasubramanian
2026-12-05 6:35 ` [PATCH 1/4] tty: hvsi: fix stack overread in hvsi_version_respond() Praneeth Balasubramanian
2026-12-05 6:53 ` sashiko-bot [this message]
2026-12-05 6:35 ` [PATCH 2/4] serial: men_z135_uart: do not release an unrequested memory region Praneeth Balasubramanian
2026-12-05 6:35 ` [PATCH 3/4] tty: atmel_serial: take the port lock in console write Praneeth Balasubramanian
2026-12-05 6:59 ` sashiko-bot
2026-12-05 6:35 ` [PATCH 4/4] mxser: take termios_rwsem in mxser_set_serial_info() Praneeth Balasubramanian
2026-12-05 6:56 ` sashiko-bot
2026-12-05 6:59 ` [PATCH 0/4] tty: fix a stack overread and missing locking in serial drivers sashiko-bot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=sashiko-outbox-251156@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-serial@vger.kernel.org \
--cc=praneethb2002@gmail.com \
--cc=sashiko-reviews@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox