diff mbox series

[03/21] btrfs: Add start < end check in btrfs_debug_check_extent_io_range()

Message ID 37fd374e88730196100116cc237f637cd6a8962a.1677793433.git.rgoldwyn@suse.com (mailing list archive)
State New, archived
Headers show
Series Lock extents before pages | expand

Commit Message

Goldwyn Rodrigues March 2, 2023, 10:24 p.m. UTC
From: Goldwyn Rodrigues <rgoldwyn@suse.com>

For issues such as zero size writes, we can get start > end. Check them
in btrfs_debug_check_extent_io_range() so this may be caught early.

Signed-off-by: Goldwyn Rodrigues <rgoldwyn@suse.com>
---
 fs/btrfs/extent-io-tree.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Boris Burkov March 8, 2023, 7:29 p.m. UTC | #1
On Thu, Mar 02, 2023 at 04:24:48PM -0600, Goldwyn Rodrigues wrote:
> From: Goldwyn Rodrigues <rgoldwyn@suse.com>
> 
> For issues such as zero size writes, we can get start > end. Check them
> in btrfs_debug_check_extent_io_range() so this may be caught early.
> 
> Signed-off-by: Goldwyn Rodrigues <rgoldwyn@suse.com>

Reviewed-by: Boris Burkov <boris@bur.io>

> ---
>  fs/btrfs/extent-io-tree.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/btrfs/extent-io-tree.c b/fs/btrfs/extent-io-tree.c
> index 482721dd1eba..d467c614c84e 100644
> --- a/fs/btrfs/extent-io-tree.c
> +++ b/fs/btrfs/extent-io-tree.c
> @@ -65,7 +65,8 @@ static inline void __btrfs_debug_check_extent_io_range(const char *caller,
>  		return;
>  
>  	isize = i_size_read(&inode->vfs_inode);
> -	if (end >= PAGE_SIZE && (end % 2) == 0 && end != isize - 1) {
> +	if ((start > end) ||
> +	    (end >= PAGE_SIZE && (end % 2) == 0 && end != isize - 1)) {
>  		btrfs_debug_rl(inode->root->fs_info,
>  		    "%s: ino %llu isize %llu odd range [%llu,%llu]",
>  			caller, btrfs_ino(inode), isize, start, end);
> -- 
> 2.39.2
>
diff mbox series

Patch

diff --git a/fs/btrfs/extent-io-tree.c b/fs/btrfs/extent-io-tree.c
index 482721dd1eba..d467c614c84e 100644
--- a/fs/btrfs/extent-io-tree.c
+++ b/fs/btrfs/extent-io-tree.c
@@ -65,7 +65,8 @@  static inline void __btrfs_debug_check_extent_io_range(const char *caller,
 		return;
 
 	isize = i_size_read(&inode->vfs_inode);
-	if (end >= PAGE_SIZE && (end % 2) == 0 && end != isize - 1) {
+	if ((start > end) ||
+	    (end >= PAGE_SIZE && (end % 2) == 0 && end != isize - 1)) {
 		btrfs_debug_rl(inode->root->fs_info,
 		    "%s: ino %llu isize %llu odd range [%llu,%llu]",
 			caller, btrfs_ino(inode), isize, start, end);