Linux NILFS development
 help / color / mirror / Atom feed
* [PATCH] nilfs2: fix use-after-free bug in nilfs_mdt_destroy()
@ 2022-08-15 17:51 Ryusuke Konishi
       [not found] ` <20220815175114.23576-1-konishi.ryusuke-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
  0 siblings, 1 reply; 7+ messages in thread
From: Ryusuke Konishi @ 2022-08-15 17:51 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Al Viro, linux-nilfs, LKML, Jiacheng Xu, Mudong Liang

In alloc_inode(), inode_init_always() could return -ENOMEM if
security_inode_alloc() fails.  If this happens for nilfs2,
nilfs_free_inode() is called without initializing inode->i_private and
nilfs_free_inode() wrongly calls nilfs_mdt_destroy(), which frees
uninitialized inode->i_private and can trigger a crash.

Fix this bug by initializing inode->i_private in nilfs_alloc_inode().

Link: https://lkml.kernel.org/r/CAFcO6XOcf1Jj2SeGt=jJV59wmhESeSKpfR0omdFRq+J9nD1vfQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
Link: https://lkml.kernel.org/r/20211011030956.2459172-1-mudongliangabcd-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
Reported-by: butt3rflyh4ck <butterflyhuangxx-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Reported-by: Hao Sun <sunhao.th-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Reported-by: Jiacheng Xu <stitch-Y5EWUtBUdg4nDS1+zs4M5A@public.gmane.org>
Reported-by: Mudong Liang <mudongliangabcd-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Signed-off-by: Ryusuke Konishi <konishi.ryusuke-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: Al Viro <viro-RmSDqhL/yNMiFSDQTTA3OLVCufUGDwFn@public.gmane.org>
---
 fs/nilfs2/super.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/fs/nilfs2/super.c b/fs/nilfs2/super.c
index ba108f915391..aca5614f1b44 100644
--- a/fs/nilfs2/super.c
+++ b/fs/nilfs2/super.c
@@ -159,6 +159,7 @@ struct inode *nilfs_alloc_inode(struct super_block *sb)
 	ii->i_cno = 0;
 	ii->i_assoc_inode = NULL;
 	ii->i_bmap = &ii->i_bmap_data;
+	ii->vfs_inode.i_private = NULL;
 	return &ii->vfs_inode;
 }
 
-- 
2.34.1


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

end of thread, other threads:[~2022-08-16  9:18 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-08-15 17:51 [PATCH] nilfs2: fix use-after-free bug in nilfs_mdt_destroy() Ryusuke Konishi
     [not found] ` <20220815175114.23576-1-konishi.ryusuke-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2022-08-15 18:27   ` Al Viro
2022-08-15 20:34     ` Ryusuke Konishi
     [not found]       ` <CAKFNMomyjXpsz-=BtG+G3q1J7CFUBMEfP13FfxwhWB==9qb++w-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2022-08-15 23:04         ` Al Viro
2022-08-16  3:11           ` Ryusuke Konishi
     [not found]             ` <CAKFNMoniwM5x0w03cezGTFDWt=apNmGWpur83+vjghg3zcawpQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2022-08-16  3:24               ` Dongliang Mu
     [not found]                 ` <CAD-N9QW5-kVR85t1canTqrF9RMkOjC1Z2q8BSQKxLwaay97Mgg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2022-08-16  9:18                   ` Ryusuke Konishi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox