Linux Btrfs filesystem development
 help / color / mirror / Atom feed
* [PATCH] btrfs: fix off-by-one end offset check in report_setget_bounds()
@ 2026-09-30 15:19 fdmanana
  2026-09-30 17:33 ` Daniel Vacek
  2026-09-30 21:44 ` Qu Wenruo
  0 siblings, 2 replies; 3+ messages in thread
From: fdmanana @ 2026-09-30 15:19 UTC (permalink / raw)
  To: linux-btrfs

From: Filipe Manana <fdmanana@suse.com>

The addressable range with an extent buffer goes from byte 0 to byte
eb->len - 1, so if a byte address matches eb->len, it's already beyond
the addressable range and we should log that it's bad start address
and not end address.

Fixes: 234fdd2815ce ("btrfs: remove redundant check in up check_setget_bounds")
Signed-off-by: Filipe Manana <fdmanana@suse.com>
---
 fs/btrfs/accessors.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/btrfs/accessors.c b/fs/btrfs/accessors.c
index 1248aa2535d3..d63ac6eb92de 100644
--- a/fs/btrfs/accessors.c
+++ b/fs/btrfs/accessors.c
@@ -16,7 +16,7 @@ static void __cold report_setget_bounds(const struct extent_buffer *eb,
 
 	btrfs_warn(eb->fs_info,
 		   "bad eb member %s: ptr 0x%lx start %llu member offset %lu size %d",
-		   (member_offset > eb->len ? "start" : "end"),
+		   (member_offset >= eb->len ? "start" : "end"),
 		   (unsigned long)ptr, eb->start, member_offset, size);
 }
 
-- 
2.47.2


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] btrfs: fix off-by-one end offset check in report_setget_bounds()
  2026-09-30 15:19 [PATCH] btrfs: fix off-by-one end offset check in report_setget_bounds() fdmanana
@ 2026-09-30 17:33 ` Daniel Vacek
  2026-09-30 21:44 ` Qu Wenruo
  1 sibling, 0 replies; 3+ messages in thread
From: Daniel Vacek @ 2026-09-30 17:33 UTC (permalink / raw)
  To: fdmanana; +Cc: linux-btrfs

On Wed, 30 Sept 2026 at 17:20, <fdmanana@kernel.org> wrote:
> From: Filipe Manana <fdmanana@suse.com>
>
> The addressable range with an extent buffer goes from byte 0 to byte
> eb->len - 1, so if a byte address matches eb->len, it's already beyond
> the addressable range and we should log that it's bad start address
> and not end address.
>
> Fixes: 234fdd2815ce ("btrfs: remove redundant check in up check_setget_bounds")
> Signed-off-by: Filipe Manana <fdmanana@suse.com>

I agree, looks good to me.

Reviewed-by: Daniel Vacek <neelx@suse.com>

> ---
>  fs/btrfs/accessors.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/btrfs/accessors.c b/fs/btrfs/accessors.c
> index 1248aa2535d3..d63ac6eb92de 100644
> --- a/fs/btrfs/accessors.c
> +++ b/fs/btrfs/accessors.c
> @@ -16,7 +16,7 @@ static void __cold report_setget_bounds(const struct extent_buffer *eb,
>
>         btrfs_warn(eb->fs_info,
>                    "bad eb member %s: ptr 0x%lx start %llu member offset %lu size %d",
> -                  (member_offset > eb->len ? "start" : "end"),
> +                  (member_offset >= eb->len ? "start" : "end"),
>                    (unsigned long)ptr, eb->start, member_offset, size);
>  }
>
> --
> 2.47.2
>
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] btrfs: fix off-by-one end offset check in report_setget_bounds()
  2026-09-30 15:19 [PATCH] btrfs: fix off-by-one end offset check in report_setget_bounds() fdmanana
  2026-09-30 17:33 ` Daniel Vacek
@ 2026-09-30 21:44 ` Qu Wenruo
  1 sibling, 0 replies; 3+ messages in thread
From: Qu Wenruo @ 2026-09-30 21:44 UTC (permalink / raw)
  To: fdmanana, linux-btrfs



在 2026/10/1 00:49, fdmanana@kernel.org 写道:
> From: Filipe Manana <fdmanana@suse.com>
> 
> The addressable range with an extent buffer goes from byte 0 to byte
> eb->len - 1, so if a byte address matches eb->len, it's already beyond
> the addressable range and we should log that it's bad start address
> and not end address.
> 
> Fixes: 234fdd2815ce ("btrfs: remove redundant check in up check_setget_bounds")
> Signed-off-by: Filipe Manana <fdmanana@suse.com>

Reviewed-by: Qu Wenruo <wqu@suse.com>

Thanks,
Qu

> ---
>   fs/btrfs/accessors.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/btrfs/accessors.c b/fs/btrfs/accessors.c
> index 1248aa2535d3..d63ac6eb92de 100644
> --- a/fs/btrfs/accessors.c
> +++ b/fs/btrfs/accessors.c
> @@ -16,7 +16,7 @@ static void __cold report_setget_bounds(const struct extent_buffer *eb,
>   
>   	btrfs_warn(eb->fs_info,
>   		   "bad eb member %s: ptr 0x%lx start %llu member offset %lu size %d",
> -		   (member_offset > eb->len ? "start" : "end"),
> +		   (member_offset >= eb->len ? "start" : "end"),
>   		   (unsigned long)ptr, eb->start, member_offset, size);
>   }
>   


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-09-30 21:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-30 15:19 [PATCH] btrfs: fix off-by-one end offset check in report_setget_bounds() fdmanana
2026-09-30 17:33 ` Daniel Vacek
2026-09-30 21:44 ` Qu Wenruo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox