All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Marek Behún" <marek.behun@nic.cz>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] fs: btrfs: Fix tree traversal with btrfs_next_slot()
Date: Tue, 2 Oct 2018 13:22:28 +0200	[thread overview]
Message-ID: <20181002132228.1de1da5b@dellmb.labs.office.nic.cz> (raw)
In-Reply-To: <1536314370-15060-1-git-send-email-yevgenyp@pointgrab.com>

Tested-by: Marek Behún <marek.behun@nic.cz>

Hello Tom, could you please apply the patch by Yevgeny?

Marek

On Fri,  7 Sep 2018 12:59:30 +0300
Yevgeny Popovych <yevgenyp@pointgrab.com> 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 <yevgenyp@pointgrab.com>
> Cc: Marek Behun <marek.behun@nic.cz>
> ---
>  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]++;

  parent reply	other threads:[~2018-10-02 11:22 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-07  9:59 [U-Boot] [PATCH] fs: btrfs: Fix tree traversal with btrfs_next_slot() Yevgeny Popovych
2018-10-01  5:50 ` Yevgeny Popovych
2018-10-01 10:35   ` Marek Behún
2018-10-01 14:18     ` Yevgeny Popovych
2018-10-02 11:22 ` Marek Behún [this message]
2018-10-08 15:16   ` Tom Rini
2018-10-11 14:11 ` [U-Boot] " Tom Rini

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=20181002132228.1de1da5b@dellmb.labs.office.nic.cz \
    --to=marek.behun@nic.cz \
    --cc=u-boot@lists.denx.de \
    /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.