From: Edward Adam Davis <eadavis@qq.com>
To: syzbot+0c99c3f90699936c1e77@syzkaller.appspotmail.com
Cc: linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com
Subject: Re: [syzbot] [ext4?] KASAN: use-after-free Write in ext4_insert_dentry
Date: Sun, 27 Oct 2024 16:54:44 +0800 [thread overview]
Message-ID: <tencent_4E83A7C006C212DC065509AAEEC86EC48C06@qq.com> (raw)
In-Reply-To: <671c2223.050a0220.2fdf0c.021c.GAE@google.com>
directory entry space is too smaller than file name?
#syz test
diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c
index 790db7eac6c2..cd1e1e8e0c04 100644
--- a/fs/ext4/namei.c
+++ b/fs/ext4/namei.c
@@ -2098,15 +2098,19 @@ void ext4_insert_dentry(struct inode *dir,
if (de->inode) {
struct ext4_dir_entry_2 *de1 =
(struct ext4_dir_entry_2 *)((char *)de + nlen);
+ printk("old name: %s, old nl: %d, oonl: %d, %s\n", de->name, nlen, de->name_len, __func__);
de1->rec_len = ext4_rec_len_to_disk(rlen - nlen, buf_size);
de->rec_len = ext4_rec_len_to_disk(nlen, buf_size);
de = de1;
+ rlen = ext4_rec_len_from_disk(de->rec_len, buf_size);
}
de->file_type = EXT4_FT_UNKNOWN;
de->inode = cpu_to_le32(inode->i_ino);
ext4_set_de_type(inode->i_sb, de, inode->i_mode);
- de->name_len = fname_len(fname);
- memcpy(de->name, fname_name(fname), fname_len(fname));
+ de->name_len = min_t(int, fname_len(fname), rlen - 8);
+ printk("rec length: %d, buf_size: %d, old nl: %d, name length:%d, %s\n",
+ rlen, buf_size, nlen, fname_len(fname), __func__);
+ memcpy(de->name, fname_name(fname), de->name_len);
if (ext4_hash_in_dirent(dir)) {
struct dx_hash_info *hinfo = &fname->hinfo;
next prev parent reply other threads:[~2024-10-27 8:59 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-25 22:56 syzbot
2024-10-27 4:53 ` Edward Adam Davis
2024-10-27 5:08 ` syzbot
2024-10-27 8:54 ` Edward Adam Davis [this message]
2024-10-27 9:15 ` syzbot
2024-10-27 9:51 ` Edward Adam Davis
2024-10-27 10:02 ` syzbot
2024-10-27 10:26 ` Edward Adam Davis
2024-10-27 10:40 ` syzbot
2024-10-27 11:09 ` [PATCH] ext4: Add a sanity check for next dentry when insert Edward Adam Davis
2024-10-27 15:45 ` kernel test robot
2024-10-28 14:07 ` [PATCH V2] " Edward Adam Davis
2024-11-04 6:43 ` kernel test robot
2024-10-27 16:06 ` [PATCH] " kernel test robot
2024-10-28 14:14 ` kernel test robot
2024-10-30 11:21 ` [syzbot] [ext4?] KASAN: use-after-free Write in ext4_insert_dentry Edward Adam Davis
2024-10-30 11:35 ` syzbot
2024-11-06 15:22 ` syzbot
2025-04-15 17:29 ` Thadeu Lima de Souza Cascardo
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=tencent_4E83A7C006C212DC065509AAEEC86EC48C06@qq.com \
--to=eadavis@qq.com \
--cc=linux-kernel@vger.kernel.org \
--cc=syzbot+0c99c3f90699936c1e77@syzkaller.appspotmail.com \
--cc=syzkaller-bugs@googlegroups.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
all inboxes | Powered by JetHome®