FAILED: patch "[PATCH] f2fs: avoid NULL checkpoint thread access in sysfs" failed to apply to 5.15-stable tree
Subsystems (2)
[email protected]
maintainerThe patch below does not apply to the 5.15-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-5.15.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-appease-drainpipe-8027@gregkh' --subject-prefix 'PATCH 5.15.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/4 f2fs: convert to use sysfs_emit
From: Yangtao Li <[email protected]>
[ Upstream commit 084e15ea14bbb1ad40163438cfa74a76a1521c16 ]
Let's use sysfs_emit.
Stable-dep-of: 5cb33b00c8fb ("f2fs: avoid NULL checkpoint thread access in sysfs")
--- fs/f2fs/sysfs.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-)
fs/f2fs/sysfs.c +3 -8
@@ -302,19 +302,14 @@ 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 len =0 ;int class =IOPRIO_PRIO_CLASS (cprc->ckpt_thread_ioprio);int data =IOPRIO_PRIO_DATA (cprc->ckpt_thread_ioprio); -if (class ==IOPRIO_CLASS_RT ) - len +=scnprintf (buf + len,PAGE_SIZE - len,"rt," ); -else if (class ==IOPRIO_CLASS_BE ) - len +=scnprintf (buf + len,PAGE_SIZE - len,"be," ); -else +if (class !=IOPRIO_CLASS_RT && class !=IOPRIO_CLASS_BE )return -EINVAL ; - len +=scnprintf (buf + len,PAGE_SIZE - len,"%d\n" , data); -return len; +return sysfs_emit (buf,"%s,%d\n" , + class ==IOPRIO_CLASS_RT ?"rt" :"be" , data); }#ifdef CONFIG_F2FS_FS_COMPRESSION
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 2/4 scsi: block: ioprio: Clean up interface definition
From: Damien Le Moal <[email protected]>
[ Upstream commit eca2040972b411ec27483bf75dc8b84e730e88ff ]
The I/O priority user interface defines the 16-bits ioprio values as the combination of the upper 3-bits for an I/O priority class and the lower 13-bits as priority data. However, the kernel only uses the lower 3-bits of the priority data to define priority levels for the RT and BE priority classes. The data part of an ioprio value is completely ignored for the IDLE and NONE classes. This is enforced by checks done in ioprio_check_cap(), which is called for all paths that allow defining an I/O priority for I/Os: the per-context ioprio_set() system call, aio interface and io_uring interface.
Clarify this fact in the uapi ioprio.h header file and introduce the IOPRIO_PRIO_LEVEL_MASK and IOPRIO_PRIO_LEVEL() macros for users to define and get priority levels in an ioprio value. The coarser macro IOPRIO_PRIO_DATA() is retained for backward compatibility with old applications already using it. There is no functional change introduced with this.
In-kernel users of the IOPRIO_PRIO_DATA() macro which are explicitly handling I/O priority data as a priority level are modified to use the new IOPRIO_PRIO_LEVEL() macro without any functional change. Since f2fs is the only user of this macro not explicitly using that value as a priority level, it is left unchanged.
Stable-dep-of: 5cb33b00c8fb ("f2fs: avoid NULL checkpoint thread access in sysfs")
--- block/bfq-iosched.c | 8 ++++---- block/ioprio.c | 6 +++--- include/uapi/linux/ioprio.h | 19 ++++++++++++++----- 3 files changed, 21 insertions(+), 12 deletions(-)
block/bfq-iosched.c +4 -4
@@ -5314,16 +5314,16 @@ bfq_set_next_ioprio_data(struct bfq_queue *bfqq, struct bfq_io_cq *bic) bfqq->new_ioprio_class =task_nice_ioclass (tsk);break ;case IOPRIO_CLASS_RT : - bfqq->new_ioprio =IOPRIO_PRIO_DATA (bic->ioprio); + bfqq->new_ioprio =IOPRIO_PRIO_LEVEL (bic->ioprio); bfqq->new_ioprio_class =IOPRIO_CLASS_RT ;break ;case IOPRIO_CLASS_BE : - bfqq->new_ioprio =IOPRIO_PRIO_DATA (bic->ioprio); + bfqq->new_ioprio =IOPRIO_PRIO_LEVEL (bic->ioprio); bfqq->new_ioprio_class =IOPRIO_CLASS_BE ;break ;case IOPRIO_CLASS_IDLE : bfqq->new_ioprio_class =IOPRIO_CLASS_IDLE ; - bfqq->new_ioprio =7 ; + bfqq->new_ioprio =IOPRIO_NR_LEVELS -1 ;break ; }
@@ -5607,7 +5607,7 @@ static struct bfq_queue *bfq_get_queue(struct bfq_data *bfqd, struct bfq_io_cq *bic, bool respawn) { -const int ioprio =IOPRIO_PRIO_DATA (bic->ioprio); +const int ioprio =IOPRIO_PRIO_LEVEL (bic->ioprio);const int ioprio_class =IOPRIO_PRIO_CLASS (bic->ioprio);struct bfq_queue **async_bfqq =NULL ;struct bfq_queue *bfqq;
block/ioprio.c +3 -3
@@ -65,7 +65,7 @@ EXPORT_SYMBOL_GPL(set_task_ioprio);int ioprio_check_cap (int ioprio) {int class =IOPRIO_PRIO_CLASS (ioprio); -int data =IOPRIO_PRIO_DATA (ioprio); +int level =IOPRIO_PRIO_LEVEL (ioprio);switch (class) {case IOPRIO_CLASS_RT :
@@ -81,13 +81,13 @@ int ioprio_check_cap(int ioprio) fallthrough;/* rt has prio field too */ case IOPRIO_CLASS_BE : -if (data >=IOPRIO_NR_LEVELS || data <0 ) +if (level >=IOPRIO_NR_LEVELS )return -EINVAL ;break ;case IOPRIO_CLASS_IDLE :break ;case IOPRIO_CLASS_NONE : -if (data) +if (level)return -EINVAL ;break ;default :
include/uapi/linux/ioprio.h +14 -5
@@ -17,7 +17,7 @@ ((data) & IOPRIO_PRIO_MASK))/* -* These are the io priority groups as implemented by the BFQ and mq-deadline +* These are the io priority classes as implemented by the BFQ and mq-deadline * schedulers. RT is the realtime class, it always gets premium service. For * ATA disks supporting NCQ IO priority, RT class IOs will be processed using * high priority NCQ commands. BE is the best-effort scheduling class, the
@@ -32,11 +32,20 @@ enum { };/* -* The RT and BE priority classes both support up to 8 priority levels. +* The RT and BE priority classes both support up to 8 priority levels that +* can be specified using the lower 3-bits of the priority data. */ -#define IOPRIO_NR_LEVELS 8 -#define IOPRIO_BE_NR IOPRIO_NR_LEVELS +#define IOPRIO_LEVEL_NR_BITS 3 +#define IOPRIO_NR_LEVELS (1 << IOPRIO_LEVEL_NR_BITS) +#define IOPRIO_LEVEL_MASK (IOPRIO_NR_LEVELS - 1) +#define IOPRIO_PRIO_LEVEL (ioprio) ((ioprio) & IOPRIO_LEVEL_MASK) +#define IOPRIO_BE_NR IOPRIO_NR_LEVELS + +/* +* Possible values for the "which" argument of the ioprio_get() and +* ioprio_set() system calls (see "man ioprio_set"). +*/ enum {IOPRIO_WHO_PROCESS =1 ,IOPRIO_WHO_PGRP ,
@@ -44,7 +53,7 @@ enum { };/* -* Fallback BE priority level. +* Fallback BE class priority level. */ #define IOPRIO_NORM 4#define IOPRIO_BE_NORM IOPRIO_NORM
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 3/4 f2fs: use new ioprio Macro to get ckpt thread ioprio level
In reply to Sasha LevinFrom: 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
@@ -303,13 +303,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
@@ -409,7 +409,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 ))
@@ -420,13 +420,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 4/4 f2fs: avoid NULL checkpoint thread access in sysfs
In reply to Sasha LevinFrom: 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
@@ -427,7 +427,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)
@@ -607,13 +607,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