From: Jan Kara <jack@suse.cz>
To: Ye Bin <yebin@huaweicloud.com>
Cc: tytso@mit.edu, adilger.kernel@dilger.ca,
linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org,
jack@suse.cz, Ye Bin <yebin10@huawei.com>,
syzbot+98346927678ac3059c77@syzkaller.appspotmail.com
Subject: Re: [PATCH] ext4: init quota for 'old.inode' in 'ext4_rename'
Date: Mon, 7 Nov 2022 14:36:51 +0100 [thread overview]
Message-ID: <20221107133651.qmitthhev3lq4h5q@quack3> (raw)
In-Reply-To: <20221107015335.2524319-1-yebin@huaweicloud.com>
On Mon 07-11-22 09:53:35, Ye Bin wrote:
> From: Ye Bin <yebin10@huawei.com>
>
> Syzbot found the following issue:
> ext4_parse_param: s_want_extra_isize=128
> ext4_inode_info_init: s_want_extra_isize=32
> ext4_rename: old.inode=ffff88823869a2c8 old.dir=ffff888238699828 new.inode=ffff88823869d7e8 new.dir=ffff888238699828
> __ext4_mark_inode_dirty: inode=ffff888238699828 ea_isize=32 want_ea_size=128
> __ext4_mark_inode_dirty: inode=ffff88823869a2c8 ea_isize=32 want_ea_size=128
> ext4_xattr_block_set: inode=ffff88823869a2c8
> ------------[ cut here ]------------
> WARNING: CPU: 13 PID: 2234 at fs/ext4/xattr.c:2070 ext4_xattr_block_set.cold+0x22/0x980
> Modules linked in:
> RIP: 0010:ext4_xattr_block_set.cold+0x22/0x980
> RSP: 0018:ffff888227d3f3b0 EFLAGS: 00010202
> RAX: 0000000000000001 RBX: ffff88823007a000 RCX: 0000000000000000
> RDX: 0000000000000a03 RSI: 0000000000000040 RDI: ffff888230078178
> RBP: 0000000000000000 R08: 000000000000002c R09: ffffed1075c7df8e
> R10: ffff8883ae3efc6b R11: ffffed1075c7df8d R12: 0000000000000000
> R13: ffff88823869a2c8 R14: ffff8881012e0460 R15: dffffc0000000000
> FS: 00007f350ac1f740(0000) GS:ffff8883ae200000(0000) knlGS:0000000000000000
> CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
> CR2: 00007f350a6ed6a0 CR3: 0000000237456000 CR4: 00000000000006e0
> DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
> DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
> Call Trace:
> <TASK>
> ? ext4_xattr_set_entry+0x3b7/0x2320
> ? ext4_xattr_block_set+0x0/0x2020
> ? ext4_xattr_set_entry+0x0/0x2320
> ? ext4_xattr_check_entries+0x77/0x310
> ? ext4_xattr_ibody_set+0x23b/0x340
> ext4_xattr_move_to_block+0x594/0x720
> ext4_expand_extra_isize_ea+0x59a/0x10f0
> __ext4_expand_extra_isize+0x278/0x3f0
> __ext4_mark_inode_dirty.cold+0x347/0x410
> ext4_rename+0xed3/0x174f
> vfs_rename+0x13a7/0x2510
> do_renameat2+0x55d/0x920
> __x64_sys_rename+0x7d/0xb0
> do_syscall_64+0x3b/0xa0
> entry_SYSCALL_64_after_hwframe+0x72/0xdc
>
> As 'ext4_rename' will modify 'old.inode' ctime and mark inode dirty, which may
> trigger expand 'extra_isize' and allocate block. If inode didn't init quota
> will lead to warning.
> To solve above issue, init 'old.inode' firstly in 'ext4_rename'.
>
> Reported-by: syzbot+98346927678ac3059c77@syzkaller.appspotmail.com
> Signed-off-by: Ye Bin <yebin10@huawei.com>
OK, nice catch. Feel free to add:
Reviewed-by: Jan Kara <jack@suse.cz>
Honza
> ---
> fs/ext4/namei.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c
> index b8a91d74fdd1..6e40dfc8bd30 100644
> --- a/fs/ext4/namei.c
> +++ b/fs/ext4/namei.c
> @@ -3784,6 +3784,9 @@ static int ext4_rename(struct user_namespace *mnt_userns, struct inode *old_dir,
> return -EXDEV;
>
> retval = dquot_initialize(old.dir);
> + if (retval)
> + return retval;
> + retval = dquot_initialize(old.inode);
> if (retval)
> return retval;
> retval = dquot_initialize(new.dir);
> --
> 2.31.1
>
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
prev parent reply other threads:[~2022-11-07 13:37 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-07 1:53 [PATCH] ext4: init quota for 'old.inode' in 'ext4_rename' Ye Bin
2022-11-07 13:36 ` Jan Kara [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=20221107133651.qmitthhev3lq4h5q@quack3 \
--to=jack@suse.cz \
--cc=adilger.kernel@dilger.ca \
--cc=linux-ext4@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=syzbot+98346927678ac3059c77@syzkaller.appspotmail.com \
--cc=tytso@mit.edu \
--cc=yebin10@huawei.com \
--cc=yebin@huaweicloud.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;
as well as URLs for NNTP newsgroup(s).