From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: Dave Chinner <david@fromorbit.com>
Cc: linux-xfs@vger.kernel.org, viro@ZenIV.linux.org.uk
Subject: Re: [PATCH 2/2] xfs: validate allocated inode number
Date: Tue, 17 Apr 2018 17:12:59 -0700 [thread overview]
Message-ID: <20180418001259.GH24738@magnolia> (raw)
In-Reply-To: <20180417063916.13069-3-david@fromorbit.com>
On Tue, Apr 17, 2018 at 04:39:16PM +1000, Dave Chinner wrote:
> From: Dave Chinner <dchinner@redhat.com>
>
> When we have corrupted free inode btrees, we can attempt to
> allocate inodes that we know are already allocated. Catch allocation
> of these inodes and report corruption as early as possible to
> prevent corruption propagation or deadlocks.
>
> Signed-Off-By: Dave Chinner <dchinner@redhat.com>
Looks ok, will test...
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
--D
> ---
> fs/xfs/xfs_inode.c | 13 +++++++++++++
> 1 file changed, 13 insertions(+)
>
> diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
> index 7b764f746ff2..12e6c1aec386 100644
> --- a/fs/xfs/xfs_inode.c
> +++ b/fs/xfs/xfs_inode.c
> @@ -790,6 +790,19 @@ xfs_ialloc(
> }
> ASSERT(*ialloc_context == NULL);
>
> + /*
> + * Protect against obviously corrupt allocation btree records. Later
> + * xfs_iget checks will catch re-allocation of other active in-memory
> + * and on-disk inodes. If we don't catch reallocating the parent inode
> + * here we will deadlock in xfs_iget() so we have to do these checks
> + * first.
> + */
> + if ((pip && ino == pip->i_ino) ||
> + !xfs_verify_dir_ino(mp, ino)) {
> + xfs_alert(mp, "Allocated a known in-use inode 0x%llx!", ino);
> + return -EFSCORRUPTED;
> + }
> +
> /*
> * Get the in-core inode with the lock held exclusively.
> * This is because we're setting fields here we need
> --
> 2.16.1
>
> --
> 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
next prev parent reply other threads:[~2018-04-18 0:13 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-04-17 6:39 [PATCH 0/3] xfs: detect corrupt inobt records better Dave Chinner
2018-04-17 6:39 ` [PATCH 1/2] xfs: validate cached inodes are free when allocated Dave Chinner
2018-04-17 7:11 ` Christoph Hellwig
2018-04-17 9:00 ` Carlos Maiolino
2018-04-17 23:57 ` Dave Chinner
2018-04-18 0:05 ` Darrick J. Wong
2018-04-18 0:10 ` Darrick J. Wong
2018-04-17 6:39 ` [PATCH 2/2] xfs: validate allocated inode number Dave Chinner
2018-04-17 7:12 ` Christoph Hellwig
2018-04-17 9:05 ` Carlos Maiolino
2018-04-18 0:12 ` Darrick J. Wong [this message]
2018-04-17 9:13 ` [PATCH 0/3] xfs: detect corrupt inobt records better Carlos Maiolino
2018-04-17 22:28 ` Dave Chinner
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=20180418001259.GH24738@magnolia \
--to=darrick.wong@oracle.com \
--cc=david@fromorbit.com \
--cc=linux-xfs@vger.kernel.org \
--cc=viro@ZenIV.linux.org.uk \
/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).