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]
Message-ID: <20210820164556.GA30851@localhost.localdomain>
Date:   Fri, 20 Aug 2021 12:45:56 -0400
From:   Eric Whitney <enwlinux@...il.com>
To:     Jeffle Xu <jefflexu@...ux.alibaba.com>
Cc:     tytso@....edu, adilger.kernel@...ger.ca,
        linux-ext4@...r.kernel.org, joseph.qi@...ux.alibaba.com
Subject: Re: [PATCH] ext4: fix reserved space counter leakage

* Jeffle Xu <jefflexu@...ux.alibaba.com>:
> When ext4_es_insert_delayed_block() returns error, e.g., ENOMEM,
> previously reserved space is not released as the error handling,
> in which case @s_dirtyclusters_counter is left over. Since this delayed
> extent failes to be inserted into extent status tree, when inode is
> written back, the extra @s_dirtyclusters_counter won't be subtracted and
> remains there forever.
> 
> This can leads to /sys/fs/ext4/<dev>/delayed_allocation_blocks remains
> non-zero even when syncfs is executed on the filesystem.
> 

Hi:

I think the fix below looks fine.  However, this comment doesn't look right
to me.  Are you really seeing delayed_allocation_blocks values that remain
incorrectly elevated across last closes (or across file system unmounts and
remounts)?  s_dirtyclusters_counter isn't written out to stable storage -
it's an in-memory only variable that's created when a file is first opened
and destroyed on last close.

Eric

> Fixes: 51865fda28e5 ("ext4: let ext4 maintain extent status tree")
> Cc: <stable@...r.kernel.org>
> Reported-by: Gao Xiang <hsiangkao@...ux.alibaba.com>
> Signed-off-by: Jeffle Xu <jefflexu@...ux.alibaba.com>
> ---
>  fs/ext4/inode.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
> index 82087657860b..7f15da370281 100644
> --- a/fs/ext4/inode.c
> +++ b/fs/ext4/inode.c
> @@ -1650,6 +1650,7 @@ static int ext4_insert_delayed_block(struct inode *inode, ext4_lblk_t lblk)
>  	struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb);
>  	int ret;
>  	bool allocated = false;
> +	bool reserved = false;
>  
>  	/*
>  	 * If the cluster containing lblk is shared with a delayed,
> @@ -1666,6 +1667,7 @@ static int ext4_insert_delayed_block(struct inode *inode, ext4_lblk_t lblk)
>  		ret = ext4_da_reserve_space(inode);
>  		if (ret != 0)   /* ENOSPC */
>  			goto errout;
> +		reserved = true;
>  	} else {   /* bigalloc */
>  		if (!ext4_es_scan_clu(inode, &ext4_es_is_delonly, lblk)) {
>  			if (!ext4_es_scan_clu(inode,
> @@ -1678,6 +1680,7 @@ static int ext4_insert_delayed_block(struct inode *inode, ext4_lblk_t lblk)
>  					ret = ext4_da_reserve_space(inode);
>  					if (ret != 0)   /* ENOSPC */
>  						goto errout;
> +					reserved = true;
>  				} else {
>  					allocated = true;
>  				}
> @@ -1688,6 +1691,8 @@ static int ext4_insert_delayed_block(struct inode *inode, ext4_lblk_t lblk)
>  	}
>  
>  	ret = ext4_es_insert_delayed_block(inode, lblk, allocated);
> +	if (ret && reserved)
> +		ext4_da_release_space(inode, 1);
>  
>  errout:
>  	return ret;
> -- 
> 2.27.0
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ