linux/drivers/tty/vt
Thomas Weißschuh 06740b433d vc_screen: don't clobber return value in vcs_read
commit ae3419fbac upstream.

Commit 226fae124b ("vc_screen: move load of struct vc_data pointer in
vcs_read() to avoid UAF") moved the call to vcs_vc() into the loop.

While doing this it also moved the unconditional assignment of

	ret = -ENXIO;

This unconditional assignment was valid outside the loop but within it
it clobbers the actual value of ret.

To avoid this only assign "ret = -ENXIO" when actually needed.

[ Also, the 'goto unlock_out" needs to be just a "break", so that it
  does the right thing when it exits on later iterations when partial
  success has happened - Linus ]

Reported-by: Storm Dragon <stormdragon2976@gmail.com>
Link: https://lore.kernel.org/lkml/Y%2FKS6vdql2pIsCiI@hotmail.com/
Fixes: 226fae124b ("vc_screen: move load of struct vc_data pointer in vcs_read() to avoid UAF")
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Link: https://lore.kernel.org/lkml/64981d94-d00c-4b31-9063-43ad0a384bde@t-8ch.de/
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2023-03-03 11:45:53 +01:00
..
.gitignore
conmakehash.c
consolemap.c
cp437.uni
defkeymap.c_shipped
defkeymap.map
keyboard.c tty: drivers/tty/, stop using tty_schedule_flip() 2022-07-29 17:25:31 +02:00
Makefile
selection.c
vc_screen.c vc_screen: don't clobber return value in vcs_read 2023-03-03 11:45:53 +01:00
vt_ioctl.c
vt.c vt: Clear selection before changing the font 2022-09-08 12:28:03 +02:00