From: Chao Yu via Linux-f2fs-devel <linux-f2fs-devel@lists.sourceforge.net>
To: Wenjie Qi <qwjhust@gmail.com>, jaegeuk@kernel.org
Cc: stable@kernel.org, qiwenjie@xiaomi.com,
linux-kernel@vger.kernel.org,
linux-f2fs-devel@lists.sourceforge.net
Subject: Re: [f2fs-dev] [PATCH] f2fs: avoid NULL checkpoint thread access in sysfs
Date: Mon, 3 Aug 2026 15:53:45 +0800 [thread overview]
Message-ID: <c235897c-bec7-45f2-aed9-1efa7e0646ed@kernel.org> (raw)
In-Reply-To: <20260724090532.351989-1-qiwenjie@xiaomi.com>
On 7/24/26 17:05, Wenjie Qi wrote:
> checkpoint_merge is set by default, but the checkpoint merge thread is not
> created for read-only mounts. The ckpt_thread_ioprio sysfs store path uses
> the mount option to decide whether to update the task ioprio. On such
> mounts, writing the node passes a NULL task to set_task_ioprio().
>
> Keep storing the requested ioprio, but apply it only when the checkpoint
> thread exists. Take s_umount for ckpt_thread_ioprio and
> critical_task_priority too, matching the existing protection for GC thread
> entries.
>
> Fixes: e65920661708 ("f2fs: add ckpt_thread_ioprio sysfs node")
> Cc: stable@kernel.org
> Signed-off-by: Wenjie Qi <qiwenjie@xiaomi.com>
> ---
> Reproducer:
> mount -o ro -t f2fs /dev/vdb /mnt/f2fs
> echo be,4 > /sys/fs/f2fs/vdb/ckpt_thread_ioprio
>
> Baseline dmesg:
> Oops: general protection fault
> KASAN: null-ptr-deref in range [0x00000000000007b0-0x00000000000007b7]
> RIP: set_task_ioprio+0x8b/0x360
> Call Trace:
> f2fs_sbi_store+0x2af/0x2580
> kernfs_fop_write_iter+0x360/0x620
> vfs_write+0x5f8/0xf50
> ksys_write+0xf9/0x1d0
> do_syscall_64+0x5f/0x550
>
> fs/f2fs/sysfs.c | 9 ++++++---
> 1 file changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/fs/f2fs/sysfs.c b/fs/f2fs/sysfs.c
> index be92c05a5420..0294544d3d34 100644
> --- a/fs/f2fs/sysfs.c
> +++ b/fs/f2fs/sysfs.c
> @@ -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,16 @@ 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 = gc_entry ||
> + !strcmp(a->attr.name, "ckpt_thread_ioprio") ||
> + !strcmp(a->attr.name, "critical_task_priority");
Oh, seems you fixed another race issue in this patch as well?
"mount -o remount,ro" vs "echo xx > critical_task_priority"
Can you fix this in a separated patch?
>
> - if (gc_entry) {
> + if (thread_entry) {
bool thread_entry = !strcmp(a->attr.name, "ckpt_thread_ioprio") ||
!strcmp(a->attr.name, "critical_task_priority");
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 (thread_entry)
if (gc_entry || thread_entry)
Thanks,
> up_read(&sbi->sb->s_umount);
>
> return ret;
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
WARNING: multiple messages have this Message-ID (diff)
From: Chao Yu <chao@kernel.org>
To: Wenjie Qi <qwjhust@gmail.com>, jaegeuk@kernel.org
Cc: chao@kernel.org, linux-f2fs-devel@lists.sourceforge.net,
linux-kernel@vger.kernel.org, qiwenjie@xiaomi.com,
stable@kernel.org
Subject: Re: [PATCH] f2fs: avoid NULL checkpoint thread access in sysfs
Date: Mon, 3 Aug 2026 15:53:45 +0800 [thread overview]
Message-ID: <c235897c-bec7-45f2-aed9-1efa7e0646ed@kernel.org> (raw)
In-Reply-To: <20260724090532.351989-1-qiwenjie@xiaomi.com>
On 7/24/26 17:05, Wenjie Qi wrote:
> checkpoint_merge is set by default, but the checkpoint merge thread is not
> created for read-only mounts. The ckpt_thread_ioprio sysfs store path uses
> the mount option to decide whether to update the task ioprio. On such
> mounts, writing the node passes a NULL task to set_task_ioprio().
>
> Keep storing the requested ioprio, but apply it only when the checkpoint
> thread exists. Take s_umount for ckpt_thread_ioprio and
> critical_task_priority too, matching the existing protection for GC thread
> entries.
>
> Fixes: e65920661708 ("f2fs: add ckpt_thread_ioprio sysfs node")
> Cc: stable@kernel.org
> Signed-off-by: Wenjie Qi <qiwenjie@xiaomi.com>
> ---
> Reproducer:
> mount -o ro -t f2fs /dev/vdb /mnt/f2fs
> echo be,4 > /sys/fs/f2fs/vdb/ckpt_thread_ioprio
>
> Baseline dmesg:
> Oops: general protection fault
> KASAN: null-ptr-deref in range [0x00000000000007b0-0x00000000000007b7]
> RIP: set_task_ioprio+0x8b/0x360
> Call Trace:
> f2fs_sbi_store+0x2af/0x2580
> kernfs_fop_write_iter+0x360/0x620
> vfs_write+0x5f8/0xf50
> ksys_write+0xf9/0x1d0
> do_syscall_64+0x5f/0x550
>
> fs/f2fs/sysfs.c | 9 ++++++---
> 1 file changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/fs/f2fs/sysfs.c b/fs/f2fs/sysfs.c
> index be92c05a5420..0294544d3d34 100644
> --- a/fs/f2fs/sysfs.c
> +++ b/fs/f2fs/sysfs.c
> @@ -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,16 @@ 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 = gc_entry ||
> + !strcmp(a->attr.name, "ckpt_thread_ioprio") ||
> + !strcmp(a->attr.name, "critical_task_priority");
Oh, seems you fixed another race issue in this patch as well?
"mount -o remount,ro" vs "echo xx > critical_task_priority"
Can you fix this in a separated patch?
>
> - if (gc_entry) {
> + if (thread_entry) {
bool thread_entry = !strcmp(a->attr.name, "ckpt_thread_ioprio") ||
!strcmp(a->attr.name, "critical_task_priority");
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 (thread_entry)
if (gc_entry || thread_entry)
Thanks,
> up_read(&sbi->sb->s_umount);
>
> return ret;
next prev parent reply other threads:[~2026-08-03 7:53 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-24 9:05 [PATCH] f2fs: avoid NULL checkpoint thread access in sysfs Wenjie Qi
2026-07-24 9:05 ` [f2fs-dev] " Wenjie Qi
2026-08-03 7:53 ` Chao Yu via Linux-f2fs-devel [this message]
2026-08-03 7:53 ` Chao Yu
2026-08-03 9:09 ` [f2fs-dev] " Wenjie Qi
2026-08-03 9:09 ` Wenjie Qi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=c235897c-bec7-45f2-aed9-1efa7e0646ed@kernel.org \
--to=linux-f2fs-devel@lists.sourceforge.net \
--cc=chao@kernel.org \
--cc=jaegeuk@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=qiwenjie@xiaomi.com \
--cc=qwjhust@gmail.com \
--cc=stable@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.