diff mbox series

btrfs: tree-checker: add missing returns after data_ref alignment checks

Message ID 20201120155558.29684-1-dsterba@suse.com (mailing list archive)
State New, archived
Headers show
Series btrfs: tree-checker: add missing returns after data_ref alignment checks | expand

Commit Message

David Sterba Nov. 20, 2020, 3:55 p.m. UTC
There are sectorsize alignment checks that are reported but then
check_extent_data_ref continues. This was not intended, wrong alignment
is not a minor problem and we should return with error.

CC: stable@vger.kernel.org # 5.4+
Fixes: 0785a9aacf9d ("btrfs: tree-checker: Add EXTENT_DATA_REF check")
Signed-off-by: David Sterba <dsterba@suse.com>
---
 fs/btrfs/tree-checker.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Qu Wenruo Nov. 20, 2020, 10:51 p.m. UTC | #1
On 2020/11/20 下午11:55, David Sterba wrote:
> There are sectorsize alignment checks that are reported but then
> check_extent_data_ref continues. This was not intended, wrong alignment
> is not a minor problem and we should return with error.
> 
> CC: stable@vger.kernel.org # 5.4+
> Fixes: 0785a9aacf9d ("btrfs: tree-checker: Add EXTENT_DATA_REF check")
> Signed-off-by: David Sterba <dsterba@suse.com>

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

Thanks,
Qu
> ---
>  fs/btrfs/tree-checker.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/fs/btrfs/tree-checker.c b/fs/btrfs/tree-checker.c
> index 1b27242a9c0b..f3f666b343ef 100644
> --- a/fs/btrfs/tree-checker.c
> +++ b/fs/btrfs/tree-checker.c
> @@ -1424,6 +1424,7 @@ static int check_extent_data_ref(struct extent_buffer *leaf,
>  	"invalid item size, have %u expect aligned to %zu for key type %u",
>  			    btrfs_item_size_nr(leaf, slot),
>  			    sizeof(*dref), key->type);
> +		return -EUCLEAN;
>  	}
>  	if (!IS_ALIGNED(key->objectid, leaf->fs_info->sectorsize)) {
>  		generic_err(leaf, slot,
> @@ -1452,6 +1453,7 @@ static int check_extent_data_ref(struct extent_buffer *leaf,
>  			extent_err(leaf, slot,
>  	"invalid extent data backref offset, have %llu expect aligned to %u",
>  				   offset, leaf->fs_info->sectorsize);
> +			return -EUCLEAN;
>  		}
>  	}
>  	return 0;
>
diff mbox series

Patch

diff --git a/fs/btrfs/tree-checker.c b/fs/btrfs/tree-checker.c
index 1b27242a9c0b..f3f666b343ef 100644
--- a/fs/btrfs/tree-checker.c
+++ b/fs/btrfs/tree-checker.c
@@ -1424,6 +1424,7 @@  static int check_extent_data_ref(struct extent_buffer *leaf,
 	"invalid item size, have %u expect aligned to %zu for key type %u",
 			    btrfs_item_size_nr(leaf, slot),
 			    sizeof(*dref), key->type);
+		return -EUCLEAN;
 	}
 	if (!IS_ALIGNED(key->objectid, leaf->fs_info->sectorsize)) {
 		generic_err(leaf, slot,
@@ -1452,6 +1453,7 @@  static int check_extent_data_ref(struct extent_buffer *leaf,
 			extent_err(leaf, slot,
 	"invalid extent data backref offset, have %llu expect aligned to %u",
 				   offset, leaf->fs_info->sectorsize);
+			return -EUCLEAN;
 		}
 	}
 	return 0;