mirror-linux/drivers/tty/hvc
Roger Pau Monne 7bed0d49ca hvc/xen: lock console list traversal
[ Upstream commit c0dccad87c ]

The currently lockless access to the xen console list in
vtermno_to_xencons() is incorrect, as additions and removals from the
list can happen anytime, and as such the traversal of the list to get
the private console data for a given termno needs to happen with the
lock held.  Note users that modify the list already do so with the
lock taken.

Adjust current lock takers to use the _irq{save,restore} helpers,
since the context in which vtermno_to_xencons() is called can have
interrupts disabled.  Use the _irq{save,restore} set of helpers to
switch the current callers to disable interrupts in the locked region.
I haven't checked if existing users could instead use the _irq
variant, as I think it's safer to use _irq{save,restore} upfront.

While there switch from using list_for_each_entry_safe to
list_for_each_entry: the current entry cursor won't be removed as
part of the code in the loop body, so using the _safe variant is
pointless.

Fixes: 02e19f9c7c ('hvc_xen: implement multiconsole support')
Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
Link: https://lore.kernel.org/r/20221130163611.14686-1-roger.pau@citrix.com
Signed-off-by: Juergen Gross <jgross@suse.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-01-18 11:58:26 +01:00
..
Kconfig tty: hvc: dcc: Bind driver to CPU core0 for reads and writes 2022-05-05 22:45:57 +02:00
Makefile
hvc_console.c Revert "tty: hvc: pass DMA capable memory to put_chars()" 2021-10-26 08:48:09 +02:00
hvc_console.h Revert "tty: hvc: pass DMA capable memory to put_chars()" 2021-10-26 08:48:09 +02:00
hvc_dcc.c tty: hvc: dcc: Bind driver to CPU core0 for reads and writes 2022-05-05 22:45:57 +02:00
hvc_irq.c
hvc_iucv.c tty: hvc: remove HVC_IUCV_MAGIC 2022-09-22 16:12:34 +02:00
hvc_opal.c tty/hvc_opal: simplify if-if to if-else 2022-04-26 13:24:17 +02:00
hvc_riscv_sbi.c
hvc_rtas.c
hvc_udbg.c tty: hvc: make symbol 'hvc_udbg_dev' static 2021-04-10 10:41:40 +02:00
hvc_vio.c tty: hvc: Prepare cleanup of powerpc's asm/prom.h 2022-04-15 08:42:26 +02:00
hvc_xen.c hvc/xen: lock console list traversal 2023-01-18 11:58:26 +01:00
hvcs.c termios: start unifying non-UAPI parts of asm/termios.h 2022-09-09 10:44:34 +02:00
hvsi.c tty: hvc: Prepare cleanup of powerpc's asm/prom.h 2022-04-15 08:42:26 +02:00
hvsi_lib.c