All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] check: check so offset is not bigger then the leaf
@ 2015-06-17 23:59 Robert Marklund
  2015-06-18 16:44 ` David Sterba
  0 siblings, 1 reply; 8+ messages in thread
From: Robert Marklund @ 2015-06-17 23:59 UTC (permalink / raw)
  To: linux-btrfs; +Cc: Robert Marklund

This could crash before because of dangerous dangling
offset of pointer.

Signed-off-by: Robert Marklund <robbelibobban@gmail.com>
---
 cmds-check.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/cmds-check.c b/cmds-check.c
index 778f141..da36758 100644
--- a/cmds-check.c
+++ b/cmds-check.c
@@ -8906,6 +8906,16 @@ static int build_roots_info_cache(struct btrfs_fs_info *info)
 			goto next;
 
 		ei = btrfs_item_ptr(leaf, slot, struct btrfs_extent_item);
+
+		if ((long long)ei > info->extent_root->leafsize) {
+			 fprintf(stderr, "Bad leaf = %p, slot = %d\n", leaf, slot);
+			 fprintf(stderr, "item ptr = %p\n", ei);
+			 fprintf(stderr, "objectid = %llx\n", found_key.objectid);
+			 fprintf(stderr, "type     = %x\n", found_key.type);
+			 fprintf(stderr, "offset   = %llx\n", found_key.offset);
+			 goto next;
+		}
+
 		flags = btrfs_extent_flags(leaf, ei);
 
 		if (found_key.type == BTRFS_EXTENT_ITEM_KEY &&
-- 
2.1.0


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

end of thread, other threads:[~2015-07-01 13:26 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-17 23:59 [PATCH] check: check so offset is not bigger then the leaf Robert Marklund
2015-06-18 16:44 ` David Sterba
2015-06-18 17:16   ` Josef Bacik
2015-06-25 16:06     ` David Sterba
2015-06-25 16:24       ` Josef Bacik
2015-06-25 16:49         ` David Sterba
2015-06-29 11:16   ` Trollkarlen Marklund
2015-07-01 13:26     ` David Sterba

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.