From: Greg Kroah-Hartman Date: Wed, 12 Jun 2024 12:45:00 +0000 (+0200) Subject: 4.19-stable patches X-Git-Tag: v4.19.316~137 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=852c3afe109c14b99b599ca412ab80443b7bc823;p=thirdparty%2Fkernel%2Fstable-queue.git 4.19-stable patches added patches: binder-fix-max_thread-type-inconsistency.patch mmc-core-do-not-force-a-retune-before-rpmb-switch.patch nilfs2-fix-use-after-free-of-timer-for-log-writer-thread.patch --- diff --git a/queue-4.19/binder-fix-max_thread-type-inconsistency.patch b/queue-4.19/binder-fix-max_thread-type-inconsistency.patch new file mode 100644 index 00000000000..9048ca230ce --- /dev/null +++ b/queue-4.19/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 +@@ -540,7 +540,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; +@@ -4658,7 +4658,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-4.19/mmc-core-do-not-force-a-retune-before-rpmb-switch.patch b/queue-4.19/mmc-core-do-not-force-a-retune-before-rpmb-switch.patch new file mode 100644 index 00000000000..3a2381fc5fd --- /dev/null +++ b/queue-4.19/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 +@@ -68,13 +68,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-4.19/nilfs2-fix-use-after-free-of-timer-for-log-writer-thread.patch b/queue-4.19/nilfs2-fix-use-after-free-of-timer-for-log-writer-thread.patch new file mode 100644 index 00000000000..53b492cbd11 --- /dev/null +++ b/queue-4.19/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 +@@ -2159,8 +2159,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); +@@ -2380,10 +2382,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); + } + + /** +@@ -2409,7 +2422,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); + } +@@ -2599,6 +2612,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; +@@ -2665,6 +2679,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; +@@ -2728,7 +2743,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; +@@ -2814,7 +2828,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-4.19/series b/queue-4.19/series index 57f9eadbf44..4b625c916a9 100644 --- a/queue-4.19/series +++ b/queue-4.19/series @@ -143,3 +143,6 @@ ipvlan-dont-use-skb-sk-in-ipvlan_process_v-4-6-_outb.patch alsa-timer-set-lower-bound-of-start-tick-time.patch genirq-cpuhotplug-x86-vector-prevent-vector-leak-during-cpu-offline.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 +nilfs2-fix-use-after-free-of-timer-for-log-writer-thread.patch