* [f2fs-dev] [PATCH] f2fs: fix an oops in f2fs_is_compressed_page
@ 2020-06-20 7:58 Yu Changchun
2020-06-20 7:59 ` Chao Yu
0 siblings, 1 reply; 2+ messages in thread
From: Yu Changchun @ 2020-06-20 7:58 UTC (permalink / raw)
To: yuchao0, jaegeuk; +Cc: linux-f2fs-devel
This patch is to fix a crash:
#3 [ffffb6580689f898] oops_end at ffffffffa2835bc2
#4 [ffffb6580689f8b8] no_context at ffffffffa28766e7
#5 [ffffb6580689f920] async_page_fault at ffffffffa320135e
[exception RIP: f2fs_is_compressed_page+34]
RIP: ffffffffa2ba83a2 RSP: ffffb6580689f9d8 RFLAGS: 00010213
RAX: 0000000000000001 RBX: fffffc0f50b34bc0 RCX: 0000000000002122
RDX: 0000000000002123 RSI: 0000000000000c00 RDI: fffffc0f50b34bc0
RBP: ffff97e815a40178 R8: 0000000000000000 R9: ffff97e83ffc9000
R10: 0000000000032300 R11: 0000000000032380 R12: ffffb6580689fa38
R13: fffffc0f50b34bc0 R14: ffff97e825cbd000 R15: 0000000000000c00
ORIG_RAX: ffffffffffffffff CS: 0010 SS: 0018
#6 [ffffb6580689f9d8] __is_cp_guaranteed at ffffffffa2b7ea98
#7 [ffffb6580689f9f0] f2fs_submit_page_write at ffffffffa2b81a69
#8 [ffffb6580689fa30] f2fs_do_write_meta_page at ffffffffa2b99777
#9 [ffffb6580689fae0] __f2fs_write_meta_page at ffffffffa2b75f1a
#10 [ffffb6580689fb18] f2fs_sync_meta_pages at ffffffffa2b77466
#11 [ffffb6580689fc98] do_checkpoint at ffffffffa2b78e46
#12 [ffffb6580689fd88] f2fs_write_checkpoint at ffffffffa2b79c29
#13 [ffffb6580689fdd0] f2fs_sync_fs at ffffffffa2b69d95
#14 [ffffb6580689fe20] sync_filesystem at ffffffffa2ad2574
#15 [ffffb6580689fe30] generic_shutdown_super at ffffffffa2a9b582
#16 [ffffb6580689fe48] kill_block_super at ffffffffa2a9b6d1
#17 [ffffb6580689fe60] kill_f2fs_super at ffffffffa2b6abe1
#18 [ffffb6580689fea0] deactivate_locked_super at ffffffffa2a9afb6
#19 [ffffb6580689feb8] cleanup_mnt at ffffffffa2abcad4
#20 [ffffb6580689fee0] task_work_run at ffffffffa28bca28
#21 [ffffb6580689ff00] exit_to_usermode_loop at ffffffffa28050b7
#22 [ffffb6580689ff38] do_syscall_64 at ffffffffa280560e
#23 [ffffb6580689ff50] entry_SYSCALL_64_after_hwframe at ffffffffa320008c
This occurred when umount f2fs if enable F2FS_FS_COMPRESSION
with F2FS_IO_TRACE. Fixes it by adding IS_IO_TRACED_PAGE to check
validity of pid for page_private.
Signed-off-by: Yu Changchun <yuchangchun1@huawei.com>
---
fs/f2fs/compress.c | 7 +++++++
fs/f2fs/f2fs.h | 8 ++++++++
2 files changed, 15 insertions(+)
diff --git a/fs/f2fs/compress.c b/fs/f2fs/compress.c
index 1e02a8c106b0..12e9b6cd8c94 100644
--- a/fs/f2fs/compress.c
+++ b/fs/f2fs/compress.c
@@ -49,6 +49,13 @@ bool f2fs_is_compressed_page(struct page *page)
return false;
if (IS_ATOMIC_WRITTEN_PAGE(page) || IS_DUMMY_WRITTEN_PAGE(page))
return false;
+ /*
+ * page->private may be set with pid.
+ * pid_max is enough to check if it is traced.
+ */
+ if (IS_IO_TRACED_PAGE(page))
+ return false;
+
f2fs_bug_on(F2FS_M_SB(page->mapping),
*((u32 *)page_private(page)) != F2FS_COMPRESSED_PAGE_MAGIC);
return true;
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index b35a50f4953c..634b6650d618 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -1313,6 +1313,14 @@ enum fsync_mode {
#define IS_DUMMY_WRITTEN_PAGE(page) \
(page_private(page) == (unsigned long)DUMMY_WRITTEN_PAGE)
+#ifdef CONFIG_F2FS_IO_TRACE
+#define IS_IO_TRACED_PAGE(page) \
+ (page_private(page) > 0 && \
+ page_private(page) < (unsigned long)PID_MAX_LIMIT)
+#else
+#define IS_IO_TRACED_PAGE(page) (0)
+#endif
+
#ifdef CONFIG_FS_ENCRYPTION
#define DUMMY_ENCRYPTION_ENABLED(sbi) \
(unlikely(F2FS_OPTION(sbi).dummy_enc_ctx.ctx != NULL))
--
2.27.0.22.g2051400
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [f2fs-dev] [PATCH] f2fs: fix an oops in f2fs_is_compressed_page
2020-06-20 7:58 [f2fs-dev] [PATCH] f2fs: fix an oops in f2fs_is_compressed_page Yu Changchun
@ 2020-06-20 7:59 ` Chao Yu
0 siblings, 0 replies; 2+ messages in thread
From: Chao Yu @ 2020-06-20 7:59 UTC (permalink / raw)
To: Yu Changchun, jaegeuk; +Cc: linux-f2fs-devel
On 2020/6/20 15:58, Yu Changchun wrote:
> This patch is to fix a crash:
>
> #3 [ffffb6580689f898] oops_end at ffffffffa2835bc2
> #4 [ffffb6580689f8b8] no_context at ffffffffa28766e7
> #5 [ffffb6580689f920] async_page_fault at ffffffffa320135e
> [exception RIP: f2fs_is_compressed_page+34]
> RIP: ffffffffa2ba83a2 RSP: ffffb6580689f9d8 RFLAGS: 00010213
> RAX: 0000000000000001 RBX: fffffc0f50b34bc0 RCX: 0000000000002122
> RDX: 0000000000002123 RSI: 0000000000000c00 RDI: fffffc0f50b34bc0
> RBP: ffff97e815a40178 R8: 0000000000000000 R9: ffff97e83ffc9000
> R10: 0000000000032300 R11: 0000000000032380 R12: ffffb6580689fa38
> R13: fffffc0f50b34bc0 R14: ffff97e825cbd000 R15: 0000000000000c00
> ORIG_RAX: ffffffffffffffff CS: 0010 SS: 0018
> #6 [ffffb6580689f9d8] __is_cp_guaranteed at ffffffffa2b7ea98
> #7 [ffffb6580689f9f0] f2fs_submit_page_write at ffffffffa2b81a69
> #8 [ffffb6580689fa30] f2fs_do_write_meta_page at ffffffffa2b99777
> #9 [ffffb6580689fae0] __f2fs_write_meta_page at ffffffffa2b75f1a
> #10 [ffffb6580689fb18] f2fs_sync_meta_pages at ffffffffa2b77466
> #11 [ffffb6580689fc98] do_checkpoint at ffffffffa2b78e46
> #12 [ffffb6580689fd88] f2fs_write_checkpoint at ffffffffa2b79c29
> #13 [ffffb6580689fdd0] f2fs_sync_fs at ffffffffa2b69d95
> #14 [ffffb6580689fe20] sync_filesystem at ffffffffa2ad2574
> #15 [ffffb6580689fe30] generic_shutdown_super at ffffffffa2a9b582
> #16 [ffffb6580689fe48] kill_block_super at ffffffffa2a9b6d1
> #17 [ffffb6580689fe60] kill_f2fs_super at ffffffffa2b6abe1
> #18 [ffffb6580689fea0] deactivate_locked_super at ffffffffa2a9afb6
> #19 [ffffb6580689feb8] cleanup_mnt at ffffffffa2abcad4
> #20 [ffffb6580689fee0] task_work_run at ffffffffa28bca28
> #21 [ffffb6580689ff00] exit_to_usermode_loop at ffffffffa28050b7
> #22 [ffffb6580689ff38] do_syscall_64 at ffffffffa280560e
> #23 [ffffb6580689ff50] entry_SYSCALL_64_after_hwframe at ffffffffa320008c
>
> This occurred when umount f2fs if enable F2FS_FS_COMPRESSION
> with F2FS_IO_TRACE. Fixes it by adding IS_IO_TRACED_PAGE to check
> validity of pid for page_private.
>
> Signed-off-by: Yu Changchun <yuchangchun1@huawei.com>
Reviewed-by: Chao Yu <yuchao0@huawei.com>
Thanks,
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-06-20 7:59 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-20 7:58 [f2fs-dev] [PATCH] f2fs: fix an oops in f2fs_is_compressed_page Yu Changchun
2020-06-20 7:59 ` Chao Yu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).