mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Zhang Yi <yi.zhang@huawei.com>
To: Kemeng Shi <shikemeng@huaweicloud.com>
Cc: <linux-ext4@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<tytso@mit.edu>, <adilger.kernel@dilger.ca>
Subject: Re: [PATCH 2/7] ext4: avoid potential buffer_head leak in __ext4_new_inode
Date: Wed, 14 Aug 2024 16:48:31 +0800	[thread overview]
Message-ID: <0351b3b1-e84a-9e41-a492-743f5bbea910@huawei.com> (raw)
In-Reply-To: <20240813120712.2592310-3-shikemeng@huaweicloud.com>

On 2024/8/13 20:07, Kemeng Shi wrote:
> If a group is marked EXT4_GROUP_INFO_IBITMAP_CORRUPT after it's inode
> bitmap buffer_head was successfully verified, then __ext4_new_inode
> will get a valid inode_bitmap_bh of a corrupted group from
> ext4_read_inode_bitmap in which case inode_bitmap_bh misses a release.
> Hnadle "IS_ERR(inode_bitmap_bh)" and group corruption separately like
> how ext4_free_inode does to avoid buffer_head leak.
> 
> Signed-off-by: Kemeng Shi <shikemeng@huaweicloud.com>
> ---
>  fs/ext4/ialloc.c | 10 +++++++---
>  1 file changed, 7 insertions(+), 3 deletions(-)
> 
> diff --git a/fs/ext4/ialloc.c b/fs/ext4/ialloc.c
> index ad7f13976dc6..f24a238b6b09 100644
> --- a/fs/ext4/ialloc.c
> +++ b/fs/ext4/ialloc.c
> @@ -1054,9 +1054,13 @@ struct inode *__ext4_new_inode(struct mnt_idmap *idmap,
>  		brelse(inode_bitmap_bh);
>  		inode_bitmap_bh = ext4_read_inode_bitmap(sb, group);
>  		/* Skip groups with suspicious inode tables */
> -		if (((!(sbi->s_mount_state & EXT4_FC_REPLAY))
> -		     && EXT4_MB_GRP_IBITMAP_CORRUPT(grp)) ||
> -		    IS_ERR(inode_bitmap_bh)) {
> +		if (IS_ERR(inode_bitmap_bh)) {
> +			inode_bitmap_bh = NULL;
> +			goto next_group;
> +		}
> +		if (!(sbi->s_mount_state & EXT4_FC_REPLAY) &&
> +		    EXT4_MB_GRP_IBITMAP_CORRUPT(grp)) {
> +			brelse(inode_bitmap_bh);
>  			inode_bitmap_bh = NULL;

Wouldn't the inode_bitmap_bh be brelsed in the next loop or the end of this
function? why not just goto next_group?

Thanks,
Yi.

>  			goto next_group;
>  		}
> 

  reply	other threads:[~2024-08-14  8:48 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-13 12:07 [PATCH 0/7] Fixes and cleanups to ext4 ialloc Kemeng Shi
2024-08-13 12:07 ` [PATCH 1/7] ext4: avoid buffer_head leak in ext4_mark_inode_used Kemeng Shi
2024-08-15  9:55   ` Markus Elfring
2024-08-15 13:17     ` Kemeng Shi
2024-08-15 14:49       ` Darrick J. Wong
2024-08-16  6:56         ` Markus Elfring
2024-08-16 16:35           ` Theodore Ts'o
2024-08-13 12:07 ` [PATCH 2/7] ext4: avoid potential buffer_head leak in __ext4_new_inode Kemeng Shi
2024-08-14  8:48   ` Zhang Yi [this message]
2024-08-15  1:36     ` Kemeng Shi
2024-08-13 12:07 ` [PATCH 3/7] ext4: avoid negative min_clusters in find_group_orlov Kemeng Shi
2024-08-13 12:07 ` [PATCH 4/7] ext4: remove dead check in __ext4_new_inode Kemeng Shi
2024-08-13 12:07 ` [PATCH 5/7] ext4: move checksum length calculation of inode bitmap into ext4_inode_bitmap_csum_[verify/set] functions Kemeng Shi
2024-08-13 12:07 ` [PATCH 6/7] ext4: remove unneeded NULL check of buffer_head in ext4_mark_inode_used Kemeng Shi
2024-08-13 12:07 ` [PATCH 7/7] ext4: check buffer_verified in advance to avoid unneeded ext4_get_group_info Kemeng Shi
2024-08-15 11:13   ` Markus Elfring
2024-08-15 13:17     ` Kemeng Shi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=0351b3b1-e84a-9e41-a492-743f5bbea910@huawei.com \
    --to=yi.zhang@huawei.com \
    --cc=adilger.kernel@dilger.ca \
    --cc=linux-ext4@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=shikemeng@huaweicloud.com \
    --cc=tytso@mit.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®