All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@infradead.org>
To: Zheng Bin <zhengbin13@huawei.com>
Cc: bfoster@redhat.com, dchinner@redhat.com, sandeen@sandeen.net,
	darrick.wong@oracle.com, linux-xfs@vger.kernel.org,
	yi.zhang@huawei.com, houtao1@huawei.com
Subject: Re: [PATCH 2/2] xfs: avoid f_bfree overflow
Date: Tue, 17 Mar 2020 11:32:23 -0700	[thread overview]
Message-ID: <20200317183223.GA23580@infradead.org> (raw)
In-Reply-To: <1584364028-122886-3-git-send-email-zhengbin13@huawei.com>

> +	if (sbp->sb_fdblocks < mp->m_alloc_set_aside) {
> +		xfs_alert(mp, "Corruption detected. Please run xfs_repair.");
> +		error = -EFSCORRUPTED;
> +		goto out_log_dealloc;
> +	}
> +
>  	/*
>  	 * Get and sanity-check the root inode.
>  	 * Save the pointer to it in the mount structure.
> diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c
> index 2094386..9dcf772 100644
> --- a/fs/xfs/xfs_super.c
> +++ b/fs/xfs/xfs_super.c
> @@ -755,7 +755,8 @@ xfs_fs_statfs(
>  	statp->f_blocks = sbp->sb_dblocks - lsize;
>  	spin_unlock(&mp->m_sb_lock);
> 
> -	statp->f_bfree = fdblocks - mp->m_alloc_set_aside;
> +	/* make sure statp->f_bfree does not underflow */
> +	statp->f_bfree = max_t(int64_t, fdblocks - mp->m_alloc_set_aside, 0);

How can this happen with the above hunk applies?  And even if we'd
need to do the sanity chck it shold be two separate patches.

      reply	other threads:[~2020-03-17 18:32 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-16 13:07 [PATCH 0/2] xfs: always init fdblocks in mount and avoid f_bfree overflow Zheng Bin
2020-03-16 13:07 ` [PATCH 1/2] xfs: always init fdblocks in mount Zheng Bin
2020-03-16 15:13   ` Darrick J. Wong
2020-03-17  1:39     ` zhengbin (A)
2020-03-17  2:22     ` zhengbin (A)
2020-03-17  3:55       ` Darrick J. Wong
2020-03-17  4:18         ` zhengbin (A)
2020-03-16 18:10   ` Eric Sandeen
2020-03-16 13:07 ` [PATCH 2/2] xfs: avoid f_bfree overflow Zheng Bin
2020-03-17 18:32   ` Christoph Hellwig [this message]

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=20200317183223.GA23580@infradead.org \
    --to=hch@infradead.org \
    --cc=bfoster@redhat.com \
    --cc=darrick.wong@oracle.com \
    --cc=dchinner@redhat.com \
    --cc=houtao1@huawei.com \
    --cc=linux-xfs@vger.kernel.org \
    --cc=sandeen@sandeen.net \
    --cc=yi.zhang@huawei.com \
    --cc=zhengbin13@huawei.com \
    /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 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.