Skip to contentSkip to conversation

f2fs: vm_unmap_ram() may be called from an invalid context

PATCH Superseded Jan Prusakowski 2 participants 2 messages Jul 24, 2025 F2FS file system

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 f2fs: vm_unmap_ram() may be called from an invalid context

When testing F2FS with xfstests using UFS backed virtual disks the kernel complains sometimes that f2fs_release_decomp_mem() calls vm_unmap_ram() from an invalid context.

This patch modifies in_task() check inside f2fs_read_end_io() to also check if interrupts are disabled. This ensures that pages are unmapped asynchronously in an interrupt handler.

Fixes bff139b (f2fs: handle decompress only post processing in softirq)
---
 fs/f2fs/data.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/f2fs/data.c +1 -1
index d1a2616d41be..0acc25f996b3 100644
@@ -280,7 +280,7 @@ static void f2fs_read_end_io(struct bio *bio)
 {
 	struct f2fs_sb_info *sbi = F2FS_F_SB(bio_first_folio_all(bio));
 	struct bio_post_read_ctx *ctx;
-	bool intask = in_task();
+	bool intask = in_task() && !irqs_disabled();
 
 	iostat_update_and_unbind_ctx(bio);
 	ctx = bio->bi_private;
Signature · 1 line
2.50.0.727.gbf7dc18ff4-goog
maintainer Reviewed-by on v1 1/1
#1 lore raw

Jan,

Quoted 3 lines · On 2025/7/24 18:30, Jan Prusakowski via Linux-f2fs-devel wrote:

When testing F2FS with xfstests using UFS backed virtual disks the kernel complains sometimes that f2fs_release_decomp_mem() calls vm_unmap_ram() from an invalid context.

It will be better to include testcase & crash information in commit message.

Quoted 6 lines

This patch modifies in_task() check inside f2fs_read_end_io() to also check if interrupts are disabled. This ensures that pages are unmapped asynchronously in an interrupt handler.

Fixes bff139b (f2fs: handle decompress only post processing in softirq)

./scripts/checkpatch.pl will output below warning message:

WARNING: Please use correct Fixes: style 'Fixes: <12+ chars of sha1> ("<title line>")' - ie: 'Fixes: bff139b49d9f ("f2fs: handle decompress only post processing in softirq")'

Please use this instead:

Fixes bff139b49d9f ("f2fs: handle decompress only post processing in softirq")
Quoted 2 lines

Code part looks good to me, please feel free to add my RVB tag in next version:

Thanks,

Quoted 17 lines
---
  fs/f2fs/data.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
fs/f2fs/data.c +1 -1
index d1a2616d41be..0acc25f996b3 100644
@@ -280,7 +280,7 @@ static void f2fs_read_end_io(struct bio *bio)
  {
  	struct f2fs_sb_info *sbi = F2FS_F_SB(bio_first_folio_all(bio));
  	struct bio_post_read_ctx *ctx;
-	bool intask = in_task();
+	bool intask = in_task() && !irqs_disabled();
 
  	iostat_update_and_unbind_ctx(bio);
  	ctx = bio->bi_private;