From: Dave Chinner <david@fromorbit.com>
To: Brian Foster <bfoster@redhat.com>
Cc: linux-xfs@vger.kernel.org
Subject: Re: [PATCH] libxfs: init ->b_maps on contig buffers for uncached compatibility
Date: Fri, 21 Jul 2017 08:57:58 +1000 [thread overview]
Message-ID: <20170720225758.GX17762@dastard> (raw)
In-Reply-To: <20170720150612.37494-1-bfoster@redhat.com>
On Thu, Jul 20, 2017 at 11:06:12AM -0400, Brian Foster wrote:
> There is a bit of an inconsistency in how ->b_maps is used for
> contiguous buffers between kernel libxfs and xfsprogs due to the
> independent buffer implementations. In the kernel, ->b_maps[0] is
> always intialized to a valid range and in xfsprogs, ->b_maps is only
> allocated for discontiguous buffers.
>
> This can lead to confusion when dealing with uncached kernel buffers
> in common libxfs code because xfsprogs has no concept of uncached
> buffers. Kernel uncached buffers have ->b_bn == XFS_BUF_DADDR_NULL
> and ->b_maps[0] points to the physical block address. Block address
> checks in common code for kernel uncached buffers, such as in
> xfs_sb_verify(), therefore would need to check both places for an
> address or risk broken logic or userspace segfaults.
>
> This problem currently manifests as an xfs_repair segfault due to a
> NULL ->b_maps access in xfs_sb_verify(). Note that this problem is
> only reproducible on builds with (-O2) optimization disabled, as the
> affected parameter is currently unused and thus optimization
> eliminates the problematic access.
>
> To fix this problem and eliminate the incompatibility, update the
> userspace xfs_buf with an internal ->__b_map field and point
> ->b_maps to it for contiguous buffers, similar to the kernel buffer
> implementation. Set valid values in ->b_maps0] for contiguous
->b_maps[0]
> buffers so common code will continue to work regardless of whether a
> buffer is uncached in the kernel.
>
> Signed-off-by: Brian Foster <bfoster@redhat.com>
Looks right but I haven't compiled/tested it so:
Acked-by: Dave Chinner <dchinner@redhat.com>
-Dave.
--
Dave Chinner
david@fromorbit.com
prev parent reply other threads:[~2017-07-20 22:58 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-20 15:06 [PATCH] libxfs: init ->b_maps on contig buffers for uncached compatibility Brian Foster
2017-07-20 22:57 ` Dave Chinner [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=20170720225758.GX17762@dastard \
--to=david@fromorbit.com \
--cc=bfoster@redhat.com \
--cc=linux-xfs@vger.kernel.org \
/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