From: Mark Tinguely <tinguely@sgi.com>
To: Eric Sandeen <sandeen@sandeen.net>
Cc: "'linux-xfs@oss.sgi.com'" <linux-xfs@oss.sgi.com>,
Eric Sandeen <sandeen@redhat.com>
Subject: Re: [PATCH] xfs_check: fix test for too-high level in v2 dir node
Date: Mon, 23 Sep 2013 08:36:52 -0500 [thread overview]
Message-ID: <524043F4.6000202@sgi.com> (raw)
In-Reply-To: <523A0AF0.3000507@sandeen.net>
On 09/18/13 15:20, Eric Sandeen wrote:
> On 9/18/13 2:35 PM, Mark Tinguely wrote:
>> On 09/12/13 16:00, Eric Sandeen wrote:
>>> The test as it stands allows level == XFS_DA_NODE_MAXDEPTH (5),
>>> but a max depth of 5 equates to level values of 0 through 4.
>>>
>>> Level 5 would be a depth of 6.
>>>
>>> Signed-off-by: Eric Sandeen<sandeen@redhat.com>
>>> ---
>>>
>>
>>> diff --git a/db/check.c b/db/check.c
>>> index cbe55ba..d9e3e3f 100644
>>> --- a/db/check.c
>>> +++ b/db/check.c
>>> @@ -3138,7 +3138,7 @@ process_leaf_node_dir_v2_int(
>>> case XFS_DA_NODE_MAGIC:
>>> node = iocur_top->data;
>>> xfs_da3_node_hdr_from_disk(&nodehdr, node);
>>> - if (nodehdr.level < 1 || nodehdr.level > XFS_DA_NODE_MAXDEPTH) {
>>> + if (nodehdr.level < 1 || nodehdr.level >= XFS_DA_NODE_MAXDEPTH) {
>>> if (!sflag || v)
>>> dbprintf(_("bad node block level %d for dir ino "
>>> "%lld block %d\n"),
>>
>>
>> I think the current code is correct.
>>
>> 0 is a leaf. levels 1-XFS_DA_NODE_MAXDEPTH are nodes.
>> Subtract 1 when used as an index.
>
> case XFS_DA_NODE_MAGIC:
> node = iocur_top->data;
> xfs_da3_node_hdr_from_disk(&nodehdr, node);
> to->level = be16_to_cpu(from->hdr.__level);
> if (nodehdr.level < 1 || nodehdr.level > XFS_DA_NODE_MAXDEPTH) {
>
> so nodehdr.level comes directly off the disk.
>
> Hm, ok, let's look at the verifier, xfs_da3_node_verify:
>
> xfs_da3_node_hdr_from_disk /* sets to->level = be16_to_cpu(from->hdr.__level) */
>
> ...
>
> if (ichdr.level == 0)
> return false;
> if (ichdr.level > XFS_DA_NODE_MAXDEPTH)
> return false;
>
> ok, so 1 through XFS_DA_NODE_MAXDEPTH is valid for a generic node. *shrug* ok
> fine, I agree. It's only xfs_check anyway. ;)
>
> Feel free to drop this patch then.
>
> But now I'm trying to reconcile it w/ the code in repair,
>
> i = da_cursor->active = nodehdr.level;
> if (i < 1 || i >= XFS_DA_NODE_MAXDEPTH) {
>
> which considers nodehdr.level == XFS_DA_NODE_MAXDEPTH to be problematic, because
> i (== nodehdr.level) is used directly as an index into a level[XFS_DA_NODE_MAXDEPTH]-sized
> array.
>
> So confused. :/ (Maybe the cursor array needs to be 1 bigger?)
>
> -Eric
Strange, the kernel attribute asserts use XFS_DA_NODE_MAXDEPTH-1 as the
maximum good value.
Looks like the repair code uses the cursor level[0], so we cannot index
with (i - 1). I agree that the array in the da_bt_cursor should be one
greater.
--Mark.
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
prev parent reply other threads:[~2013-09-23 13:36 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-09-12 21:00 [PATCH] xfs_check: fix test for too-high level in v2 dir node Eric Sandeen
2013-09-18 19:35 ` Mark Tinguely
2013-09-18 20:20 ` Eric Sandeen
2013-09-18 20:55 ` Mark Tinguely
2013-09-23 13:36 ` Mark Tinguely [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=524043F4.6000202@sgi.com \
--to=tinguely@sgi.com \
--cc=linux-xfs@oss.sgi.com \
--cc=sandeen@redhat.com \
--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.