From: Baokun Li <libaokun1@huawei.com>
To: Penglei Jiang <superman.xpt@gmail.com>
Cc: <tytso@mit.edu>, <adilger.kernel@dilger.ca>,
<linux-ext4@vger.kernel.org>, <linux-kernel@vger.kernel.or>,
<syzbot+d14b2bea87fe2aaffa3b@syzkaller.appspotmail.com>,
Yang Erkun <yangerkun@huawei.com>
Subject: Re: [PATCH] ext4: Fix the issue of missing lock in ext4_page_mkwrite
Date: Mon, 31 Mar 2025 09:51:54 +0800 [thread overview]
Message-ID: <f7dbbe6c-3341-4709-868c-9e8fabdb9af6@huawei.com> (raw)
In-Reply-To: <20250330075515.37699-1-superman.xpt@gmail.com>
Hi Penglei,
On 2025/3/30 15:55, Penglei Jiang wrote:
> 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);
We cannot directly add inode_lock here, otherwise it may cause ABBA
deadlock. The inline data conversion here does lack inode_lock, but
there is no good way to fix it now. For details, please see:
https://lore.kernel.org/all/d704ce55-321a-9c1d-1f8b-3360a0fdf978@huawei.com/
> @@ -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:
prev parent reply other threads:[~2025-03-31 1:52 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
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 message]
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=f7dbbe6c-3341-4709-868c-9e8fabdb9af6@huawei.com \
--to=libaokun1@huawei.com \
--cc=adilger.kernel@dilger.ca \
--cc=linux-ext4@vger.kernel.org \
--cc=linux-kernel@vger.kernel.or \
--cc=superman.xpt@gmail.com \
--cc=syzbot+d14b2bea87fe2aaffa3b@syzkaller.appspotmail.com \
--cc=tytso@mit.edu \
--cc=yangerkun@huawei.com \
/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