linux/drivers/tty/vt
Nicolas Pitre e9ad4d5ca3 vt: fix spurious modifier in CSI/cursor key sequences
csi_modifier_param() builds the xterm modifier parameter from
shift_state, counting KG_SHIFTL/KG_SHIFTR as Shift, KG_ALTGR as Alt
and KG_CTRLL/KG_CTRLR as Ctrl in addition to the canonical KG_SHIFT,
KG_ALT and KG_CTRL.

That is wrong when those weights are not plain modifiers. Keymaps
derived from XKB layouts (by kbd's xkbsupport, and by the
console-setup used in Debian, Ubuntu and others) encode the active
layout group using KG_SHIFTL/KG_SHIFTR:

	group 1: -
	group 2: shiftl
	group 3: shiftr
	group 4: shiftl | shiftr

So while a non-default layout group is selected, KG_SHIFTL and/or
KG_SHIFTR are set in shift_state with no Shift key held.
csi_modifier_param() then adds a spurious Shift to every cursor and
CSI key: pressing Up while group 2 is active emits ESC[1;2A (Shift+Up)
instead of ESC[A. KG_ALTGR has the same problem since it is the
standard third-level selector.

Normal keymaps bind the physical Shift/Ctrl/Alt keys to KG_SHIFT,
KG_CTRL and KG_ALT, leaving the left/right and AltGr weights free for
layout and level selection. Count only those canonical weights, so
genuine modifiers are still encoded while layout/level selectors are
not.

Fixes: 4af70f1516 ("vt: add modifier support to cursor keys")
Reported-by: Alexey Gladkov <legion@kernel.org>
Closes: https://lore.kernel.org/kbd/aj2gR0Y7sM6i9s2G@example.org/
Cc: stable <stable@kernel.org>
Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
Link: https://patch.msgid.link/20260626024833.3419086-1-nico@fluxnic.net
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2026-07-10 14:46:00 +02:00
..
.gitignore vt: create ucs_fallback_table.h_shipped with gen_ucs_fallback_table.py 2025-05-21 13:39:45 +02:00
conmakehash.c tty: vt: conmakehash: remove non-portable code printing comment header 2024-08-13 11:06:29 +02:00
consolemap.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
cp437.uni
defkeymap.c_shipped vt: defkeymap: Map keycodes above 127 to K_HOLE 2025-07-22 18:53:56 +02:00
defkeymap.map
gen_ucs_fallback_table.py vt: process the full-width ASCII fallback range programmatically 2025-05-21 13:39:45 +02:00
gen_ucs_recompose_table.py vt: move UCS tables to the "shipped" form 2025-04-26 11:22:04 +02:00
gen_ucs_width_table.py vt: merge ucs_is_zero_width()/ucs_is_double_width() into ucs_get_width() 2026-05-22 11:47:33 +02:00
keyboard.c vt: fix spurious modifier in CSI/cursor key sequences 2026-07-10 14:46:00 +02:00
Makefile vt: add ucs_get_fallback() 2025-05-21 13:39:45 +02:00
selection.c drivers/tty/vt: use umin() instead of min_t(u16, ...) for row/col limits 2025-11-21 18:16:11 +01:00
ucs_fallback_table.h_shipped vt: process the full-width ASCII fallback range programmatically 2025-05-21 13:39:45 +02:00
ucs_recompose_table.h_shipped vt: move UCS tables to the "shipped" form 2025-04-26 11:22:04 +02:00
ucs_width_table.h_shipped vt: merge ucs_is_zero_width()/ucs_is_double_width() into ucs_get_width() 2026-05-22 11:47:33 +02:00
ucs.c vt: merge ucs_is_zero_width()/ucs_is_double_width() into ucs_get_width() 2026-05-22 11:47:33 +02:00
vc_screen.c vc_screen: fix null-ptr-deref in vcs_notifier() during concurrent vcs_write 2026-06-12 11:55:37 +02:00
vt_ioctl.c tty/vt: Add missing return value for VT_RESIZE in vt_ioctl() 2025-09-06 15:49:55 +02:00
vt.c TTY / Serial driver update for 7.2-rc1 2026-06-22 11:51:49 -07:00