From 0a4807ccb4ed2995dcfab7745ede264f413fb4e5 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Tue, 30 Jul 2024 12:39:08 +0200 Subject: [PATCH] 5.4-stable patches added patches: drm-panfrost-mark-simple_ondemand-governor-as-softdep.patch platform-mips-cpu_hwmon-disable-driver-on-unsupported-hardware.patch rbd-don-t-assume-rbd_is_lock_owner-for-exclusive-mappings.patch rdma-iwcm-fix-a-use-after-free-related-to-destroying-cm-ids.patch selftests-sigaltstack-fix-ppc64-gcc-build.patch --- ...-simple_ondemand-governor-as-softdep.patch | 64 ++++++++++++++++ ...sable-driver-on-unsupported-hardware.patch | 32 ++++++++ ...is_lock_owner-for-exclusive-mappings.patch | 43 +++++++++++ ...er-free-related-to-destroying-cm-ids.patch | 74 +++++++++++++++++++ ...ests-sigaltstack-fix-ppc64-gcc-build.patch | 48 ++++++++++++ queue-5.4/series | 5 ++ 6 files changed, 266 insertions(+) create mode 100644 queue-5.4/drm-panfrost-mark-simple_ondemand-governor-as-softdep.patch create mode 100644 queue-5.4/platform-mips-cpu_hwmon-disable-driver-on-unsupported-hardware.patch create mode 100644 queue-5.4/rbd-don-t-assume-rbd_is_lock_owner-for-exclusive-mappings.patch create mode 100644 queue-5.4/rdma-iwcm-fix-a-use-after-free-related-to-destroying-cm-ids.patch create mode 100644 queue-5.4/selftests-sigaltstack-fix-ppc64-gcc-build.patch diff --git a/queue-5.4/drm-panfrost-mark-simple_ondemand-governor-as-softdep.patch b/queue-5.4/drm-panfrost-mark-simple_ondemand-governor-as-softdep.patch new file mode 100644 index 00000000000..6086c7ebca3 --- /dev/null +++ b/queue-5.4/drm-panfrost-mark-simple_ondemand-governor-as-softdep.patch @@ -0,0 +1,64 @@ +From 80f4e62730a91572b7fdc657f7bb747e107ae308 Mon Sep 17 00:00:00 2001 +From: Dragan Simic +Date: Mon, 17 Jun 2024 22:17:48 +0200 +Subject: drm/panfrost: Mark simple_ondemand governor as softdep + +From: Dragan Simic + +commit 80f4e62730a91572b7fdc657f7bb747e107ae308 upstream. + +Panfrost DRM driver uses devfreq to perform DVFS, while using simple_ondemand +devfreq governor by default. This causes driver initialization to fail on +boot when simple_ondemand governor isn't built into the kernel statically, +as a result of the missing module dependency and, consequently, the required +governor module not being included in the initial ramdisk. Thus, let's mark +simple_ondemand governor as a softdep for Panfrost, to have its kernel module +included in the initial ramdisk. + +This is a rather longstanding issue that has forced distributions to build +devfreq governors statically into their kernels, [1][2] or has forced users +to introduce some unnecessary workarounds. [3] + +For future reference, not having support for the simple_ondemand governor in +the initial ramdisk produces errors in the kernel log similar to these below, +which were taken from a Pine64 RockPro64: + + panfrost ff9a0000.gpu: [drm:panfrost_devfreq_init [panfrost]] *ERROR* Couldn't initialize GPU devfreq + panfrost ff9a0000.gpu: Fatal error during GPU init + panfrost: probe of ff9a0000.gpu failed with error -22 + +Having simple_ondemand marked as a softdep for Panfrost may not resolve this +issue for all Linux distributions. In particular, it will remain unresolved +for the distributions whose utilities for the initial ramdisk generation do +not handle the available softdep information [4] properly yet. However, some +Linux distributions already handle softdeps properly while generating their +initial ramdisks, [5] and this is a prerequisite step in the right direction +for the distributions that don't handle them properly yet. + +[1] https://gitlab.manjaro.org/manjaro-arm/packages/core/linux/-/blob/linux61/config?ref_type=heads#L8180 +[2] https://salsa.debian.org/kernel-team/linux/-/merge_requests/1066 +[3] https://forum.pine64.org/showthread.php?tid=15458 +[4] https://git.kernel.org/pub/scm/utils/kernel/kmod/kmod.git/commit/?id=49d8e0b59052999de577ab732b719cfbeb89504d +[5] https://github.com/archlinux/mkinitcpio/commit/97ac4d37aae084a050be512f6d8f4489054668ad + +Cc: Diederik de Haas +Cc: Furkan Kardame +Cc: stable@vger.kernel.org +Fixes: f3ba91228e8e ("drm/panfrost: Add initial panfrost driver") +Signed-off-by: Dragan Simic +Reviewed-by: Steven Price +Reviewed-by: Boris Brezillon +Signed-off-by: Steven Price +Link: https://patchwork.freedesktop.org/patch/msgid/4e1e00422a14db4e2a80870afb704405da16fd1b.1718655077.git.dsimic@manjaro.org +Signed-off-by: Greg Kroah-Hartman +--- + drivers/gpu/drm/panfrost/panfrost_drv.c | 1 + + 1 file changed, 1 insertion(+) + +--- a/drivers/gpu/drm/panfrost/panfrost_drv.c ++++ b/drivers/gpu/drm/panfrost/panfrost_drv.c +@@ -692,3 +692,4 @@ module_platform_driver(panfrost_driver); + MODULE_AUTHOR("Panfrost Project Developers"); + MODULE_DESCRIPTION("Panfrost DRM Driver"); + MODULE_LICENSE("GPL v2"); ++MODULE_SOFTDEP("pre: governor_simpleondemand"); diff --git a/queue-5.4/platform-mips-cpu_hwmon-disable-driver-on-unsupported-hardware.patch b/queue-5.4/platform-mips-cpu_hwmon-disable-driver-on-unsupported-hardware.patch new file mode 100644 index 00000000000..26ac669a277 --- /dev/null +++ b/queue-5.4/platform-mips-cpu_hwmon-disable-driver-on-unsupported-hardware.patch @@ -0,0 +1,32 @@ +From f4d430db17b4ef4e9c3c352a04b2fe3c93011978 Mon Sep 17 00:00:00 2001 +From: Jiaxun Yang +Date: Fri, 14 Jun 2024 16:40:15 +0100 +Subject: platform: mips: cpu_hwmon: Disable driver on unsupported hardware + +From: Jiaxun Yang + +commit f4d430db17b4ef4e9c3c352a04b2fe3c93011978 upstream. + +cpu_hwmon is unsupported on CPUs without loongson_chiptemp +register and csr. + +Cc: stable@vger.kernel.org +Signed-off-by: Jiaxun Yang +Signed-off-by: Thomas Bogendoerfer +Signed-off-by: Greg Kroah-Hartman +--- + drivers/platform/mips/cpu_hwmon.c | 3 +++ + 1 file changed, 3 insertions(+) + +--- a/drivers/platform/mips/cpu_hwmon.c ++++ b/drivers/platform/mips/cpu_hwmon.c +@@ -166,6 +166,9 @@ static int __init loongson_hwmon_init(vo + goto fail_hwmon_device_register; + } + ++ if (!csr_temp_enable && !loongson_chiptemp[0]) ++ return -ENODEV; ++ + nr_packages = loongson_sysconf.nr_cpus / + loongson_sysconf.cores_per_package; + diff --git a/queue-5.4/rbd-don-t-assume-rbd_is_lock_owner-for-exclusive-mappings.patch b/queue-5.4/rbd-don-t-assume-rbd_is_lock_owner-for-exclusive-mappings.patch new file mode 100644 index 00000000000..4c0fe5ef5e8 --- /dev/null +++ b/queue-5.4/rbd-don-t-assume-rbd_is_lock_owner-for-exclusive-mappings.patch @@ -0,0 +1,43 @@ +From 3ceccb14f5576e02b81cc8b105ab81f224bd87f6 Mon Sep 17 00:00:00 2001 +From: Ilya Dryomov +Date: Tue, 23 Jul 2024 18:08:08 +0200 +Subject: rbd: don't assume rbd_is_lock_owner() for exclusive mappings + +From: Ilya Dryomov + +commit 3ceccb14f5576e02b81cc8b105ab81f224bd87f6 upstream. + +Expanding on the previous commit, assuming that rbd_is_lock_owner() +always returns true (i.e. that we are either in RBD_LOCK_STATE_LOCKED +or RBD_LOCK_STATE_QUIESCING) if the mapping is exclusive is wrong too. +In case ceph_cls_set_cookie() fails, the lock would be temporarily +released even if the mapping is exclusive, meaning that we can end up +even in RBD_LOCK_STATE_UNLOCKED. + +IOW, exclusive mappings are really "just" about disabling automatic +lock transitions (as documented in the man page), not about grabbing +the lock and holding on to it whatever it takes. + +Cc: stable@vger.kernel.org +Fixes: 637cd060537d ("rbd: new exclusive lock wait/wake code") +Signed-off-by: Ilya Dryomov +Reviewed-by: Dongsheng Yang +Signed-off-by: Greg Kroah-Hartman +--- + drivers/block/rbd.c | 5 ----- + 1 file changed, 5 deletions(-) + +--- a/drivers/block/rbd.c ++++ b/drivers/block/rbd.c +@@ -6618,11 +6618,6 @@ static int rbd_add_acquire_lock(struct r + return ret; + } + +- /* +- * The lock may have been released by now, unless automatic lock +- * transitions are disabled. +- */ +- rbd_assert(!rbd_dev->opts->exclusive || rbd_is_lock_owner(rbd_dev)); + return 0; + } + diff --git a/queue-5.4/rdma-iwcm-fix-a-use-after-free-related-to-destroying-cm-ids.patch b/queue-5.4/rdma-iwcm-fix-a-use-after-free-related-to-destroying-cm-ids.patch new file mode 100644 index 00000000000..f1b37a9a503 --- /dev/null +++ b/queue-5.4/rdma-iwcm-fix-a-use-after-free-related-to-destroying-cm-ids.patch @@ -0,0 +1,74 @@ +From aee2424246f9f1dadc33faa78990c1e2eb7826e4 Mon Sep 17 00:00:00 2001 +From: Bart Van Assche +Date: Wed, 5 Jun 2024 08:51:01 -0600 +Subject: RDMA/iwcm: Fix a use-after-free related to destroying CM IDs + +From: Bart Van Assche + +commit aee2424246f9f1dadc33faa78990c1e2eb7826e4 upstream. + +iw_conn_req_handler() associates a new struct rdma_id_private (conn_id) with +an existing struct iw_cm_id (cm_id) as follows: + + conn_id->cm_id.iw = cm_id; + cm_id->context = conn_id; + cm_id->cm_handler = cma_iw_handler; + +rdma_destroy_id() frees both the cm_id and the struct rdma_id_private. Make +sure that cm_work_handler() does not trigger a use-after-free by only +freeing of the struct rdma_id_private after all pending work has finished. + +Cc: stable@vger.kernel.org +Fixes: 59c68ac31e15 ("iw_cm: free cm_id resources on the last deref") +Reviewed-by: Zhu Yanjun +Tested-by: Shin'ichiro Kawasaki +Signed-off-by: Bart Van Assche +Link: https://lore.kernel.org/r/20240605145117.397751-6-bvanassche@acm.org +Signed-off-by: Leon Romanovsky +Signed-off-by: Greg Kroah-Hartman +--- + drivers/infiniband/core/iwcm.c | 11 +++++++---- + 1 file changed, 7 insertions(+), 4 deletions(-) + +--- a/drivers/infiniband/core/iwcm.c ++++ b/drivers/infiniband/core/iwcm.c +@@ -370,8 +370,10 @@ EXPORT_SYMBOL(iw_cm_disconnect); + * + * Clean up all resources associated with the connection and release + * the initial reference taken by iw_create_cm_id. ++ * ++ * Returns true if and only if the last cm_id_priv reference has been dropped. + */ +-static void destroy_cm_id(struct iw_cm_id *cm_id) ++static bool destroy_cm_id(struct iw_cm_id *cm_id) + { + struct iwcm_id_private *cm_id_priv; + struct ib_qp *qp; +@@ -441,7 +443,7 @@ static void destroy_cm_id(struct iw_cm_i + iwpm_remove_mapping(&cm_id->local_addr, RDMA_NL_IWCM); + } + +- (void)iwcm_deref_id(cm_id_priv); ++ return iwcm_deref_id(cm_id_priv); + } + + /* +@@ -452,7 +454,8 @@ static void destroy_cm_id(struct iw_cm_i + */ + void iw_destroy_cm_id(struct iw_cm_id *cm_id) + { +- destroy_cm_id(cm_id); ++ if (!destroy_cm_id(cm_id)) ++ flush_workqueue(iwcm_wq); + } + EXPORT_SYMBOL(iw_destroy_cm_id); + +@@ -1036,7 +1039,7 @@ static void cm_work_handler(struct work_ + if (!test_bit(IWCM_F_DROP_EVENTS, &cm_id_priv->flags)) { + ret = process_event(cm_id_priv, &levent); + if (ret) +- destroy_cm_id(&cm_id_priv->id); ++ WARN_ON_ONCE(destroy_cm_id(&cm_id_priv->id)); + } else + pr_debug("dropping event %d\n", levent.event); + if (iwcm_deref_id(cm_id_priv)) diff --git a/queue-5.4/selftests-sigaltstack-fix-ppc64-gcc-build.patch b/queue-5.4/selftests-sigaltstack-fix-ppc64-gcc-build.patch new file mode 100644 index 00000000000..a1caf44e0ae --- /dev/null +++ b/queue-5.4/selftests-sigaltstack-fix-ppc64-gcc-build.patch @@ -0,0 +1,48 @@ +From 17c743b9da9e0d073ff19fd5313f521744514939 Mon Sep 17 00:00:00 2001 +From: Michael Ellerman +Date: Mon, 20 May 2024 16:26:47 +1000 +Subject: selftests/sigaltstack: Fix ppc64 GCC build +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +From: Michael Ellerman + +commit 17c743b9da9e0d073ff19fd5313f521744514939 upstream. + +Building the sigaltstack test with GCC on 64-bit powerpc errors with: + + gcc -Wall sas.c -o /home/michael/linux/.build/kselftest/sigaltstack/sas + In file included from sas.c:23: + current_stack_pointer.h:22:2: error: #error "implement current_stack_pointer equivalent" + 22 | #error "implement current_stack_pointer equivalent" + | ^~~~~ + sas.c: In function ‘my_usr1’: + sas.c:50:13: error: ‘sp’ undeclared (first use in this function); did you mean ‘p’? + 50 | if (sp < (unsigned long)sstack || + | ^~ + +This happens because GCC doesn't define __ppc__ for 64-bit builds, only +32-bit builds. Instead use __powerpc__ to detect powerpc builds, which +is defined by clang and GCC for 64-bit and 32-bit builds. + +Fixes: 05107edc9101 ("selftests: sigaltstack: fix -Wuninitialized") +Cc: stable@vger.kernel.org # v6.3+ +Signed-off-by: Michael Ellerman +Link: https://msgid.link/20240520062647.688667-1-mpe@ellerman.id.au +Signed-off-by: Greg Kroah-Hartman +--- + tools/testing/selftests/sigaltstack/current_stack_pointer.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/tools/testing/selftests/sigaltstack/current_stack_pointer.h ++++ b/tools/testing/selftests/sigaltstack/current_stack_pointer.h +@@ -8,7 +8,7 @@ register unsigned long sp asm("sp"); + register unsigned long sp asm("esp"); + #elif __loongarch64 + register unsigned long sp asm("$sp"); +-#elif __ppc__ ++#elif __powerpc__ + register unsigned long sp asm("r1"); + #elif __s390x__ + register unsigned long sp asm("%15"); diff --git a/queue-5.4/series b/queue-5.4/series index f9117c6e835..13452da5090 100644 --- a/queue-5.4/series +++ b/queue-5.4/series @@ -122,3 +122,8 @@ perf-x86-intel-pt-fix-topa_entry-base-length.patch perf-x86-intel-pt-fix-a-topa_entry-base-address-calculation.patch rtc-isl1208-fix-return-value-of-nvmem-callbacks.patch watchdog-perf-properly-initialize-the-turbo-mode-timestamp-and-rearm-counter.patch +platform-mips-cpu_hwmon-disable-driver-on-unsupported-hardware.patch +rdma-iwcm-fix-a-use-after-free-related-to-destroying-cm-ids.patch +selftests-sigaltstack-fix-ppc64-gcc-build.patch +rbd-don-t-assume-rbd_is_lock_owner-for-exclusive-mappings.patch +drm-panfrost-mark-simple_ondemand-governor-as-softdep.patch -- 2.47.3