From: Dave Chinner <david@fromorbit.com>
To: Viet Nguyen <vietnguyen@gmail.com>
Cc: xfs@oss.sgi.com
Subject: Re: xfs_repair segfault
Date: Sat, 5 Oct 2013 07:43:53 +1000 [thread overview]
Message-ID: <20131004214353.GK4446@dastard> (raw)
In-Reply-To: <CAGa409_wO74zGP1d85RGZ7WbfBPr7s_tKaW3u9k8=9Ps-D5FjQ@mail.gmail.com>
On Fri, Oct 04, 2013 at 10:51:50AM -0700, Viet Nguyen wrote:
> Hi,
>
> I was wondering if you got a chance to look at this and if one's available,
> where can I get a patch?
Can you try the patch below?
Cheers,
Dave.
--
Dave Chinner
david@fromorbit.com
libxfs: validity check the directory block leaf entry count
From: Dave Chinner <dchinner@redhat.com>
The directory block format verifier fails to check that the leaf
entry count is in a valid range, and so if it is corrupted then it
can lead to derefencing a pointer outside the block buffer. While we
can't exactly validate the count without first walking the directory
block, we can ensure the count lands in the valid area within the
directory block and hence avoid out-of-block references.
Signed-off-by: Dave Chinner <dchinner@redhat.com>
---
libxfs/xfs_dir2_data.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/libxfs/xfs_dir2_data.c b/libxfs/xfs_dir2_data.c
index 189699f..1b5196b 100644
--- a/libxfs/xfs_dir2_data.c
+++ b/libxfs/xfs_dir2_data.c
@@ -59,6 +59,18 @@ __xfs_dir3_data_check(
btp = xfs_dir2_block_tail_p(mp, hdr);
lep = xfs_dir2_block_leaf_p(btp);
endp = (char *)lep;
+
+ /*
+ * The number of leaf entries is limited by the size of the
+ * block and the amount of space used by the data entries.
+ * We don't know how much space is used by the data entries yet,
+ * so just ensure that the count falls somewhere inside the
+ * block right now.
+ */
+ XFS_WANT_CORRUPTED_RETURN(be32_to_cpu(btp->count) >
+ ((char *)btp - (char *)p) /
+ sizeof(struct xfs_dir2_leaf_entry));
+
break;
case cpu_to_be32(XFS_DIR3_DATA_MAGIC):
case cpu_to_be32(XFS_DIR2_DATA_MAGIC):
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
next prev parent reply other threads:[~2013-10-04 21:44 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-10-01 19:57 xfs_repair segfault Viet Nguyen
2013-10-01 20:19 ` Dave Chinner
2013-10-01 21:12 ` Viet Nguyen
2013-10-02 10:42 ` Dave Chinner
2013-10-04 17:51 ` Viet Nguyen
2013-10-04 21:43 ` Dave Chinner [this message]
2013-10-07 20:09 ` Viet Nguyen
2013-10-08 20:23 ` Dave Chinner
2013-10-09 18:59 ` Viet Nguyen
2013-10-09 20:15 ` Dave Chinner
2013-10-10 21:13 ` Viet Nguyen
-- strict thread matches above, loose matches on Subject: below --
2015-03-09 15:50 Rui Gomes
2015-03-09 15:55 ` Carsten Aulbert
2015-03-09 16:11 ` Rui Gomes
2015-03-09 16:14 ` Eric Sandeen
2015-03-09 16:24 ` Rui Gomes
2015-03-09 17:34 ` Eric Sandeen
2015-03-09 17:50 ` Rui Gomes
2015-03-09 18:18 ` Eric Sandeen
2015-03-09 18:24 ` Rui Gomes
2015-03-09 20:13 ` Eric Sandeen
2007-04-03 19:11 James W. Abendschan
2007-04-04 0:45 ` Barry Naujok
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=20131004214353.GK4446@dastard \
--to=david@fromorbit.com \
--cc=vietnguyen@gmail.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