lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Mon, 29 Aug 2022 16:15:17 +0200
From:   Christian Brauner <brauner@...nel.org>
To:     Alexey Khoroshilov <khoroshilov@...ras.ru>
Cc:     Alexander Viro <viro@...iv.linux.org.uk>,
        Rustam Subkhankulov <subkhankulov@...ras.ru>,
        linux-fsdevel@...r.kernel.org, linux-kernel@...r.kernel.org,
        ldv-project@...uxtesting.org
Subject: Re: [PATCH] fs/inode.c: change the order of initialization in
 inode_init_always()

On Sat, Aug 27, 2022 at 05:09:26PM +0300, Alexey Khoroshilov wrote:
> From: Rustam Subkhankulov <subkhankulov@...ras.ru>
> 
> If function 'security_inode_alloc()' returns a nonzero value at
> [fs/inode.c: 195] due to an error (e.g. fail to allocate memory),
> then some of the fields, including 'i_private', will not be
> initialized.
> 
> After that, if the fs-specfic free_inode function is called in
> 'i_callback', the nonzero value of 'i_private' field can be interpreted
> as initialized. As a result, this can cause dereferencing of random
> value pointer (e.g. nilfs2).
> 
> In earlier versions, a similar situation could occur with the 'u' union
> in 'inode' structure.
> 
> Found by Linux Verification Center (linuxtesting.org) with syzkaller.
> 
> Signed-off-by: Rustam Subkhankulov <subkhankulov@...ras.ru>
> Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
> ---
>  fs/inode.c | 7 +++----
>  1 file changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/fs/inode.c b/fs/inode.c
> index bd4da9c5207e..08d093737e8c 100644
> --- a/fs/inode.c
> +++ b/fs/inode.c
> @@ -192,8 +192,6 @@ int inode_init_always(struct super_block *sb, struct inode *inode)
>  	inode->i_wb_frn_history = 0;
>  #endif
>  
> -	if (security_inode_alloc(inode))
> -		goto out;
>  	spin_lock_init(&inode->i_lock);
>  	lockdep_set_class(&inode->i_lock, &sb->s_type->i_lock_key);
>  
> @@ -230,9 +228,10 @@ int inode_init_always(struct super_block *sb, struct inode *inode)
>  	inode->i_flctx = NULL;
>  	this_cpu_inc(nr_inodes);
>  
> +	if (security_inode_alloc(inode))
> +		return -ENOMEM;

This should probably be before this_cpu_inc(nr_inodes).

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ