All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: Eric Sandeen <sandeen@sandeen.net>
Cc: Bill O'Donnell <billodo@redhat.com>, linux-xfs@vger.kernel.org
Subject: Re: [PATCH v3] libxfs: add more bounds checking to sb sanity checks
Date: Wed, 25 Jul 2018 15:55:26 -0700	[thread overview]
Message-ID: <20180725225526.GC4218@magnolia> (raw)
In-Reply-To: <bee8d307-e372-2b67-e46e-f54b6dd81379@sandeen.net>

On Wed, Jul 25, 2018 at 03:48:51PM -0700, Eric Sandeen wrote:
> 
> 
> On 7/25/18 2:33 PM, Bill O'Donnell wrote:
> > +	/* Additional sb sanity checks for writes */
> > +	if (!error) {
> > +		if (sb.sb_fdblocks > sb.sb_dblocks ||
> > +		    sb.sb_ifree > sb.sb_icount) {
> > +			    xfs_notice(mp, "SB sanity check failed");
> > +			    error = -EFSCORRUPTED;
> > +		}
> > +	}
> 
> I had kind of had it in my head that Dave suggested testing not
> only sb_fdblocks & sb_ifree but also validating sb_icount against
> sb_dblocks ... would that make sense?  something like:
> 
> +		if (sb.sb_fdblocks > sb.sb_dblocks ||
> +		    sb.sb_icount / sb.sb_inopblock > sb.sb_dblocks) ||

That would make sense, but perhaps we should have a xfs_verify_icount
instead of open-coding a 64-bit division? :)

Granted, I /was/ planning to add all that as part of fs summary counter
scrubbing next cycle.

--D

> +		    sb.sb_ifree > sb.sb_icount) {
> +			    xfs_notice(mp, "SB sanity check failed");
> 
> because all 3 go into the statfs calculations which went wonky
> in the original report?  (xfs_sb_verify has done some sanity
> checks on sb_inopblock by the time we get here.)
> 
> Also, a comment about why these checks are only for write, and are not
> simply in xfs_mount_validate_sb() would be good, since that obviously
> wasn't obvious to me at first.  o_O :)
> 
> -Eric
> --
> To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

  reply	other threads:[~2018-07-26  0:09 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-13 13:10 [PATCH] libxfs: add more bounds checking to sb sanity checks Bill O'Donnell
2018-07-13 16:41 ` Darrick J. Wong
2018-07-13 20:06   ` Bill O'Donnell
2018-07-13 23:43   ` Dave Chinner
2018-07-17 17:13     ` Darrick J. Wong
2018-07-16 19:26 ` [PATCH v2] " Bill O'Donnell
2018-07-17  9:17   ` Carlos Maiolino
2018-07-17 17:06   ` Darrick J. Wong
2018-07-17 17:17     ` Bill O'Donnell
2018-07-17 19:12       ` Bill O'Donnell
2018-07-17 20:33         ` Darrick J. Wong
2018-07-17 23:26           ` Dave Chinner
2018-07-18 20:07             ` Bill O'Donnell
2018-07-25 21:33 ` [PATCH v3] " Bill O'Donnell
2018-07-25 21:47   ` Darrick J. Wong
2018-07-25 21:58     ` Bill O'Donnell
2018-07-25 22:48   ` Eric Sandeen
2018-07-25 22:55     ` Darrick J. Wong [this message]
2018-07-26 16:40 ` [PATCH v4] " Bill O'Donnell
2018-07-26 17:07   ` Darrick J. Wong
2018-07-26 17:19     ` Bill O'Donnell

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=20180725225526.GC4218@magnolia \
    --to=darrick.wong@oracle.com \
    --cc=billodo@redhat.com \
    --cc=linux-xfs@vger.kernel.org \
    --cc=sandeen@sandeen.net \
    /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.