An error occurred while fetching folder content.
tty/vt/keyboard: fix OOB access in do_compute_shiftstate()
Dmitry Torokhov authored
commit 510cccb5

 upstream.

The size of individual keymap in drivers/tty/vt/keyboard.c is NR_KEYS,
which is currently 256, whereas number of keys/buttons in input device (and
therefor in key_down) is much larger - KEY_CNT - 768, and that can cause
out-of-bound access when we do

	sym = U(key_maps[0][k]);

with large 'k'.

To fix it we should not attempt iterating beyond smaller of NR_KEYS and
KEY_CNT.

Also while at it let's switch to for_each_set_bit() instead of open-coding
it.
Reported-by: default avatarSasha Levin <sasha.levin@oracle.com>
Reviewed-by: default avatarGuenter Roeck <linux@roeck-us.net>
Cc: stable@vger.kernel.org
Signed-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: default avatarWilly Tarreau <w@1wt.eu>
074ed3fd
Name Last commit Last update
..
accessibility vt:tackle kbd_table
acpi PCI/ACPI: Fix _OSC ordering to allow PCIe hotplug use when available
amba ARM: 7675/1: amba: tegra-ahb: Fix build error w/ PM_SLEEP w/o PM_RUNTIME
ata libata: fix HDIO_GET_32BIT ioctl
atm atm: idt77252: fix dev refcnt leak
auxdisplay auxdisplay: ks0108: fix refcount
base base: make module_create_drivers_dir race-free
bcma bcma: add more core IDs
block nbd: ratelimit error msgs after socket close
bluetooth Bluetooth: vhci: purge unhandled skbs
bus bus: mvebu: pass the coherency availability information at init time
cdrom drivers/cdrom/cdrom.c: use kzalloc() for failing hardware
char vTPM: fix memory allocation flag for rtce buffer at kernel boot
clk clk: versatile: sp810: support reentrance
clocksource clocksource/drivers/vt8500: Increase the minimum delta
connector connector: bump skb->users before callback invocation
cpufreq cpufreq: speedstep-smi: enable interrupts when waiting
cpuidle cpuidle / menu: Return (-1) if there are no suitable states
crypto crypto: ux500 - memmove the right size
dca dca: convert to idr_alloc()
devfreq Merge branch 'master' into for-next
dio m68k: don't export static inline functions
dma dmaengine: mv_xor: bug fix for racing condition in descriptors cleanup
edac EDAC: i7core, sb_edac: Don't return NOTIFY_BAD from mce_decoder callback
eisa Revert "EISA: Initialize device before its resources"
extcon
firewire
firmware
gpio
gpu
hid
hsi
hv
hwmon
hwspinlock
i2c
ide
idle
iio
infiniband
input
iommu
ipack
irqchip
isdn
leds
lguest
macintosh
mailbox
md
media
memory
memstick
message
mfd
misc
mmc
mtd
net
nfc
ntb
nubus
of
oprofile
parisc
parport
pci
pcmcia
pinctrl
platform
pnp
power
pps
ps3
ptp
pwm
rapidio
regulator
remoteproc
reset
rpmsg
rtc
s390
sbus
scsi
sfi
sh
sn
spi
ssb
ssbi
staging
target
tc
thermal
tty
uio
usb
uwb
vfio