From: Tom Rini Date: Mon, 8 Oct 2018 11:16:55 -0400 Subject: [U-Boot] [PATCH] fs: btrfs: Fix tree traversal with btrfs_next_slot() In-Reply-To: <20181002132228.1de1da5b@dellmb.labs.office.nic.cz> References: <1536314370-15060-1-git-send-email-yevgenyp@pointgrab.com> <20181002132228.1de1da5b@dellmb.labs.office.nic.cz> Message-ID: <20181008151655.GA5539@bill-the-cat> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit To: u-boot@lists.denx.de On Tue, Oct 02, 2018 at 01:22:28PM +0200, Marek BehĂșn wrote: > Tested-by: Marek BehĂșn > > Hello Tom, could you please apply the patch by Yevgeny? Sorry, I'll just lament that patchwork no longer has the ability to list unassigned patches anymore. I've given this to myself in patchwork and will pick it up shortly. Thanks! > > Marek > > On Fri, 7 Sep 2018 12:59:30 +0300 > Yevgeny Popovych wrote: > > > When traversing slots in a btree (via btrfs_path) with > > btrfs_next_slot(), we didn't correctly identify that the last slot in > > the leaf was reached and we should jump to the next leaf. > > > > This could lead to any kind of runtime errors or corruptions, like: > > * file data not being read at all, or is read partially > > * file is read but is corrupted > > * (any) metadata being corrupted or not read at all, etc > > > > The easiest way to reproduce this is to read a large enough file that > > its EXTENT_DATA items don't fit into a single leaf. > > > > Signed-off-by: Yevgeny Popovych > > Cc: Marek Behun > > --- > > fs/btrfs/ctree.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c > > index 4da36a9..b44a47e 100644 > > --- a/fs/btrfs/ctree.c > > +++ b/fs/btrfs/ctree.c > > @@ -270,7 +270,7 @@ int btrfs_next_slot(struct btrfs_path *p) > > { > > struct btrfs_leaf *leaf = &p->nodes[0]->leaf; > > > > - if (p->slots[0] >= leaf->header.nritems) > > + if (p->slots[0] + 1 >= leaf->header.nritems) > > return jump_leaf(p, 1); > > > > p->slots[0]++; > -- Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: not available URL: