From: Greg Kroah-Hartman Date: Thu, 23 May 2024 12:40:54 +0000 (+0200) Subject: 5.4-stable patches X-Git-Tag: v4.19.315~8 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=0a68f6a7f6039b012530c1c740b4dfcd99207968;p=thirdparty%2Fkernel%2Fstable-queue.git 5.4-stable patches added patches: docs-kernel_include.py-cope-with-docutils-0.21.patch serial-kgdboc-fix-nmi-safety-problems-from-keyboard-reset-code.patch usb-typec-ucsi-displayport-fix-potential-deadlock.patch --- diff --git a/queue-5.4/docs-kernel_include.py-cope-with-docutils-0.21.patch b/queue-5.4/docs-kernel_include.py-cope-with-docutils-0.21.patch new file mode 100644 index 00000000000..1ffb97a855f --- /dev/null +++ b/queue-5.4/docs-kernel_include.py-cope-with-docutils-0.21.patch @@ -0,0 +1,66 @@ +From d43ddd5c91802a46354fa4c4381416ef760676e2 Mon Sep 17 00:00:00 2001 +From: Akira Yokosawa +Date: Wed, 1 May 2024 12:16:11 +0900 +Subject: docs: kernel_include.py: Cope with docutils 0.21 + +From: Akira Yokosawa + +commit d43ddd5c91802a46354fa4c4381416ef760676e2 upstream. + +Running "make htmldocs" on a newly installed Sphinx 7.3.7 ends up in +a build error: + + Sphinx parallel build error: + AttributeError: module 'docutils.nodes' has no attribute 'reprunicode' + +docutils 0.21 has removed nodes.reprunicode, quote from release note [1]: + + * Removed objects: + + docutils.nodes.reprunicode, docutils.nodes.ensure_str() + Python 2 compatibility hacks + +Sphinx 7.3.0 supports docutils 0.21 [2]: + +kernel_include.py, whose origin is misc.py of docutils, uses reprunicode. + +Upstream docutils removed the offending line from the corresponding file +(docutils/docutils/parsers/rst/directives/misc.py) in January 2022. +Quoting the changelog [3]: + + Deprecate `nodes.reprunicode` and `nodes.ensure_str()`. + + Drop uses of the deprecated constructs (not required with Python 3). + +Do the same for kernel_include.py. + +Tested against: + - Sphinx 2.4.5 (docutils 0.17.1) + - Sphinx 3.4.3 (docutils 0.17.1) + - Sphinx 5.3.0 (docutils 0.18.1) + - Sphinx 6.2.1 (docutils 0.19) + - Sphinx 7.2.6 (docutils 0.20.1) + - Sphinx 7.3.7 (docutils 0.21.2) + +Link: http://www.docutils.org/RELEASE-NOTES.html#release-0-21-2024-04-09 [1] +Link: https://www.sphinx-doc.org/en/master/changes.html#release-7-3-0-released-apr-16-2024 [2] +Link: https://github.com/docutils/docutils/commit/c8471ce47a24 [3] +Signed-off-by: Akira Yokosawa +Cc: stable@vger.kernel.org +Signed-off-by: Jonathan Corbet +Link: https://lore.kernel.org/r/faf5fa45-2a9d-4573-9d2e-3930bdc1ed65@gmail.com +Signed-off-by: Greg Kroah-Hartman +--- + Documentation/sphinx/kernel_include.py | 1 - + 1 file changed, 1 deletion(-) + +--- a/Documentation/sphinx/kernel_include.py ++++ b/Documentation/sphinx/kernel_include.py +@@ -94,7 +94,6 @@ class KernelInclude(Include): + # HINT: this is the only line I had to change / commented out: + #path = utils.relative_path(None, path) + +- path = nodes.reprunicode(path) + encoding = self.options.get( + 'encoding', self.state.document.settings.input_encoding) + e_handler=self.state.document.settings.input_encoding_error_handler diff --git a/queue-5.4/serial-kgdboc-fix-nmi-safety-problems-from-keyboard-reset-code.patch b/queue-5.4/serial-kgdboc-fix-nmi-safety-problems-from-keyboard-reset-code.patch new file mode 100644 index 00000000000..191acaef6c0 --- /dev/null +++ b/queue-5.4/serial-kgdboc-fix-nmi-safety-problems-from-keyboard-reset-code.patch @@ -0,0 +1,95 @@ +From b2aba15ad6f908d1a620fd97f6af5620c3639742 Mon Sep 17 00:00:00 2001 +From: Daniel Thompson +Date: Wed, 24 Apr 2024 15:21:41 +0100 +Subject: serial: kgdboc: Fix NMI-safety problems from keyboard reset code + +From: Daniel Thompson + +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 +Closes: https://lore.kernel.org/all/20240228025602.3087748-1-liu.yeC@h3c.com/ +Cc: stable@vger.kernel.org +Reviewed-by: Douglas Anderson +Acked-by: Greg Kroah-Hartman +Link: https://lore.kernel.org/r/20240424-kgdboc_fix_schedule_work-v2-1-50f5a490aec5@linaro.org +Signed-off-by: Daniel Thompson +Signed-off-by: Greg Kroah-Hartman +--- + drivers/tty/serial/kgdboc.c | 30 +++++++++++++++++++++++++++++- + 1 file changed, 29 insertions(+), 1 deletion(-) + +--- a/drivers/tty/serial/kgdboc.c ++++ b/drivers/tty/serial/kgdboc.c +@@ -19,6 +19,7 @@ + #include + #include + #include ++#include + #include + #include + +@@ -42,6 +43,25 @@ static int kgdb_tty_line; + + static struct platform_device *kgdboc_pdev; + ++/* ++ * When we leave the debug trap handler we need to reset the keyboard status ++ * (since the original keyboard state gets partially clobbered by kdb use of ++ * the keyboard). ++ * ++ * The path to deliver the reset is somewhat circuitous. ++ * ++ * To deliver the reset we register an input handler, reset the keyboard and ++ * then deregister the input handler. However, to get this done right, we do ++ * have to carefully manage the calling context because we can only register ++ * input handlers from task context. ++ * ++ * In particular we need to trigger the action from the debug trap handler with ++ * all its NMI and/or NMI-like oddities. To solve this the kgdboc trap exit code ++ * (the "post_exception" callback) uses irq_work_queue(), which is NMI-safe, to ++ * schedule a callback from a hardirq context. From there we have to defer the ++ * work again, this time using schedule_work(), to get a callback using the ++ * system workqueue, which runs in task context. ++ */ + #ifdef CONFIG_KDB_KEYBOARD + static int kgdboc_reset_connect(struct input_handler *handler, + struct input_dev *dev, +@@ -93,10 +113,17 @@ static void kgdboc_restore_input_helper( + + static DECLARE_WORK(kgdboc_restore_input_work, kgdboc_restore_input_helper); + ++static void kgdboc_queue_restore_input_helper(struct irq_work *unused) ++{ ++ schedule_work(&kgdboc_restore_input_work); ++} ++ ++static DEFINE_IRQ_WORK(kgdboc_restore_input_irq_work, kgdboc_queue_restore_input_helper); ++ + static void kgdboc_restore_input(void) + { + if (likely(system_state == SYSTEM_RUNNING)) +- schedule_work(&kgdboc_restore_input_work); ++ irq_work_queue(&kgdboc_restore_input_irq_work); + } + + static int kgdboc_register_kbd(char **cptr) +@@ -127,6 +154,7 @@ static void kgdboc_unregister_kbd(void) + i--; + } + } ++ irq_work_sync(&kgdboc_restore_input_irq_work); + flush_work(&kgdboc_restore_input_work); + } + #else /* ! CONFIG_KDB_KEYBOARD */ diff --git a/queue-5.4/series b/queue-5.4/series index 68b2148448b..1da1d3ee9cc 100644 --- a/queue-5.4/series +++ b/queue-5.4/series @@ -11,3 +11,6 @@ firmware-arm_scmi-harden-accesses-to-the-reset-domains.patch arm64-dts-qcom-fix-interrupt-map-parent-address-cells.patch btrfs-add-missing-mutex_unlock-in-btrfs_relocate_sys_chunks.patch drm-amdgpu-fix-possible-null-dereference-in-amdgpu_ras_query_error_status_helper.patch +usb-typec-ucsi-displayport-fix-potential-deadlock.patch +serial-kgdboc-fix-nmi-safety-problems-from-keyboard-reset-code.patch +docs-kernel_include.py-cope-with-docutils-0.21.patch diff --git a/queue-5.4/usb-typec-ucsi-displayport-fix-potential-deadlock.patch b/queue-5.4/usb-typec-ucsi-displayport-fix-potential-deadlock.patch new file mode 100644 index 00000000000..b4820772dcd --- /dev/null +++ b/queue-5.4/usb-typec-ucsi-displayport-fix-potential-deadlock.patch @@ -0,0 +1,51 @@ +From b791a67f68121d69108640d4a3e591d210ffe850 Mon Sep 17 00:00:00 2001 +From: Heikki Krogerus +Date: Tue, 7 May 2024 16:43:16 +0300 +Subject: usb: typec: ucsi: displayport: Fix potential deadlock + +From: Heikki Krogerus + +commit b791a67f68121d69108640d4a3e591d210ffe850 upstream. + +The function ucsi_displayport_work() does not access the +connector, so it also must not acquire the connector lock. + +This fixes a potential deadlock scenario: + +ucsi_displayport_work() -> lock(&con->lock) +typec_altmode_vdm() +dp_altmode_vdm() +dp_altmode_work() +typec_altmode_enter() +ucsi_displayport_enter() -> lock(&con->lock) + +Reported-by: Mathias Nyman +Fixes: af8622f6a585 ("usb: typec: ucsi: Support for DisplayPort alt mode") +Cc: stable@vger.kernel.org +Signed-off-by: Heikki Krogerus +Link: https://lore.kernel.org/r/20240507134316.161999-1-heikki.krogerus@linux.intel.com +Signed-off-by: Greg Kroah-Hartman +--- + drivers/usb/typec/ucsi/displayport.c | 4 ---- + 1 file changed, 4 deletions(-) + +--- a/drivers/usb/typec/ucsi/displayport.c ++++ b/drivers/usb/typec/ucsi/displayport.c +@@ -251,8 +251,6 @@ static void ucsi_displayport_work(struct + struct ucsi_dp *dp = container_of(work, struct ucsi_dp, work); + int ret; + +- mutex_lock(&dp->con->lock); +- + ret = typec_altmode_vdm(dp->alt, dp->header, + dp->vdo_data, dp->vdo_size); + if (ret) +@@ -261,8 +259,6 @@ static void ucsi_displayport_work(struct + dp->vdo_data = NULL; + dp->vdo_size = 0; + dp->header = 0; +- +- mutex_unlock(&dp->con->lock); + } + + void ucsi_displayport_remove_partner(struct typec_altmode *alt)