The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: yuhaocheng035@gmail.com
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Jiri Slaby <jirislaby@kernel.org>
Cc: Nicolas Pitre <npitre@baylibre.com>,
	linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org,
	Calixte Pernot <calixte.pernot@grenoble-inp.org>
Subject: [PATCH] tty: vt: Fix slab-out-of-bounds write in do_con_write
Date: Sat, 21 Mar 2026 14:23:12 +0800	[thread overview]
Message-ID: <20260321062312.4290-1-yuhaocheng035@gmail.com> (raw)

From: Haocheng Yu <yuhaocheng035@gmail.com>

A KASAN: slab-out-of-bounds Write in do_con_write issue is reported by 
a modified Syzkaller-based kernel fuzzing tool that we developed. The 
report indicates the problem lies in vc_con_write_normal 
drivers/tty/vt/vt.c:3141(scr_writew(tc, (u16*)vc->vc_pos)), which writes 
2 bytes to the right of the allocated region at 2634 bytes.

Since it did not provide any repro program or enough information, 
the cause remains unclear. However, adding a validity check of vc->vc_pos 
before scr_writew should avoid this issue.

Signed-off-by: Haocheng Yu <yuhaocheng035@gmail.com>
---
 drivers/tty/vt/vt.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c
index 6e0089b85c27..95d860f09837 100644
--- a/drivers/tty/vt/vt.c
+++ b/drivers/tty/vt/vt.c
@@ -3138,6 +3138,13 @@ static int vc_con_write_normal(struct vc_data *vc, int tc, int c,
 			      (tc &  0xff);
 		tc |= (vc_attr << 8) & ~himask;
 
+		unsigned long end = vc->vc_origin + vc->vc_screenbuf_size;
+
+		if (WARN_ON_ONCE(vc->vc_screenbuf_size < 2 ||
+				 end < vc->vc_origin ||
+				 vc->vc_pos < vc->vc_origin ||
+				 vc->vc_pos > end - 2))
+			return -1;
+
 		scr_writew(tc, (u16 *)vc->vc_pos);
 
 		if (con_should_update(vc) && draw->x < 0) {

base-commit: 7d0a66e4bb9081d75c82ec4957c50034cb0ea449
-- 
2.51.0


             reply	other threads:[~2026-03-21  6:23 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-21  6:23 yuhaocheng035 [this message]
2026-03-21  6:32 ` [PATCH] tty: vt: Fix slab-out-of-bounds write in do_con_write Greg Kroah-Hartman
2026-03-21  6:37   ` Greg Kroah-Hartman
2026-03-22  7:32   ` Haocheng Yu

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=20260321062312.4290-1-yuhaocheng035@gmail.com \
    --to=yuhaocheng035@gmail.com \
    --cc=calixte.pernot@grenoble-inp.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=jirislaby@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=npitre@baylibre.com \
    /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