linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: [PATCH] ext4: implement filesystem specific alloc_inode in unit test
  2024-03-22 16:55 [PATCH] ext4: implement filesystem specific alloc_inode in unit test Kemeng Shi
@ 2024-03-22 15:37 ` Guenter Roeck
  2024-04-27 19:09 ` Guenter Roeck
  2024-05-03  4:07 ` Theodore Ts'o
  2 siblings, 0 replies; 4+ messages in thread
From: Guenter Roeck @ 2024-03-22 15:37 UTC (permalink / raw)
  To: Kemeng Shi; +Cc: tytso, adilger.kernel, linux-ext4, linux-kernel

On Sat, Mar 23, 2024 at 12:55:18AM +0800, Kemeng Shi wrote:
> We expect inode with ext4_info_info type as following:
> mbt_kunit_init
>   mbt_mb_init
>     ext4_mb_init
>       ext4_mb_init_backend
>         sbi->s_buddy_cache = new_inode(sb);
>         EXT4_I(sbi->s_buddy_cache)->i_disksize = 0;
> 
> Implement alloc_inode ionde with ext4_inode_info type to avoid
> out-of-bounds write.
> 
> Signed-off-by: Kemeng Shi <shikemeng@huaweicloud.com>
> Reported-by: Guenter Roeck <linux@roeck-us.net>

Tested-by: Guenter Roeck <linux@roeck-us.net>

Guenter

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

* [PATCH] ext4: implement filesystem specific alloc_inode in unit test
@ 2024-03-22 16:55 Kemeng Shi
  2024-03-22 15:37 ` Guenter Roeck
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Kemeng Shi @ 2024-03-22 16:55 UTC (permalink / raw)
  To: tytso, adilger.kernel, linux; +Cc: linux-ext4, linux-kernel

We expect inode with ext4_info_info type as following:
mbt_kunit_init
  mbt_mb_init
    ext4_mb_init
      ext4_mb_init_backend
        sbi->s_buddy_cache = new_inode(sb);
        EXT4_I(sbi->s_buddy_cache)->i_disksize = 0;

Implement alloc_inode ionde with ext4_inode_info type to avoid
out-of-bounds write.

Signed-off-by: Kemeng Shi <shikemeng@huaweicloud.com>
Reported-by: Guenter Roeck <linux@roeck-us.net>
---
 fs/ext4/mballoc-test.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/fs/ext4/mballoc-test.c b/fs/ext4/mballoc-test.c
index 044ca5238f41..49aabcfe6b46 100644
--- a/fs/ext4/mballoc-test.c
+++ b/fs/ext4/mballoc-test.c
@@ -30,7 +30,31 @@ struct mbt_ext4_super_block {
 #define MBT_CTX(_sb) (&MBT_SB(_sb)->mbt_ctx)
 #define MBT_GRP_CTX(_sb, _group) (&MBT_CTX(_sb)->grp_ctx[_group])
 
+static struct inode *mbt_alloc_inode(struct super_block *sb)
+{
+	struct ext4_inode_info *ei;
+
+	ei = kmalloc(sizeof(struct ext4_inode_info), GFP_KERNEL);
+	if (!ei)
+		return NULL;
+
+	INIT_LIST_HEAD(&ei->i_orphan);
+	init_rwsem(&ei->xattr_sem);
+	init_rwsem(&ei->i_data_sem);
+	inode_init_once(&ei->vfs_inode);
+	ext4_fc_init_inode(&ei->vfs_inode);
+
+	return &ei->vfs_inode;
+}
+
+static void mbt_free_inode(struct inode *inode)
+{
+	kfree(EXT4_I(inode));
+}
+
 static const struct super_operations mbt_sops = {
+	.alloc_inode	= mbt_alloc_inode,
+	.free_inode	= mbt_free_inode,
 };
 
 static void mbt_kill_sb(struct super_block *sb)
-- 
2.30.0


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

* Re: [PATCH] ext4: implement filesystem specific alloc_inode in unit test
  2024-03-22 16:55 [PATCH] ext4: implement filesystem specific alloc_inode in unit test Kemeng Shi
  2024-03-22 15:37 ` Guenter Roeck
@ 2024-04-27 19:09 ` Guenter Roeck
  2024-05-03  4:07 ` Theodore Ts'o
  2 siblings, 0 replies; 4+ messages in thread
From: Guenter Roeck @ 2024-04-27 19:09 UTC (permalink / raw)
  To: Kemeng Shi; +Cc: tytso, adilger.kernel, linux-ext4, linux-kernel

Hi,

On Sat, Mar 23, 2024 at 12:55:18AM +0800, Kemeng Shi wrote:
> We expect inode with ext4_info_info type as following:
> mbt_kunit_init
>   mbt_mb_init
>     ext4_mb_init
>       ext4_mb_init_backend
>         sbi->s_buddy_cache = new_inode(sb);
>         EXT4_I(sbi->s_buddy_cache)->i_disksize = 0;
> 
> Implement alloc_inode ionde with ext4_inode_info type to avoid
> out-of-bounds write.
> 
> Signed-off-by: Kemeng Shi <shikemeng@huaweicloud.com>
> Reported-by: Guenter Roeck <linux@roeck-us.net>
> ---

Ths problem fixed by this patch still affects the mainline kernel,
and is often fatal there if CONFIG_EXT4_KUNIT_TESTS is enabled
due to memory corruptions. Is there a chance to get it applied soon,
or should I just disable CONFIG_EXT4_KUNIT_TESTS for good ?

Thanks,
Guenter

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

* Re: [PATCH] ext4: implement filesystem specific alloc_inode in unit test
  2024-03-22 16:55 [PATCH] ext4: implement filesystem specific alloc_inode in unit test Kemeng Shi
  2024-03-22 15:37 ` Guenter Roeck
  2024-04-27 19:09 ` Guenter Roeck
@ 2024-05-03  4:07 ` Theodore Ts'o
  2 siblings, 0 replies; 4+ messages in thread
From: Theodore Ts'o @ 2024-05-03  4:07 UTC (permalink / raw)
  To: adilger.kernel, linux, Kemeng Shi
  Cc: Theodore Ts'o, linux-ext4, linux-kernel


On Sat, 23 Mar 2024 00:55:18 +0800, Kemeng Shi wrote:
> We expect inode with ext4_info_info type as following:
> mbt_kunit_init
>   mbt_mb_init
>     ext4_mb_init
>       ext4_mb_init_backend
>         sbi->s_buddy_cache = new_inode(sb);
>         EXT4_I(sbi->s_buddy_cache)->i_disksize = 0;
> 
> [...]

Applied, thanks!

[1/1] ext4: implement filesystem specific alloc_inode in unit test
      commit: a11adf7be9d8baefe798eab49c356ab8e3924f0e

Best regards,
-- 
Theodore Ts'o <tytso@mit.edu>

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

end of thread, other threads:[~2024-05-03  4:08 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-22 16:55 [PATCH] ext4: implement filesystem specific alloc_inode in unit test Kemeng Shi
2024-03-22 15:37 ` Guenter Roeck
2024-04-27 19:09 ` Guenter Roeck
2024-05-03  4:07 ` Theodore Ts'o

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).