From: Brian Foster <bfoster@redhat.com>
To: xfs@oss.sgi.com
Subject: Re: [PATCH] xfs: sanitize sb_inopblock in xfs_mount_validate_sb
Date: Thu, 30 Jan 2014 15:26:06 -0500 [thread overview]
Message-ID: <52EAB55E.5030204@redhat.com> (raw)
In-Reply-To: <52E88357.6090104@redhat.com>
On 01/28/2014 11:28 PM, Eric Sandeen wrote:
> xfs_mount_validate_sb doesn't check sb_inopblock for sanity
> (as does its xfs_repair counterpart, FWIW).
>
> If it's out of bounds, we can go off the rails in i.e.
> xfs_inode_buf_verify(), which uses sb_inopblock as a loop
> limit when stepping through a metadata buffer.
>
> The problem can be demonstrated easily by corrupting
> sb_inopblock with xfs_db and trying to mount the result:
>
> # mkfs.xfs -dfile,name=fsfile,size=1g
> # xfs_db -x fsfile
> xfs_db> sb 0
> xfs_db> write inopblock 512
> inopblock = 512
> xfs_db> quit
>
> # mount -o loop fsfile mnt
> and we blow up in xfs_inode_buf_verify().
>
> With this patch, we get a (very noisy) corruption error,
> and fail the mount as we should.
>
> Signed-off-by: Eric Sandeen <sandeen@redhat.com>
> ---
Reviewed-by: Brian Foster <bfoster@redhat.com>
>
> diff --git a/fs/xfs/xfs_sb.c b/fs/xfs/xfs_sb.c
> index b7c9aea..511cce9 100644
> --- a/fs/xfs/xfs_sb.c
> +++ b/fs/xfs/xfs_sb.c
> @@ -288,6 +288,7 @@ xfs_mount_validate_sb(
> sbp->sb_inodelog < XFS_DINODE_MIN_LOG ||
> sbp->sb_inodelog > XFS_DINODE_MAX_LOG ||
> sbp->sb_inodesize != (1 << sbp->sb_inodelog) ||
> + sbp->sb_inopblock != howmany(sbp->sb_blocksize,sbp->sb_inodesize) ||
> (sbp->sb_blocklog - sbp->sb_inodelog != sbp->sb_inopblog) ||
> (sbp->sb_rextsize * sbp->sb_blocksize > XFS_MAX_RTEXTSIZE) ||
> (sbp->sb_rextsize * sbp->sb_blocksize < XFS_MIN_RTEXTSIZE) ||
>
> _______________________________________________
> xfs mailing list
> xfs@oss.sgi.com
> http://oss.sgi.com/mailman/listinfo/xfs
>
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
prev parent reply other threads:[~2014-01-30 20:26 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-01-29 4:28 [PATCH] xfs: sanitize sb_inopblock in xfs_mount_validate_sb Eric Sandeen
2014-01-29 14:58 ` Jeff Liu
2014-01-30 20:26 ` Brian Foster [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=52EAB55E.5030204@redhat.com \
--to=bfoster@redhat.com \
--cc=xfs@oss.sgi.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).