All of lore.kernel.org
 help / color / mirror / Atom feed
From: Filipe Manana <fdmanana@gmail.com>
To: Qu Wenruo <wqu@suse.com>
Cc: linux-btrfs <linux-btrfs@vger.kernel.org>
Subject: Re: [PATCH v2 2/2] btrfs: volumes: Make sure no dev extent is beyond device boundary
Date: Mon, 7 Jan 2019 16:27:41 +0000	[thread overview]
Message-ID: <CAL3q7H4-YsT4n663XNTzFa9hUnmRWUPzgvovP-GcYnkA6cKHWw@mail.gmail.com> (raw)
In-Reply-To: <20181005094555.31177-3-wqu@suse.com>

On Fri, Oct 5, 2018 at 10:46 AM Qu Wenruo <wqu@suse.com> wrote:
>
> Add extra dev extent end check against device boundary.
>
> Signed-off-by: Qu Wenruo <wqu@suse.com>
> ---
>  fs/btrfs/volumes.c | 17 +++++++++++++++++
>  1 file changed, 17 insertions(+)
>
> diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
> index bf0b2c16847a..bc3ac4715694 100644
> --- a/fs/btrfs/volumes.c
> +++ b/fs/btrfs/volumes.c
> @@ -7371,6 +7371,7 @@ static int verify_one_dev_extent(struct btrfs_fs_info *fs_info,
>         struct extent_map_tree *em_tree = &fs_info->mapping_tree.map_tree;
>         struct extent_map *em;
>         struct map_lookup *map;
> +       struct btrfs_device *dev;
>         u64 stripe_len;
>         bool found = false;
>         int ret = 0;
> @@ -7420,6 +7421,22 @@ static int verify_one_dev_extent(struct btrfs_fs_info *fs_info,
>                         physical_offset, devid);
>                 ret = -EUCLEAN;
>         }
> +
> +       /* Make sure no dev extent is beyond device bondary */
> +       dev = btrfs_find_device(fs_info, devid, NULL, NULL);

Qu,

This breaks use cases including seed devices. In those cases we need
to find a device by ID and FSID (not not return the first device we
find with a specific ID, ignoring the FSID).
Fstest btrfs/163 now fails in 5.0-rc1 because of this change.

Thanks.

> +       if (!dev) {
> +               btrfs_err(fs_info, "failed to find devid %llu", devid);
> +               ret = -EUCLEAN;
> +               goto out;
> +       }
> +       if (physical_offset + physical_len > dev->disk_total_bytes) {
> +               btrfs_err(fs_info,
> +"dev extent devid %llu physical offset %llu len %llu is beyond device boundary %llu",
> +                         devid, physical_offset, physical_len,
> +                         dev->disk_total_bytes);
> +               ret = -EUCLEAN;
> +               goto out;
> +       }
>  out:
>         free_extent_map(em);
>         return ret;
> --
> 2.19.0
>


-- 
Filipe David Manana,

“Whether you think you can, or you think you can't — you're right.”

  reply	other threads:[~2019-01-07 16:27 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-05  9:45 [PATCH v2 0/2] Enhance btrfs_verify_dev_extents() to do more checks on dev extents Qu Wenruo
2018-10-05  9:45 ` [PATCH v2 1/2] btrfs: volumes: Make sure there is no overlap dev extents at mount time Qu Wenruo
2018-10-05  9:45 ` [PATCH v2 2/2] btrfs: volumes: Make sure no dev extent is beyond device boundary Qu Wenruo
2019-01-07 16:27   ` Filipe Manana [this message]
2018-11-05 15:15 ` [PATCH v2 0/2] Enhance btrfs_verify_dev_extents() to do more checks on dev extents David Sterba

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=CAL3q7H4-YsT4n663XNTzFa9hUnmRWUPzgvovP-GcYnkA6cKHWw@mail.gmail.com \
    --to=fdmanana@gmail.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=wqu@suse.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 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.