Linux EXT4 FS development
 help / color / mirror / Atom feed
From: Penglei Jiang <superman.xpt@gmail.com>
To: tytso@mit.edu, adilger.kernel@dilger.ca
Cc: linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.or,
	syzbot+d14b2bea87fe2aaffa3b@syzkaller.appspotmail.com,
	Penglei Jiang <superman.xpt@gmail.com>
Subject: [PATCH] ext4: Fix the issue of missing lock in ext4_page_mkwrite
Date: Sun, 30 Mar 2025 00:55:15 -0700	[thread overview]
Message-ID: <20250330075515.37699-1-superman.xpt@gmail.com> (raw)

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


             reply	other threads:[~2025-03-30  7:56 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-30  7:55 Penglei Jiang [this message]
2025-03-31  1:51 ` [PATCH] ext4: Fix the issue of missing lock in ext4_page_mkwrite Baokun Li

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=20250330075515.37699-1-superman.xpt@gmail.com \
    --to=superman.xpt@gmail.com \
    --cc=adilger.kernel@dilger.ca \
    --cc=linux-ext4@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.or \
    --cc=syzbot+d14b2bea87fe2aaffa3b@syzkaller.appspotmail.com \
    --cc=tytso@mit.edu \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox