From: Greg Kroah-Hartman Date: Mon, 29 Jul 2024 12:17:05 +0000 (+0200) Subject: 5.4-stable patches X-Git-Tag: v6.1.103~61 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=3dd9efba234b841dcf48895df2864a18b3258d5e;p=thirdparty%2Fkernel%2Fstable-queue.git 5.4-stable patches added patches: binder-fix-hang-of-unregistered-readers.patch hwrng-amd-convert-pcibios_-return-codes-to-errnos.patch pci-hv-return-zero-not-garbage-when-reading-pci_interrupt_pin.patch tools-memory-model-fix-bug-in-lock.cat.patch --- diff --git a/queue-5.4/binder-fix-hang-of-unregistered-readers.patch b/queue-5.4/binder-fix-hang-of-unregistered-readers.patch new file mode 100644 index 00000000000..d668656ee2d --- /dev/null +++ b/queue-5.4/binder-fix-hang-of-unregistered-readers.patch @@ -0,0 +1,51 @@ +From 31643d84b8c3d9c846aa0e20bc033e46c68c7e7d Mon Sep 17 00:00:00 2001 +From: Carlos Llamas +Date: Thu, 11 Jul 2024 20:14:51 +0000 +Subject: binder: fix hang of unregistered readers +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +From: Carlos Llamas + +commit 31643d84b8c3d9c846aa0e20bc033e46c68c7e7d upstream. + +With the introduction of binder_available_for_proc_work_ilocked() in +commit 1b77e9dcc3da ("ANDROID: binder: remove proc waitqueue") a binder +thread can only "wait_for_proc_work" after its thread->looper has been +marked as BINDER_LOOPER_STATE_{ENTERED|REGISTERED}. + +This means an unregistered reader risks waiting indefinitely for work +since it never gets added to the proc->waiting_threads. If there are no +further references to its waitqueue either the task will hang. The same +applies to readers using the (e)poll interface. + +I couldn't find the rationale behind this restriction. So this patch +restores the previous behavior of allowing unregistered threads to +"wait_for_proc_work". Note that an error message for this scenario, +which had previously become unreachable, is now re-enabled. + +Fixes: 1b77e9dcc3da ("ANDROID: binder: remove proc waitqueue") +Cc: stable@vger.kernel.org +Cc: Martijn Coenen +Cc: Arve Hjønnevåg +Signed-off-by: Carlos Llamas +Link: https://lore.kernel.org/r/20240711201452.2017543-1-cmllamas@google.com +Signed-off-by: Greg Kroah-Hartman +--- + drivers/android/binder.c | 4 +--- + 1 file changed, 1 insertion(+), 3 deletions(-) + +--- a/drivers/android/binder.c ++++ b/drivers/android/binder.c +@@ -932,9 +932,7 @@ static bool binder_has_work(struct binde + static bool binder_available_for_proc_work_ilocked(struct binder_thread *thread) + { + return !thread->transaction_stack && +- binder_worklist_empty_ilocked(&thread->todo) && +- (thread->looper & (BINDER_LOOPER_STATE_ENTERED | +- BINDER_LOOPER_STATE_REGISTERED)); ++ binder_worklist_empty_ilocked(&thread->todo); + } + + static void binder_wakeup_poll_threads_ilocked(struct binder_proc *proc, diff --git a/queue-5.4/hwrng-amd-convert-pcibios_-return-codes-to-errnos.patch b/queue-5.4/hwrng-amd-convert-pcibios_-return-codes-to-errnos.patch new file mode 100644 index 00000000000..f478940e5b3 --- /dev/null +++ b/queue-5.4/hwrng-amd-convert-pcibios_-return-codes-to-errnos.patch @@ -0,0 +1,42 @@ +From 14cba6ace79627a57fb9058582b03f0ed3832390 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= +Date: Mon, 27 May 2024 16:26:15 +0300 +Subject: hwrng: amd - Convert PCIBIOS_* return codes to errnos +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +From: Ilpo Järvinen + +commit 14cba6ace79627a57fb9058582b03f0ed3832390 upstream. + +amd_rng_mod_init() uses pci_read_config_dword() that returns PCIBIOS_* +codes. The return code is then returned as is but amd_rng_mod_init() is +a module_init() function that should return normal errnos. + +Convert PCIBIOS_* returns code using pcibios_err_to_errno() into normal +errno before returning it. + +Fixes: 96d63c0297cc ("[PATCH] Add AMD HW RNG driver") +Cc: stable@vger.kernel.org +Signed-off-by: Ilpo Järvinen +Signed-off-by: Herbert Xu +Signed-off-by: Greg Kroah-Hartman +--- + drivers/char/hw_random/amd-rng.c | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +--- a/drivers/char/hw_random/amd-rng.c ++++ b/drivers/char/hw_random/amd-rng.c +@@ -142,8 +142,10 @@ static int __init mod_init(void) + + found: + err = pci_read_config_dword(pdev, 0x58, &pmbase); +- if (err) ++ if (err) { ++ err = pcibios_err_to_errno(err); + goto put_dev; ++ } + + pmbase &= 0x0000FF00; + if (pmbase == 0) { diff --git a/queue-5.4/pci-hv-return-zero-not-garbage-when-reading-pci_interrupt_pin.patch b/queue-5.4/pci-hv-return-zero-not-garbage-when-reading-pci_interrupt_pin.patch new file mode 100644 index 00000000000..9a1f1b27e64 --- /dev/null +++ b/queue-5.4/pci-hv-return-zero-not-garbage-when-reading-pci_interrupt_pin.patch @@ -0,0 +1,48 @@ +From fea93a3e5d5e6a09eb153866d2ce60ea3287a70d Mon Sep 17 00:00:00 2001 +From: Wei Liu +Date: Mon, 1 Jul 2024 20:26:05 +0000 +Subject: PCI: hv: Return zero, not garbage, when reading PCI_INTERRUPT_PIN +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +From: Wei Liu + +commit fea93a3e5d5e6a09eb153866d2ce60ea3287a70d upstream. + +The intent of the code snippet is to always return 0 for both +PCI_INTERRUPT_LINE and PCI_INTERRUPT_PIN. + +The check misses PCI_INTERRUPT_PIN. This patch fixes that. + +This is discovered by this call in VFIO: + + pci_read_config_byte(vdev->pdev, PCI_INTERRUPT_PIN, &pin); + +The old code does not set *val to 0 because it misses the check for +PCI_INTERRUPT_PIN. Garbage is returned in that case. + +Fixes: 4daace0d8ce8 ("PCI: hv: Add paravirtual PCI front-end for Microsoft Hyper-V VMs") +Link: https://lore.kernel.org/linux-pci/20240701202606.129606-1-wei.liu@kernel.org +Signed-off-by: Wei Liu +Signed-off-by: Krzysztof Wilczyński +Reviewed-by: Michael Kelley +Cc: stable@kernel.org +Signed-off-by: Greg Kroah-Hartman +--- + drivers/pci/controller/pci-hyperv.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +--- a/drivers/pci/controller/pci-hyperv.c ++++ b/drivers/pci/controller/pci-hyperv.c +@@ -682,8 +682,8 @@ static void _hv_pcifront_read_config(str + PCI_CAPABILITY_LIST) { + /* ROM BARs are unimplemented */ + *val = 0; +- } else if (where >= PCI_INTERRUPT_LINE && where + size <= +- PCI_INTERRUPT_PIN) { ++ } else if ((where >= PCI_INTERRUPT_LINE && where + size <= PCI_INTERRUPT_PIN) || ++ (where >= PCI_INTERRUPT_PIN && where + size <= PCI_MIN_GNT)) { + /* + * Interrupt Line and Interrupt PIN are hard-wired to zero + * because this front-end only supports message-signaled diff --git a/queue-5.4/series b/queue-5.4/series index 3ca99c7d3cd..dfac779cbf6 100644 --- a/queue-5.4/series +++ b/queue-5.4/series @@ -103,3 +103,7 @@ ext4-check-dot-and-dotdot-of-dx_root-before-making-dir-indexed.patch ext4-make-sure-the-first-directory-block-is-not-a-hole.patch wifi-mwifiex-fix-interface-type-change.patch leds-ss4200-convert-pcibios_-return-codes-to-errnos.patch +tools-memory-model-fix-bug-in-lock.cat.patch +hwrng-amd-convert-pcibios_-return-codes-to-errnos.patch +pci-hv-return-zero-not-garbage-when-reading-pci_interrupt_pin.patch +binder-fix-hang-of-unregistered-readers.patch diff --git a/queue-5.4/tools-memory-model-fix-bug-in-lock.cat.patch b/queue-5.4/tools-memory-model-fix-bug-in-lock.cat.patch new file mode 100644 index 00000000000..e66fde3ce8d --- /dev/null +++ b/queue-5.4/tools-memory-model-fix-bug-in-lock.cat.patch @@ -0,0 +1,98 @@ +From 4c830eef806679dc243e191f962c488dd9d00708 Mon Sep 17 00:00:00 2001 +From: Alan Stern +Date: Thu, 6 Jun 2024 09:57:55 -0400 +Subject: tools/memory-model: Fix bug in lock.cat + +From: Alan Stern + +commit 4c830eef806679dc243e191f962c488dd9d00708 upstream. + +Andrea reported that the following innocuous litmus test: + +C T + +{} + +P0(spinlock_t *x) +{ + int r0; + + spin_lock(x); + spin_unlock(x); + r0 = spin_is_locked(x); +} + +gives rise to a nonsensical empty result with no executions: + +$ herd7 -conf linux-kernel.cfg T.litmus +Test T Required +States 0 +Ok +Witnesses +Positive: 0 Negative: 0 +Condition forall (true) +Observation T Never 0 0 +Time T 0.00 +Hash=6fa204e139ddddf2cb6fa963bad117c0 + +The problem is caused by a bug in the lock.cat part of the LKMM. Its +computation of the rf relation for RU (read-unlocked) events is +faulty; it implicitly assumes that every RU event must read from +either a UL (unlock) event in another thread or from the lock's +initial state. Neither is true in the litmus test above, so the +computation yields no possible executions. + +The lock.cat code tries to make up for this deficiency by allowing RU +events outside of critical sections to read from the last po-previous +UL event. But it does this incorrectly, trying to keep these rfi links +separate from the rfe links that might also be needed, and passing only +the latter to herd7's cross() macro. + +The problem is fixed by merging the two sets of possible rf links for +RU events and using them all in the call to cross(). + +Signed-off-by: Alan Stern +Reported-by: Andrea Parri +Closes: https://lore.kernel.org/linux-arch/ZlC0IkzpQdeGj+a3@andrea/ +Tested-by: Andrea Parri +Acked-by: Andrea Parri +Fixes: 15553dcbca06 ("tools/memory-model: Add model support for spin_is_locked()") +CC: +Signed-off-by: Paul E. McKenney +Signed-off-by: Greg Kroah-Hartman +--- + tools/memory-model/lock.cat | 20 ++++++++++---------- + 1 file changed, 10 insertions(+), 10 deletions(-) + +--- a/tools/memory-model/lock.cat ++++ b/tools/memory-model/lock.cat +@@ -102,19 +102,19 @@ let rf-lf = rfe-lf | rfi-lf + * within one of the lock's critical sections returns False. + *) + +-(* rfi for RU events: an RU may read from the last po-previous UL *) +-let rfi-ru = ([UL] ; po-loc ; [RU]) \ ([UL] ; po-loc ; [LKW] ; po-loc) +- +-(* rfe for RU events: an RU may read from an external UL or the initial write *) +-let all-possible-rfe-ru = +- let possible-rfe-ru r = ++(* ++ * rf for RU events: an RU may read from an external UL or the initial write, ++ * or from the last po-previous UL ++ *) ++let all-possible-rf-ru = ++ let possible-rf-ru r = + let pair-to-relation p = p ++ 0 +- in map pair-to-relation (((UL | IW) * {r}) & loc & ext) +- in map possible-rfe-ru RU ++ in map pair-to-relation ((((UL | IW) * {r}) & loc & ext) | ++ (((UL * {r}) & po-loc) \ ([UL] ; po-loc ; [LKW] ; po-loc))) ++ in map possible-rf-ru RU + + (* Generate all rf relations for RU events *) +-with rfe-ru from cross(all-possible-rfe-ru) +-let rf-ru = rfe-ru | rfi-ru ++with rf-ru from cross(all-possible-rf-ru) + + (* Final rf relation *) + let rf = rf | rf-lf | rf-ru