* [PATCH] fs: fix GPF in nilfs_mdt_destroy
@ 2021-10-11 3:09 Dongliang Mu
2022-01-20 9:28 ` Dongliang Mu
0 siblings, 1 reply; 2+ messages in thread
From: Dongliang Mu @ 2021-10-11 3:09 UTC (permalink / raw)
To: Alexander Viro; +Cc: Dongliang Mu, linux-fsdevel, linux-kernel
In alloc_inode, inode_init_always could return -NOMEM if
security_inode_alloc fails. In its error handling, i_callback and
nilfs_free_inode will be called. However, because inode->i_private is
not initialized due to the failure of security_inode_alloc, the function
nilfs_is_metadata_file_inode can return true and nilfs_mdt_destroy will
be executed to lead to GPF bug.
Fix this bug by moving the assignment of inode->i_private before
security_inode_alloc.
BTW, this bug is triggered by fault injection in the syzkaller.
Signed-off-by: Dongliang Mu <mudongliangabcd@gmail.com>
---
fs/inode.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/inode.c b/fs/inode.c
index ed0cab8a32db..f6fce84bf550 100644
--- a/fs/inode.c
+++ b/fs/inode.c
@@ -160,6 +160,7 @@ int inode_init_always(struct super_block *sb, struct inode *inode)
inode->i_dir_seq = 0;
inode->i_rdev = 0;
inode->dirtied_when = 0;
+ inode->i_private = NULL;
#ifdef CONFIG_CGROUP_WRITEBACK
inode->i_wb_frn_winner = 0;
@@ -194,7 +195,6 @@ int inode_init_always(struct super_block *sb, struct inode *inode)
lockdep_set_class_and_name(&mapping->invalidate_lock,
&sb->s_type->invalidate_lock_key,
"mapping.invalidate_lock");
- inode->i_private = NULL;
inode->i_mapping = mapping;
INIT_HLIST_HEAD(&inode->i_dentry); /* buggered by rcu freeing */
#ifdef CONFIG_FS_POSIX_ACL
--
2.25.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] fs: fix GPF in nilfs_mdt_destroy
2021-10-11 3:09 [PATCH] fs: fix GPF in nilfs_mdt_destroy Dongliang Mu
@ 2022-01-20 9:28 ` Dongliang Mu
0 siblings, 0 replies; 2+ messages in thread
From: Dongliang Mu @ 2022-01-20 9:28 UTC (permalink / raw)
To: Alexander Viro; +Cc: linux-fsdevel, linux-kernel
On Mon, Oct 11, 2021 at 11:10 AM Dongliang Mu <mudongliangabcd@gmail.com> wrote:
>
> In alloc_inode, inode_init_always could return -NOMEM if
> security_inode_alloc fails. In its error handling, i_callback and
> nilfs_free_inode will be called. However, because inode->i_private is
> not initialized due to the failure of security_inode_alloc, the function
> nilfs_is_metadata_file_inode can return true and nilfs_mdt_destroy will
> be executed to lead to GPF bug.
>
> Fix this bug by moving the assignment of inode->i_private before
> security_inode_alloc.
>
ping?
> BTW, this bug is triggered by fault injection in the syzkaller.
>
> Signed-off-by: Dongliang Mu <mudongliangabcd@gmail.com>
> ---
> fs/inode.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/inode.c b/fs/inode.c
> index ed0cab8a32db..f6fce84bf550 100644
> --- a/fs/inode.c
> +++ b/fs/inode.c
> @@ -160,6 +160,7 @@ int inode_init_always(struct super_block *sb, struct inode *inode)
> inode->i_dir_seq = 0;
> inode->i_rdev = 0;
> inode->dirtied_when = 0;
> + inode->i_private = NULL;
>
> #ifdef CONFIG_CGROUP_WRITEBACK
> inode->i_wb_frn_winner = 0;
> @@ -194,7 +195,6 @@ int inode_init_always(struct super_block *sb, struct inode *inode)
> lockdep_set_class_and_name(&mapping->invalidate_lock,
> &sb->s_type->invalidate_lock_key,
> "mapping.invalidate_lock");
> - inode->i_private = NULL;
> inode->i_mapping = mapping;
> INIT_HLIST_HEAD(&inode->i_dentry); /* buggered by rcu freeing */
> #ifdef CONFIG_FS_POSIX_ACL
> --
> 2.25.1
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-01-20 9:28 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-11 3:09 [PATCH] fs: fix GPF in nilfs_mdt_destroy Dongliang Mu
2022-01-20 9:28 ` Dongliang Mu
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.