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, 9 Jan 2023 12:01:16 +0100
From:   Jan Kara <jack@...e.cz>
To:     Baokun Li <libaokun1@...wei.com>
Cc:     linux-ext4@...r.kernel.org, tytso@....edu,
        adilger.kernel@...ger.ca, jack@...e.cz, ritesh.list@...il.com,
        linux-kernel@...r.kernel.org, yi.zhang@...wei.com,
        yukuai3@...wei.com,
        Luís Henriques <lhenriques@...e.de>
Subject: Re: [PATCH v2 1/2] ext4: fail ext4_iget if special inode unallocated

On Sat 07-01-23 11:21:25, Baokun Li wrote:
> In ext4_fill_super(), EXT4_ORPHAN_FS flag is cleared after
> ext4_orphan_cleanup() is executed. Therefore, when __ext4_iget() is
> called to get an inode whose i_nlink is 0 when the flag exists, no error
> is returned. If the inode is a special inode, a null pointer dereference
> may occur. If the value of i_nlink is 0 for any inodes (except boot loader
> inodes) got by using the EXT4_IGET_SPECIAL flag, the current file system
> is corrupted. Therefore, make the ext4_iget() function return an error if
> it gets such an abnormal special inode.
> 
> Link: https://bugzilla.kernel.org/show_bug.cgi?id=199179
> Link: https://bugzilla.kernel.org/show_bug.cgi?id=216541
> Link: https://bugzilla.kernel.org/show_bug.cgi?id=216539
> Reported-by: Luís Henriques <lhenriques@...e.de>
> Suggested-by: Theodore Ts'o <tytso@....edu>
> Signed-off-by: Baokun Li <libaokun1@...wei.com>

Looks good. Feel free to add:

Reviewed-by: Jan Kara <jack@...e.cz>

								Honza

> ---
> V1->V2:
> 	-EFSCORRUPTED is returned instead of -ESTALE for special inode
> 	errors, and the extra parentheses are removed.
> 
>  fs/ext4/inode.c | 18 ++++++++----------
>  1 file changed, 8 insertions(+), 10 deletions(-)
> 
> diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
> index 9d9f414f99fe..ed7598127e7c 100644
> --- a/fs/ext4/inode.c
> +++ b/fs/ext4/inode.c
> @@ -4872,13 +4872,6 @@ struct inode *__ext4_iget(struct super_block *sb, unsigned long ino,
>  		goto bad_inode;
>  	raw_inode = ext4_raw_inode(&iloc);
>  
> -	if ((ino == EXT4_ROOT_INO) && (raw_inode->i_links_count == 0)) {
> -		ext4_error_inode(inode, function, line, 0,
> -				 "iget: root inode unallocated");
> -		ret = -EFSCORRUPTED;
> -		goto bad_inode;
> -	}
> -
>  	if ((flags & EXT4_IGET_HANDLE) &&
>  	    (raw_inode->i_links_count == 0) && (raw_inode->i_mode == 0)) {
>  		ret = -ESTALE;
> @@ -4951,11 +4944,16 @@ struct inode *__ext4_iget(struct super_block *sb, unsigned long ino,
>  	 * NeilBrown 1999oct15
>  	 */
>  	if (inode->i_nlink == 0) {
> -		if ((inode->i_mode == 0 ||
> +		if ((inode->i_mode == 0 || flags & EXT4_IGET_SPECIAL ||
>  		     !(EXT4_SB(inode->i_sb)->s_mount_state & EXT4_ORPHAN_FS)) &&
>  		    ino != EXT4_BOOT_LOADER_INO) {
> -			/* this inode is deleted */
> -			ret = -ESTALE;
> +			/* this inode is deleted or unallocated */
> +			if (flags & EXT4_IGET_SPECIAL) {
> +				ext4_error_inode(inode, function, line, 0,
> +						 "iget: special inode unallocated");
> +				ret = -EFSCORRUPTED;
> +			} else
> +				ret = -ESTALE;
>  			goto bad_inode;
>  		}
>  		/* The only unlinked inodes we let through here have
> -- 
> 2.31.1
> 
-- 
Jan Kara <jack@...e.com>
SUSE Labs, CR

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ