Subject: [PATCH 2/3 v2] Prevent attempt to insert extent record with max_size==0
diff mbox

Message ID 74CAC383-4C3A-4C68-9B56-2AB28947E3E3@redhat.com
State New
Headers show

Commit Message

Christophe de Dinechin April 28, 2017, 9:50 a.m. UTC
When this happens, we will trip a BUG_ON(end < start) in insert_state
because in check_extent_refs, we use this max_size expecting it's not zero:

  set_extent_dirty(root->fs_info->excluded_extents,
                   rec->start,
                   rec->start + rec->max_size - 1);

See https://bugzilla.redhat.com/show_bug.cgi?id=1435567
for an example where this scenario occurs.

Signed-off-by: Christophe de Dinechin <dinechin@redhat.com>
---
 cmds-check.c | 1 +
 1 file changed, 1 insertion(+)

Comments

David Sterba May 2, 2017, 4:46 p.m. UTC | #1
On Fri, Apr 28, 2017 at 11:50:23AM +0200, Christophe de Dinechin wrote:
> When this happens, we will trip a BUG_ON(end < start) in insert_state
> because in check_extent_refs, we use this max_size expecting it's not zero:
> 
>   set_extent_dirty(root->fs_info->excluded_extents,
>                    rec->start,
>                    rec->start + rec->max_size - 1);
> 
> See https://bugzilla.redhat.com/show_bug.cgi?id=1435567
> for an example where this scenario occurs.
> 
> Signed-off-by: Christophe de Dinechin <dinechin@redhat.com>

Applied, thanks.
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch
diff mbox

diff --git a/cmds-check.c b/cmds-check.c
index 2d3ebc1..c13f900 100644
--- a/cmds-check.c
+++ b/cmds-check.c
@@ -6029,6 +6029,7 @@  static int add_extent_rec_nolookup(struct cache_tree *extent_cache,
 	struct extent_record *rec;
 	int ret = 0;
 
+	BUG_ON(tmpl->max_size == 0);
 	rec = malloc(sizeof(*rec));
 	if (!rec)
 		return -ENOMEM;