* [PATCH 0/2] vt: Some small vt bugfixes found by code scans
@ 2026-07-31 7:56 Greg Kroah-Hartman
2026-07-31 7:56 ` [PATCH 1/2] vt: stabilize tty reference in kbd_keycode with tty_port_tty_get Greg Kroah-Hartman
2026-07-31 7:56 ` [PATCH 2/2] vt: add permission check for KDSKBMETA ioctl Greg Kroah-Hartman
0 siblings, 2 replies; 3+ messages in thread
From: Greg Kroah-Hartman @ 2026-07-31 7:56 UTC (permalink / raw)
To: Jiri Slaby
Cc: linux-kernel, linux-serial, Joshua Rogers, Greg Kroah-Hartman,
stable
Joshua at AISLE has been kind enough to run a bunch of scans on
the tty/serial code and here are two minor fixes for the vt code that
the tools found.
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
Joshua Rogers (2):
vt: stabilize tty reference in kbd_keycode with tty_port_tty_get
vt: add permission check for KDSKBMETA ioctl
drivers/tty/vt/keyboard.c | 5 ++++-
drivers/tty/vt/vt_ioctl.c | 2 ++
2 files changed, 6 insertions(+), 1 deletion(-)
---
base-commit: 8ba098e6b6ff0db8edf28528d1552be261af30d4
change-id: 20260731-tty-vt-stuff-eb7c6f3f7727
Best regards,
--
Greg Kroah-Hartman <gregkh@linuxfoundation.org>
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 1/2] vt: stabilize tty reference in kbd_keycode with tty_port_tty_get
2026-07-31 7:56 [PATCH 0/2] vt: Some small vt bugfixes found by code scans Greg Kroah-Hartman
@ 2026-07-31 7:56 ` Greg Kroah-Hartman
2026-07-31 7:56 ` [PATCH 2/2] vt: add permission check for KDSKBMETA ioctl Greg Kroah-Hartman
1 sibling, 0 replies; 3+ messages in thread
From: Greg Kroah-Hartman @ 2026-07-31 7:56 UTC (permalink / raw)
To: Jiri Slaby
Cc: linux-kernel, linux-serial, Joshua Rogers, Greg Kroah-Hartman,
stable
From: Joshua Rogers <linux@joshua.hu>
kbd_keycode() reads vc->port.tty without acquiring a tty reference,
racing against con_shutdown() which clears port.tty under a different
lock. Use tty_port_tty_get()/tty_kref_put() to hold a proper reference
for the duration the tty pointer is needed.
Assisted-by: AISLE:Snapshot
Signed-off-by: Joshua Rogers <linux@joshua.hu>
Cc: stable <stable@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/tty/vt/keyboard.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/tty/vt/keyboard.c b/drivers/tty/vt/keyboard.c
index 763a3f1b7be0..c41d850b29c6 100644
--- a/drivers/tty/vt/keyboard.c
+++ b/drivers/tty/vt/keyboard.c
@@ -1437,7 +1437,7 @@ static void kbd_keycode(unsigned int keycode, int down, bool hw_raw)
struct keyboard_notifier_param param = { .vc = vc, .value = keycode, .down = down };
int rc;
- tty = vc->port.tty;
+ tty = tty_port_tty_get(&vc->port);
if (tty && (!tty->driver_data)) {
/* No driver data? Strange. Okay we fix it then. */
@@ -1497,9 +1497,12 @@ static void kbd_keycode(unsigned int keycode, int down, bool hw_raw)
* characters get aren't echoed locally. This makes key repeat
* usable with slow applications and under heavy loads.
*/
+ tty_kref_put(tty);
return;
}
+ tty_kref_put(tty);
+
param.shift = shift_final = (shift_state | kbd->slockstate) ^ kbd->lockstate;
param.ledstate = kbd->ledflagstate;
key_map = key_maps[shift_final];
--
2.55.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 2/2] vt: add permission check for KDSKBMETA ioctl
2026-07-31 7:56 [PATCH 0/2] vt: Some small vt bugfixes found by code scans Greg Kroah-Hartman
2026-07-31 7:56 ` [PATCH 1/2] vt: stabilize tty reference in kbd_keycode with tty_port_tty_get Greg Kroah-Hartman
@ 2026-07-31 7:56 ` Greg Kroah-Hartman
1 sibling, 0 replies; 3+ messages in thread
From: Greg Kroah-Hartman @ 2026-07-31 7:56 UTC (permalink / raw)
To: Jiri Slaby
Cc: linux-kernel, linux-serial, Joshua Rogers, Greg Kroah-Hartman,
stable
From: Joshua Rogers <linux@joshua.hu>
KDSKBMETA modifies keyboard meta mode but lacks the !perm check that all
other keyboard setter ioctls in vt_k_ioctl() enforce, allowing a process
to change meta mode on a non-controlling console without authorization.
Assisted-by: AISLE:Snapshot
Cc: stable <stable@kernel.org>
Signed-off-by: Joshua Rogers <linux@joshua.hu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/tty/vt/vt_ioctl.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/tty/vt/vt_ioctl.c b/drivers/tty/vt/vt_ioctl.c
index 28993a3d0acb..deb3b3f93461 100644
--- a/drivers/tty/vt/vt_ioctl.c
+++ b/drivers/tty/vt/vt_ioctl.c
@@ -406,6 +406,8 @@ static int vt_k_ioctl(struct tty_struct *tty, unsigned int cmd,
/* this could be folded into KDSKBMODE, but for compatibility
reasons it is not so easy to fold KDGKBMETA into KDGKBMODE */
case KDSKBMETA:
+ if (!perm)
+ return -EPERM;
return vt_do_kdskbmeta(console, arg);
case KDGKBMETA:
--
2.55.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-07-31 7:56 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-31 7:56 [PATCH 0/2] vt: Some small vt bugfixes found by code scans Greg Kroah-Hartman
2026-07-31 7:56 ` [PATCH 1/2] vt: stabilize tty reference in kbd_keycode with tty_port_tty_get Greg Kroah-Hartman
2026-07-31 7:56 ` [PATCH 2/2] vt: add permission check for KDSKBMETA ioctl Greg Kroah-Hartman
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.