All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Theodore Y. Ts'o" <tytso@mit.edu>
To: Jan Kara <jack@suse.cz>
Cc: Lukas Czerner <lczerner@redhat.com>, linux-ext4@vger.kernel.org
Subject: Re: [PATCH 2/2] ext2fs: Fix off-by-one in dx_grow_tree()
Date: Fri, 10 Apr 2020 00:33:21 -0400	[thread overview]
Message-ID: <20200410043321.GM45598@mit.edu> (raw)
In-Reply-To: <20200331143035.GB13528@quack2.suse.cz>

On Tue, Mar 31, 2020 at 04:30:35PM +0200, Jan Kara wrote:
> > > > Don't we have basically the same off-by-one in
> > > > e2fsck/pass1.c handle_htree() ?
> > > > 
> > > >        if ((root->indirect_levels > ext2_dir_htree_level(fs)) &&
> > > >            fix_problem(ctx, PR_1_HTREE_DEPTH, pctx))
> > > 
> > 
> > root->indirect_levels is zero based, while ext2_dir_htree_level()
> > returns the maximum number of levels (that is 3 by default). If I am
> > right then indirect_levels must always be smaller then
> > ext2_dir_htree_level() and that is how we use it everywhere else - the
> > palce I am pointing out is an exception and I think it's a bug.
> > 
> > Indeed it looks like the bug got introduced in
> > 3f0cf647539970474be8f607017ca7eccfc2fbbe
> > 
> > -       if ((root->indirect_levels > 1) &&
> > +       if ((root->indirect_levels > ext2_dir_htree_level(fs)) &&
> > 
> > Or am I missing something ?
> 
> Ah, you're indeed right! e2fsck/pass2.c even has a correct version of the
> condition. Just the condition in pass1.c is wrong.

I've applied the following fix on the maint branch.

     	     	 	       	      	    - Ted

commit 759b387775bfd5c9d3692680e5e4b929c3848d51
Author: Theodore Ts'o <tytso@mit.edu>
Date:   Fri Apr 10 00:30:52 2020 -0400

    e2fsck: fix off-by-one check when validating depth of an htree
    
    Fixes: 3f0cf6475399 ("e2fsprogs: add support for 3-level htree")
    
    Signed-off-by: Theodore Ts'o <tytso@mit.edu>

diff --git a/e2fsck/pass1.c b/e2fsck/pass1.c
index c9e8bf82..38afda48 100644
--- a/e2fsck/pass1.c
+++ b/e2fsck/pass1.c
@@ -2685,7 +2685,7 @@ static int handle_htree(e2fsck_t ctx, struct problem_context *pctx,
 		return 1;
 
 	pctx->num = root->indirect_levels;
-	if ((root->indirect_levels > ext2_dir_htree_level(fs)) &&
+	if ((root->indirect_levels >= ext2_dir_htree_level(fs)) &&
 	    fix_problem(ctx, PR_1_HTREE_DEPTH, pctx))
 		return 1;
 

  reply	other threads:[~2020-04-10  4:33 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-30  9:09 [PATCH 0/2] Fixes for dir_index support in libext2fs Jan Kara
2020-03-30  9:09 ` [PATCH 1/2] ext2fs: Fix error checking in dx_link() Jan Kara
2020-03-30 13:24   ` Lukas Czerner
2020-03-30 13:48     ` Lukas Czerner
2020-03-30 14:55       ` Jan Kara
2020-04-10  3:52   ` Theodore Y. Ts'o
2020-03-30  9:09 ` [PATCH 2/2] ext2fs: Fix off-by-one in dx_grow_tree() Jan Kara
2020-03-30 13:27   ` Lukas Czerner
2020-03-30 14:55     ` Jan Kara
2020-03-31 11:33       ` Lukas Czerner
2020-03-31 14:30         ` Jan Kara
2020-04-10  4:33           ` Theodore Y. Ts'o [this message]
2020-04-10 15:09             ` Jan Kara
2020-04-10  4:32   ` Theodore Y. Ts'o

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=20200410043321.GM45598@mit.edu \
    --to=tytso@mit.edu \
    --cc=jack@suse.cz \
    --cc=lczerner@redhat.com \
    --cc=linux-ext4@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 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.