Linux EXT4 FS development
 help / color / mirror / Atom feed
* [PATCH] ext4: Fix the issue of missing lock in ext4_page_mkwrite
@ 2025-03-30  7:55 Penglei Jiang
  2025-03-31  1:51 ` Baokun Li
  0 siblings, 1 reply; 2+ messages in thread
From: Penglei Jiang @ 2025-03-30  7:55 UTC (permalink / raw)
  To: tytso, adilger.kernel
  Cc: linux-ext4, linux-kernel, syzbot+d14b2bea87fe2aaffa3b,
	Penglei Jiang

In ext4_page_mkwrite, it calls ext4_convert_inline_data, but it does
not use inode_lock to hold i_rwsem.

Fixes: 7b4cc9787fe35 ("ext4: evict inline data when writing to memory map")
Reported-by: syzbot+d14b2bea87fe2aaffa3b@syzkaller.appspotmail.com
Closes: https://lore.kernel.org/all/67e57c6c.050a0220.2f068f.0037.GAE@google.com
Signed-off-by: Penglei Jiang <superman.xpt@gmail.com>
---
 fs/ext4/inode.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index bcb96caf77c0..4e726c86377a 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -6203,6 +6203,8 @@ vm_fault_t ext4_page_mkwrite(struct vm_fault *vmf)
 	sb_start_pagefault(inode->i_sb);
 	file_update_time(vma->vm_file);
 
+	inode_lock(inode);
+
 	filemap_invalidate_lock_shared(mapping);
 
 	err = ext4_convert_inline_data(inode);
@@ -6308,6 +6310,7 @@ vm_fault_t ext4_page_mkwrite(struct vm_fault *vmf)
 	ret = vmf_fs_error(err);
 out:
 	filemap_invalidate_unlock_shared(mapping);
+	inode_unlock(inode);
 	sb_end_pagefault(inode->i_sb);
 	return ret;
 out_error:
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-03-31  1:52 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-30  7:55 [PATCH] ext4: Fix the issue of missing lock in ext4_page_mkwrite Penglei Jiang
2025-03-31  1:51 ` Baokun Li

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox