FAILED: patch "[PATCH] f2fs: avoid NULL checkpoint thread access in sysfs" failed to apply to 6.6-stable tree
Subsystems (2)
[email protected]
maintainerThe patch below does not apply to the 6.6-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.6.y
git checkout FETCH_HEAD
git cherry-pick -x 5cb33b00c8fbb6e8f1fa3d281c3036d5f7c7c41f
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2026090930-parkway-apply-1c3d@gregkh' --subject-prefix 'PATCH 6.6.y' 'HEAD^..'
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 5cb33b00c8fbb6e8f1fa3d281c3036d5f7c7c41f Mon Sep 17 00:00:00 2001
From: Wenjie Qi <[email protected]>
Date: Tue, 4 Aug 2026 09:48:48 +0800
Subject: [PATCH] f2fs: avoid NULL checkpoint thread access in sysfs
checkpoint_merge can be enabled even when no checkpoint merge thread is running. A read-only mount is one case: f2fs does not start f2fs_issue_ckpt there, but ckpt_thread_ioprio is still writable through sysfs.
The ckpt_thread_ioprio store path updates the saved ioprio value and, when checkpoint_merge is enabled, calls set_task_ioprio() for the checkpoint thread. If cprc->f2fs_issue_ckpt is NULL, that dereferences a NULL task pointer.
Protect ckpt_thread_ioprio sysfs writes with s_umount as well, so the checkpoint thread cannot disappear under the store path while updating its ioprio.
fs/f2fs/sysfs.c +4 -3
@@ -557,7 +557,7 @@ static ssize_t __sbi_store(struct f2fs_attr *a,return -EINVAL ; cprc->ckpt_thread_ioprio =IOPRIO_PRIO_VALUE (class, level); -if (test_opt (sbi,MERGE_CHECKPOINT )) { +if (cprc->f2fs_issue_ckpt) { ret =set_task_ioprio (cprc->f2fs_issue_ckpt, cprc->ckpt_thread_ioprio);if (ret)
@@ -1007,13 +1007,14 @@ static ssize_t f2fs_sbi_store(struct f2fs_attr *a,ssize_t ret;bool gc_entry = (!strcmp (a->attr.name,"gc_urgent" ) || a->struct_type ==GC_THREAD ); +bool thread_entry = !strcmp (a->attr.name,"ckpt_thread_ioprio" ); -if (gc_entry) { +if (gc_entry || thread_entry) {if (!down_read_trylock (&sbi->sb->s_umount))return -EAGAIN ; } ret =__sbi_store (a, sbi, buf, count); -if (gc_entry) +if (gc_entry || thread_entry)up_read (&sbi->sb->s_umount);return ret;
Sasha Levin
maintainerPATCH 1/2 f2fs: use new ioprio Macro to get ckpt thread ioprio level
From: Zhiguo Niu <[email protected]>
[ Upstream commit 270b09313b4e16cdfd01d8371023a1661dd1112e ]
IOPRIO_PRIO_DATA in the new kernel version includes level and hint, So Macro IOPRIO_PRIO_LEVEL is more accurate to get ckpt thread ioprio data/level, and it is also consisten with the way setting ckpt thread ioprio by IOPRIO_PRIO_VALUE(class, data/level).
Besides, change variable name from "data" to "level" for more readable.
Stable-dep-of: 5cb33b00c8fb ("f2fs: avoid NULL checkpoint thread access in sysfs")
--- fs/f2fs/sysfs.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
fs/f2fs/sysfs.c +6 -6
@@ -339,13 +339,13 @@ static ssize_t f2fs_sbi_show(struct f2fs_attr *a,if (!strcmp (a->attr.name,"ckpt_thread_ioprio" )) {struct ckpt_req_control *cprc = &sbi->cprc_info;int class =IOPRIO_PRIO_CLASS (cprc->ckpt_thread_ioprio); -int data =IOPRIO_PRIO_DATA (cprc->ckpt_thread_ioprio); +int level =IOPRIO_PRIO_LEVEL (cprc->ckpt_thread_ioprio);if (class !=IOPRIO_CLASS_RT && class !=IOPRIO_CLASS_BE )return -EINVAL ;return sysfs_emit (buf,"%s,%d\n" , - class ==IOPRIO_CLASS_RT ?"rt" :"be" , data); + class ==IOPRIO_CLASS_RT ?"rt" :"be" , level); }#ifdef CONFIG_F2FS_FS_COMPRESSION
@@ -470,7 +470,7 @@ static ssize_t __sbi_store(struct f2fs_attr *a,const char *name =strim ((char *)buf);struct ckpt_req_control *cprc = &sbi->cprc_info;int class; -long data; +long level;int ret;if (!strncmp (name,"rt," ,3 ))
@@ -481,13 +481,13 @@ static ssize_t __sbi_store(struct f2fs_attr *a,return -EINVAL ; name +=3 ; - ret =kstrtol (name,10 , &data); + ret =kstrtol (name,10 , &level);if (ret)return ret; -if (data >=IOPRIO_NR_LEVELS || data <0 ) +if (level >=IOPRIO_NR_LEVELS || level <0 )return -EINVAL ; - cprc->ckpt_thread_ioprio =IOPRIO_PRIO_VALUE (class, data); + cprc->ckpt_thread_ioprio =IOPRIO_PRIO_VALUE (class, level);if (test_opt (sbi,MERGE_CHECKPOINT )) { ret =set_task_ioprio (cprc->f2fs_issue_ckpt, cprc->ckpt_thread_ioprio);
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 2/2 f2fs: avoid NULL checkpoint thread access in sysfs
From: Wenjie Qi <[email protected]>
[ Upstream commit 5cb33b00c8fbb6e8f1fa3d281c3036d5f7c7c41f ]
checkpoint_merge can be enabled even when no checkpoint merge thread is running. A read-only mount is one case: f2fs does not start f2fs_issue_ckpt there, but ckpt_thread_ioprio is still writable through sysfs.
The ckpt_thread_ioprio store path updates the saved ioprio value and, when checkpoint_merge is enabled, calls set_task_ioprio() for the checkpoint thread. If cprc->f2fs_issue_ckpt is NULL, that dereferences a NULL task pointer.
Protect ckpt_thread_ioprio sysfs writes with s_umount as well, so the checkpoint thread cannot disappear under the store path while updating its ioprio.
--- fs/f2fs/sysfs.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
fs/f2fs/sysfs.c +4 -3
@@ -488,7 +488,7 @@ static ssize_t __sbi_store(struct f2fs_attr *a,return -EINVAL ; cprc->ckpt_thread_ioprio =IOPRIO_PRIO_VALUE (class, level); -if (test_opt (sbi,MERGE_CHECKPOINT )) { +if (cprc->f2fs_issue_ckpt) { ret =set_task_ioprio (cprc->f2fs_issue_ckpt, cprc->ckpt_thread_ioprio);if (ret)
@@ -799,13 +799,14 @@ static ssize_t f2fs_sbi_store(struct f2fs_attr *a,ssize_t ret;bool gc_entry = (!strcmp (a->attr.name,"gc_urgent" ) || a->struct_type ==GC_THREAD ); +bool thread_entry = !strcmp (a->attr.name,"ckpt_thread_ioprio" ); -if (gc_entry) { +if (gc_entry || thread_entry) {if (!down_read_trylock (&sbi->sb->s_umount))return -EAGAIN ; } ret =__sbi_store (a, sbi, buf, count); -if (gc_entry) +if (gc_entry || thread_entry)up_read (&sbi->sb->s_umount);return ret;
Signature · 1 line
2.53.0