]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
serial: kgdboc: Fix NMI-safety problems from keyboard reset code
authorDaniel Thompson <daniel.thompson@linaro.org>
Wed, 24 Apr 2024 14:21:41 +0000 (15:21 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 25 May 2024 14:28:39 +0000 (16:28 +0200)
commita943edd3c6fce456a6607ca2bf89d229101a2dbe
treedc812e58bbfa14c4a3e71ff0ba70be58ba0b944d
parentdd35c3bb9c023aeb3c9910a6dae09ec358d4994c
serial: kgdboc: Fix NMI-safety problems from keyboard reset code

commit b2aba15ad6f908d1a620fd97f6af5620c3639742 upstream.

Currently, when kdb is compiled with keyboard support, then we will use
schedule_work() to provoke reset of the keyboard status.  Unfortunately
schedule_work() gets called from the kgdboc post-debug-exception
handler.  That risks deadlock since schedule_work() is not NMI-safe and,
even on platforms where the NMI is not directly used for debugging, the
debug trap can have NMI-like behaviour depending on where breakpoints
are placed.

Fix this by using the irq work system, which is NMI-safe, to defer the
call to schedule_work() to a point when it is safe to call.

Reported-by: Liuye <liu.yeC@h3c.com>
Closes: https://lore.kernel.org/all/20240228025602.3087748-1-liu.yeC@h3c.com/
Cc: stable@vger.kernel.org
Reviewed-by: Douglas Anderson <dianders@chromium.org>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Link: https://lore.kernel.org/r/20240424-kgdboc_fix_schedule_work-v2-1-50f5a490aec5@linaro.org
Signed-off-by: Daniel Thompson <daniel.thompson@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/tty/serial/kgdboc.c