提交 8cfd9168 编写于 作者: M Mushahid Hussain 提交者: openeuler-sync-bot

speakup: fix a segfault caused by switching consoles

stable inclusion
from stable-v5.10.156
commit eb3af3ea5bcabee193ce31e08fedf55cc3d20b9f
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I7MCG1

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=eb3af3ea5bcabee193ce31e08fedf55cc3d20b9f

--------------------------------

commit 0fc801f8 upstream.

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: 2610df41 ("staging: speakup: Add pause command used on switching to graphical mode")
Cc: stable <stable@kernel.org>
Signed-off-by: NMushahid Hussain <mushi.shar@gmail.com>
Signed-off-by: NSamuel Thibault <samuel.thibault@ens-lyon.org>
Link: https://lore.kernel.org/r/20221010165720.397042-1-mushi.shar@gmail.comSigned-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Nsanglipeng <sanglipeng1@jd.com>
(cherry picked from commit 9c4777d6)
上级 c3d08687
...@@ -1780,7 +1780,7 @@ static void speakup_con_update(struct vc_data *vc) ...@@ -1780,7 +1780,7 @@ static void speakup_con_update(struct vc_data *vc)
{ {
unsigned long flags; unsigned long flags;
if (!speakup_console[vc->vc_num] || spk_parked) if (!speakup_console[vc->vc_num] || spk_parked || !synth)
return; return;
if (!spin_trylock_irqsave(&speakup_info.spinlock, flags)) if (!spin_trylock_irqsave(&speakup_info.spinlock, flags))
/* Speakup output, discard */ /* Speakup output, discard */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册