Skip to contentSkip to conversation

Speakup: fix a segfault caused by switching consoles

PATCH In review Mushahid Hussain 3 participants 3 messages Oct 10, 2022 Speakup console speech driver

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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.

---
 drivers/accessibility/speakup/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/accessibility/speakup/main.c +1 -1
index f52265293482..73db0cb44fc7 100644
@@ -1778,7 +1778,7 @@ static void speakup_con_update(struct vc_data *vc)
 {
 	unsigned long flags;
 
-	if (!speakup_console[vc->vc_num] || spk_parked)
+	if (!speakup_console[vc->vc_num] || spk_parked || !synth)
 		return;
 	if (!spin_trylock_irqsave(&speakup_info.spinlock, flags))
 		/* Speakup output, discard */
Signature · 1 line
2.38.0
#1 lore raw
Quoted 29 lines · Mushahid Hussain

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.

Quoted 7 lines

Therefore adding a null check on synth solves the issue.

---
 drivers/accessibility/speakup/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

What commit id does this fix? Should it go to stable kernels?

thanks,

greg k-h

maintainer
#2 lore raw

Hello,

Greg KH, le lun. 10 oct. 2022 19:02:46 +0200, a ecrit:

Quoted 32 lines · Mushahid Hussain
Quoted 31 lines

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.

Quoted 7 lines
Quoted 5 lines
---
 drivers/accessibility/speakup/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

What commit id does this fix?

It is there since 2610df41489f548e235171b86895d4b49e6acb1f ("staging: speakup: Add pause command used on switching to graphical mode")

Quoted 1 line

Should it go to stable kernels?

Yes, please.

Mushahid, you can see in Documentation/process/submitting-patches.rst how to encode this in the patch submission.

Samuel