From 88883d336d26e925e63d5813b2f925f91925c181 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Wed, 12 Jun 2024 14:45:28 +0200 Subject: [PATCH] 5.10-stable patches added patches: afs-don-t-cross-.backup-mountpoint-from-backup-volume.patch binder-fix-max_thread-type-inconsistency.patch io_uring-fail-nop-if-non-zero-op-flags-is-passed-in.patch mmc-core-do-not-force-a-retune-before-rpmb-switch.patch nilfs2-fix-use-after-free-of-timer-for-log-writer-thread.patch --- ...backup-mountpoint-from-backup-volume.patch | 50 +++++++ ...er-fix-max_thread-type-inconsistency.patch | 50 +++++++ ...op-if-non-zero-op-flags-is-passed-in.patch | 38 ++++++ ...ot-force-a-retune-before-rpmb-switch.patch | 66 ++++++++++ ...-free-of-timer-for-log-writer-thread.patch | 122 ++++++++++++++++++ queue-5.10/series | 5 + 6 files changed, 331 insertions(+) create mode 100644 queue-5.10/afs-don-t-cross-.backup-mountpoint-from-backup-volume.patch create mode 100644 queue-5.10/binder-fix-max_thread-type-inconsistency.patch create mode 100644 queue-5.10/io_uring-fail-nop-if-non-zero-op-flags-is-passed-in.patch create mode 100644 queue-5.10/mmc-core-do-not-force-a-retune-before-rpmb-switch.patch create mode 100644 queue-5.10/nilfs2-fix-use-after-free-of-timer-for-log-writer-thread.patch diff --git a/queue-5.10/afs-don-t-cross-.backup-mountpoint-from-backup-volume.patch b/queue-5.10/afs-don-t-cross-.backup-mountpoint-from-backup-volume.patch new file mode 100644 index 00000000000..8615127058d --- /dev/null +++ b/queue-5.10/afs-don-t-cross-.backup-mountpoint-from-backup-volume.patch @@ -0,0 +1,50 @@ +From 29be9100aca2915fab54b5693309bc42956542e5 Mon Sep 17 00:00:00 2001 +From: Marc Dionne +Date: Fri, 24 May 2024 17:17:55 +0100 +Subject: afs: Don't cross .backup mountpoint from backup volume + +From: Marc Dionne + +commit 29be9100aca2915fab54b5693309bc42956542e5 upstream. + +Don't cross a mountpoint that explicitly specifies a backup volume +(target is .backup) when starting from a backup volume. + +It it not uncommon to mount a volume's backup directly in the volume +itself. This can cause tools that are not paying attention to get +into a loop mounting the volume onto itself as they attempt to +traverse the tree, leading to a variety of problems. + +This doesn't prevent the general case of loops in a sequence of +mountpoints, but addresses a common special case in the same way +as other afs clients. + +Reported-by: Jan Henrik Sylvester +Link: http://lists.infradead.org/pipermail/linux-afs/2024-May/008454.html +Reported-by: Markus Suvanto +Link: http://lists.infradead.org/pipermail/linux-afs/2024-February/008074.html +Signed-off-by: Marc Dionne +Signed-off-by: David Howells +Link: https://lore.kernel.org/r/768760.1716567475@warthog.procyon.org.uk +Reviewed-by: Jeffrey Altman +cc: linux-afs@lists.infradead.org +Signed-off-by: Christian Brauner +Signed-off-by: Greg Kroah-Hartman +--- + fs/afs/mntpt.c | 5 +++++ + 1 file changed, 5 insertions(+) + +--- a/fs/afs/mntpt.c ++++ b/fs/afs/mntpt.c +@@ -146,6 +146,11 @@ static int afs_mntpt_set_params(struct f + put_page(page); + if (ret < 0) + return ret; ++ ++ /* Don't cross a backup volume mountpoint from a backup volume */ ++ if (src_as->volume && src_as->volume->type == AFSVL_BACKVOL && ++ ctx->type == AFSVL_BACKVOL) ++ return -ENODEV; + } + + return 0; diff --git a/queue-5.10/binder-fix-max_thread-type-inconsistency.patch b/queue-5.10/binder-fix-max_thread-type-inconsistency.patch new file mode 100644 index 00000000000..b240ef84eb0 --- /dev/null +++ b/queue-5.10/binder-fix-max_thread-type-inconsistency.patch @@ -0,0 +1,50 @@ +From 42316941335644a98335f209daafa4c122f28983 Mon Sep 17 00:00:00 2001 +From: Carlos Llamas +Date: Sun, 21 Apr 2024 17:37:49 +0000 +Subject: binder: fix max_thread type inconsistency +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +From: Carlos Llamas + +commit 42316941335644a98335f209daafa4c122f28983 upstream. + +The type defined for the BINDER_SET_MAX_THREADS ioctl was changed from +size_t to __u32 in order to avoid incompatibility issues between 32 and +64-bit kernels. However, the internal types used to copy from user and +store the value were never updated. Use u32 to fix the inconsistency. + +Fixes: a9350fc859ae ("staging: android: binder: fix BINDER_SET_MAX_THREADS declaration") +Reported-by: Arve Hjønnevåg +Cc: stable@vger.kernel.org +Signed-off-by: Carlos Llamas +Reviewed-by: Alice Ryhl +Link: https://lore.kernel.org/r/20240421173750.3117808-1-cmllamas@google.com +[cmllamas: resolve minor conflicts due to missing commit 421518a2740f] +Signed-off-by: Carlos Llamas +Signed-off-by: Greg Kroah-Hartman +--- + drivers/android/binder.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +--- a/drivers/android/binder.c ++++ b/drivers/android/binder.c +@@ -476,7 +476,7 @@ struct binder_proc { + struct list_head todo; + struct binder_stats stats; + struct list_head delivered_death; +- int max_threads; ++ u32 max_threads; + int requested_threads; + int requested_threads_started; + int tmp_ref; +@@ -5408,7 +5408,7 @@ static long binder_ioctl(struct file *fi + goto err; + break; + case BINDER_SET_MAX_THREADS: { +- int max_threads; ++ u32 max_threads; + + if (copy_from_user(&max_threads, ubuf, + sizeof(max_threads))) { diff --git a/queue-5.10/io_uring-fail-nop-if-non-zero-op-flags-is-passed-in.patch b/queue-5.10/io_uring-fail-nop-if-non-zero-op-flags-is-passed-in.patch new file mode 100644 index 00000000000..0658f2b6a46 --- /dev/null +++ b/queue-5.10/io_uring-fail-nop-if-non-zero-op-flags-is-passed-in.patch @@ -0,0 +1,38 @@ +From 3d8f874bd620ce03f75a5512847586828ab86544 Mon Sep 17 00:00:00 2001 +From: Ming Lei +Date: Fri, 10 May 2024 11:50:27 +0800 +Subject: io_uring: fail NOP if non-zero op flags is passed in + +From: Ming Lei + +commit 3d8f874bd620ce03f75a5512847586828ab86544 upstream. + +The NOP op flags should have been checked from beginning like any other +opcode, otherwise NOP may not be extended with the op flags. + +Given both liburing and Rust io-uring crate always zeros SQE op flags, just +ignore users which play raw NOP uring interface without zeroing SQE, because +NOP is just for test purpose. Then we can save one NOP2 opcode. + +Suggested-by: Jens Axboe +Fixes: 2b188cc1bb85 ("Add io_uring IO interface") +Cc: stable@vger.kernel.org +Signed-off-by: Ming Lei +Link: https://lore.kernel.org/r/20240510035031.78874-2-ming.lei@redhat.com +Signed-off-by: Jens Axboe +Signed-off-by: Greg Kroah-Hartman +--- + io_uring/io_uring.c | 2 ++ + 1 file changed, 2 insertions(+) + +--- a/io_uring/io_uring.c ++++ b/io_uring/io_uring.c +@@ -6474,6 +6474,8 @@ static int io_req_prep(struct io_kiocb * + { + switch (req->opcode) { + case IORING_OP_NOP: ++ if (READ_ONCE(sqe->rw_flags)) ++ return -EINVAL; + return 0; + case IORING_OP_READV: + case IORING_OP_READ_FIXED: diff --git a/queue-5.10/mmc-core-do-not-force-a-retune-before-rpmb-switch.patch b/queue-5.10/mmc-core-do-not-force-a-retune-before-rpmb-switch.patch new file mode 100644 index 00000000000..8e4f7e16215 --- /dev/null +++ b/queue-5.10/mmc-core-do-not-force-a-retune-before-rpmb-switch.patch @@ -0,0 +1,66 @@ +From 67380251e8bbd3302c64fea07f95c31971b91c22 Mon Sep 17 00:00:00 2001 +From: Jorge Ramirez-Ortiz +Date: Wed, 3 Jan 2024 12:29:11 +0100 +Subject: mmc: core: Do not force a retune before RPMB switch + +From: Jorge Ramirez-Ortiz + +commit 67380251e8bbd3302c64fea07f95c31971b91c22 upstream. + +Requesting a retune before switching to the RPMB partition has been +observed to cause CRC errors on the RPMB reads (-EILSEQ). + +Since RPMB reads can not be retried, the clients would be directly +affected by the errors. + +This commit disables the retune request prior to switching to the RPMB +partition: mmc_retune_pause() no longer triggers a retune before the +pause period begins. + +This was verified with the sdhci-of-arasan driver (ZynqMP) configured +for HS200 using two separate eMMC cards (DG4064 and 064GB2). In both +cases, the error was easy to reproduce triggering every few tenths of +reads. + +With this commit, systems that were utilizing OP-TEE to access RPMB +variables will experience an enhanced performance. Specifically, when +OP-TEE is configured to employ RPMB as a secure storage solution, it not +only writes the data but also the secure filesystem within the +partition. As a result, retrieving any variable involves multiple RPMB +reads, typically around five. + +For context, on ZynqMP, each retune request consumed approximately +8ms. Consequently, reading any RPMB variable used to take at the very +minimum 40ms. + +After droping the need to retune before switching to the RPMB partition, +this is no longer the case. + +Signed-off-by: Jorge Ramirez-Ortiz +Acked-by: Avri Altman +Acked-by: Adrian Hunter +Link: https://lore.kernel.org/r/20240103112911.2954632-1-jorge@foundries.io +Signed-off-by: Ulf Hansson +Signed-off-by: Florian Fainelli +Signed-off-by: Greg Kroah-Hartman +--- + drivers/mmc/core/host.c | 3 +-- + 1 file changed, 1 insertion(+), 2 deletions(-) + +--- a/drivers/mmc/core/host.c ++++ b/drivers/mmc/core/host.c +@@ -114,13 +114,12 @@ void mmc_retune_enable(struct mmc_host * + + /* + * Pause re-tuning for a small set of operations. The pause begins after the +- * next command and after first doing re-tuning. ++ * next command. + */ + void mmc_retune_pause(struct mmc_host *host) + { + if (!host->retune_paused) { + host->retune_paused = 1; +- mmc_retune_needed(host); + mmc_retune_hold(host); + } + } diff --git a/queue-5.10/nilfs2-fix-use-after-free-of-timer-for-log-writer-thread.patch b/queue-5.10/nilfs2-fix-use-after-free-of-timer-for-log-writer-thread.patch new file mode 100644 index 00000000000..c0cb4212f56 --- /dev/null +++ b/queue-5.10/nilfs2-fix-use-after-free-of-timer-for-log-writer-thread.patch @@ -0,0 +1,122 @@ +From f5d4e04634c9cf68bdf23de08ada0bb92e8befe7 Mon Sep 17 00:00:00 2001 +From: Ryusuke Konishi +Date: Mon, 20 May 2024 22:26:19 +0900 +Subject: nilfs2: fix use-after-free of timer for log writer thread + +From: Ryusuke Konishi + +commit f5d4e04634c9cf68bdf23de08ada0bb92e8befe7 upstream. + +Patch series "nilfs2: fix log writer related issues". + +This bug fix series covers three nilfs2 log writer-related issues, +including a timer use-after-free issue and potential deadlock issue on +unmount, and a potential freeze issue in event synchronization found +during their analysis. Details are described in each commit log. + + +This patch (of 3): + +A use-after-free issue has been reported regarding the timer sc_timer on +the nilfs_sc_info structure. + +The problem is that even though it is used to wake up a sleeping log +writer thread, sc_timer is not shut down until the nilfs_sc_info structure +is about to be freed, and is used regardless of the thread's lifetime. + +Fix this issue by limiting the use of sc_timer only while the log writer +thread is alive. + +Link: https://lkml.kernel.org/r/20240520132621.4054-1-konishi.ryusuke@gmail.com +Link: https://lkml.kernel.org/r/20240520132621.4054-2-konishi.ryusuke@gmail.com +Fixes: fdce895ea5dd ("nilfs2: change sc_timer from a pointer to an embedded one in struct nilfs_sc_info") +Signed-off-by: Ryusuke Konishi +Reported-by: "Bai, Shuangpeng" +Closes: https://groups.google.com/g/syzkaller/c/MK_LYqtt8ko/m/8rgdWeseAwAJ +Tested-by: Ryusuke Konishi +Cc: +Signed-off-by: Andrew Morton +Signed-off-by: Greg Kroah-Hartman +--- + fs/nilfs2/segment.c | 25 +++++++++++++++++++------ + 1 file changed, 19 insertions(+), 6 deletions(-) + +--- a/fs/nilfs2/segment.c ++++ b/fs/nilfs2/segment.c +@@ -2164,8 +2164,10 @@ static void nilfs_segctor_start_timer(st + { + spin_lock(&sci->sc_state_lock); + if (!(sci->sc_state & NILFS_SEGCTOR_COMMIT)) { +- sci->sc_timer.expires = jiffies + sci->sc_interval; +- add_timer(&sci->sc_timer); ++ if (sci->sc_task) { ++ sci->sc_timer.expires = jiffies + sci->sc_interval; ++ add_timer(&sci->sc_timer); ++ } + sci->sc_state |= NILFS_SEGCTOR_COMMIT; + } + spin_unlock(&sci->sc_state_lock); +@@ -2385,10 +2387,21 @@ int nilfs_construct_dsync_segment(struct + */ + static void nilfs_segctor_accept(struct nilfs_sc_info *sci) + { ++ bool thread_is_alive; ++ + spin_lock(&sci->sc_state_lock); + sci->sc_seq_accepted = sci->sc_seq_request; ++ thread_is_alive = (bool)sci->sc_task; + spin_unlock(&sci->sc_state_lock); +- del_timer_sync(&sci->sc_timer); ++ ++ /* ++ * This function does not race with the log writer thread's ++ * termination. Therefore, deleting sc_timer, which should not be ++ * done after the log writer thread exits, can be done safely outside ++ * the area protected by sc_state_lock. ++ */ ++ if (thread_is_alive) ++ del_timer_sync(&sci->sc_timer); + } + + /** +@@ -2414,7 +2427,7 @@ static void nilfs_segctor_notify(struct + sci->sc_flush_request &= ~FLUSH_DAT_BIT; + + /* re-enable timer if checkpoint creation was not done */ +- if ((sci->sc_state & NILFS_SEGCTOR_COMMIT) && ++ if ((sci->sc_state & NILFS_SEGCTOR_COMMIT) && sci->sc_task && + time_before(jiffies, sci->sc_timer.expires)) + add_timer(&sci->sc_timer); + } +@@ -2604,6 +2617,7 @@ static int nilfs_segctor_thread(void *ar + int timeout = 0; + + sci->sc_timer_task = current; ++ timer_setup(&sci->sc_timer, nilfs_construction_timeout, 0); + + /* start sync. */ + sci->sc_task = current; +@@ -2670,6 +2684,7 @@ static int nilfs_segctor_thread(void *ar + end_thread: + /* end sync. */ + sci->sc_task = NULL; ++ del_timer_sync(&sci->sc_timer); + wake_up(&sci->sc_wait_task); /* for nilfs_segctor_kill_thread() */ + spin_unlock(&sci->sc_state_lock); + return 0; +@@ -2733,7 +2748,6 @@ static struct nilfs_sc_info *nilfs_segct + INIT_LIST_HEAD(&sci->sc_gc_inodes); + INIT_LIST_HEAD(&sci->sc_iput_queue); + INIT_WORK(&sci->sc_iput_work, nilfs_iput_work_func); +- timer_setup(&sci->sc_timer, nilfs_construction_timeout, 0); + + sci->sc_interval = HZ * NILFS_SC_DEFAULT_TIMEOUT; + sci->sc_mjcp_freq = HZ * NILFS_SC_DEFAULT_SR_FREQ; +@@ -2819,7 +2833,6 @@ static void nilfs_segctor_destroy(struct + + down_write(&nilfs->ns_segctor_sem); + +- del_timer_sync(&sci->sc_timer); + kfree(sci); + } + diff --git a/queue-5.10/series b/queue-5.10/series index 56ed916c6a6..efa68b26464 100644 --- a/queue-5.10/series +++ b/queue-5.10/series @@ -263,3 +263,8 @@ alsa-timer-set-lower-bound-of-start-tick-time.patch genirq-cpuhotplug-x86-vector-prevent-vector-leak-during-cpu-offline.patch media-cec-core-add-adap_nb_transmit_canceled-callback.patch sunrpc-fix-loop-termination-condition-in-gss_free_in_token_pages.patch +binder-fix-max_thread-type-inconsistency.patch +mmc-core-do-not-force-a-retune-before-rpmb-switch.patch +io_uring-fail-nop-if-non-zero-op-flags-is-passed-in.patch +afs-don-t-cross-.backup-mountpoint-from-backup-volume.patch +nilfs2-fix-use-after-free-of-timer-for-log-writer-thread.patch -- 2.47.3