speakup: fix a segfault caused by switching consoles
authorMushahid Hussain <mushi.shar@gmail.com>
Mon, 10 Oct 2022 16:57:20 +0000 (21:57 +0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 9 Nov 2022 14:21:55 +0000 (15:21 +0100)
commit0fc801f8018000c8e64a275a20cb1da7c54e46df
tree9caa2472134e41b96c76b2e5e8136744c8fd4f12
parent38e9f21f648ed3f9125fe09378da9b2eb08b12d9
speakup: fix a segfault caused by switching consoles

This patch fixes a segfault by adding a null check on synth in
speakup_con_update(). The segfault can be reproduced as follows:

- Login into a text console

- Load speakup and speakup_soft modules

- Remove speakup_soft

- Switch to a graphics console

This is caused by lack of a null check on `synth` in
speakup_con_update().

Here's the sequence that causes the segfault:

- When we remove the speakup_soft, synth_release() sets the synth
  to null.

- After that, when we change the virtual console to graphics
  console, vt_notifier_call() is fired, which then calls
  speakup_con_update().

- Inside speakup_con_update() there's no null check on synth,
  so it calls synth_printf().

- Inside synth_printf(), synth_buffer_add() and synth_start(),
  both access synth, when it is null and causing a segfault.

Therefore adding a null check on synth solves the issue.

Fixes: 2610df41489f ("staging: speakup: Add pause command used on switching to graphical mode")
Cc: stable <stable@kernel.org>
Signed-off-by: Mushahid Hussain <mushi.shar@gmail.com>
Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Link: https://lore.kernel.org/r/20221010165720.397042-1-mushi.shar@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/accessibility/speakup/main.c