android_kernel_sony_sdm845/drivers/tty
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Jiri Slaby 04a6e5aa75 vt: keyboard, extend func_buf_lock to readers
commit 82e61c3909db51d91b9d3e2071557b6435018b80 upstream.

Both read-side users of func_table/func_buf need locking. Without that,
one can easily confuse the code by repeatedly setting altering strings
like:
while (1)
	for (a = 0; a < 2; a++) {
		struct kbsentry kbs = {};
		strcpy((char *)kbs.kb_string, a ? ".\n" : "88888\n");
		ioctl(fd, KDSKBSENT, &kbs);
	}

When that program runs, one can get unexpected output by holding F1
(note the unxpected period on the last line):
.
88888
.8888

So protect all accesses to 'func_table' (and func_buf) by preexisting
'func_buf_lock'.

It is easy in 'k_fn' handler as 'puts_queue' is expected not to sleep.
On the other hand, KDGKBSENT needs a local (atomic) copy of the string
because copy_to_user can sleep. Use already allocated, but unused
'kbs->kb_string' for that purpose.

Note that the program above needs at least CAP_SYS_TTY_CONFIG.

This depends on the previous patch and on the func_buf_lock lock added
in commit 46ca3f735f34 (tty/vt: fix write/write race in ioctl(KDSKBSENT)
handler) in 5.2.

Likely fixes CVE-2020-25656.

Cc: <stable@vger.kernel.org>
Reported-by: Minh Yuan <yuanmingbuaa@gmail.com>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Link: https://lore.kernel.org/r/20201019085517.10176-2-jslaby@suse.cz
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-11-10 10:23:58 +01:00
..
hvc tty: hvcs: Don't NULL tty->driver_data until hvcs_cleanup() 2020-10-29 09:05:35 +01:00
ipwireless tty: ipwireless: fix error handling 2020-10-29 09:05:45 +01:00
serial tty: serial: earlycon dependency 2020-10-29 09:05:35 +01:00
vt vt: keyboard, extend func_buf_lock to readers 2020-11-10 10:23:58 +01:00
amiserial.c
bfin_jtag_comm.c
cyclades.c
ehv_bytechan.c tty: evh_bytechan: Fix out of bounds accesses 2020-04-24 07:59:15 +02:00
goldfish.c
isicom.c
Kconfig tty: ldisc: add sysctl to prevent autoloading of ldiscs 2019-04-17 08:36:44 +02:00
Makefile
metag_da.c
mips_ejtag_fdc.c
moxa.c
moxa.h
mxser.c
mxser.h
n_gsm.c tty: n_gsm: Fix bogus i++ in gsm_data_kick 2020-06-30 15:38:26 -04:00
n_hdlc.c tty: Don't block on IO when ldisc change is pending 2019-12-21 10:41:25 +01:00
n_r3964.c tty: Don't block on IO when ldisc change is pending 2019-12-21 10:41:25 +01:00
n_tracerouter.c
n_tracesink.c
n_tracesink.h
n_tty.c tty: Don't block on IO when ldisc change is pending 2019-12-21 10:41:25 +01:00
nozomi.c
pty.c pty: do tty_flip_buffer_push without port->lock in pty_write 2020-10-29 09:05:35 +01:00
rocket.c tty: rocket, avoid OOB access 2020-05-02 17:23:12 +02:00
rocket.h
rocket_int.h
synclink.c
synclink_gt.c tty: synclink_gt: Adjust indentation in several functions 2020-02-28 15:42:32 +01:00
synclinkmp.c tty: synclinkmp: Adjust indentation in several functions 2020-02-28 15:42:32 +01:00
sysrq.c sysrq: Remove duplicated sysrq message 2020-03-11 07:53:04 +01:00
tty_audit.c
tty_buffer.c tty: increase the default flip buffer limit to 2*640K 2019-04-05 22:29:13 +02:00
tty_io.c tty: ldisc: add sysctl to prevent autoloading of ldiscs 2019-04-17 08:36:44 +02:00
tty_ioctl.c termios, tty/tty_baudrate.c: fix buffer overrun 2018-11-21 09:26:00 +01:00
tty_ldisc.c tty: Don't block on IO when ldisc change is pending 2019-12-21 10:41:25 +01:00
tty_ldsem.c tty/ldsem, locking/rwsem: Add missing ACQUIRE to read_failed sleep loop 2019-08-25 10:51:35 +02:00
tty_mutex.c
tty_port.c tty: always relink the port 2020-01-14 20:04:30 +01:00