Skip to contentSkip to conversation

Fix a sign bug causing invalid memory access in the ino_paths ioctl.

PATCH New Gabriel de Perthuis 1 participant 1 message Oct 10, 2012 Btrfs file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix a sign bug causing invalid memory access in the ino_paths ioctl.

To see the problem, create many hardlinks to the same file (120 should do it), then look up paths by inode with:

ls -i
btrfs inspect inode-resolve -v $ino /mnt/btrfs

I noticed the memory layout of the fspath->val data had some irregularities (some unnecessary gaps that stop appearing about halfway),
so I'm not sure there aren't any bugs left in it.

---
 fs/btrfs/backref.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/btrfs/backref.c +1 -1
index 868cf5b..29d05c6 100644
@@ -1131,7 +1131,7 @@ char *btrfs_iref_to_path(struct btrfs_root *fs_root, struct btrfs_path *path,
 	int slot;
 	u64 next_inum;
 	int ret;
-	s64 bytes_left = size - 1;
+	s64 bytes_left = ((s64)size) - 1;
 	struct extent_buffer *eb = eb_in;
 	struct btrfs_key found_key;
 	int leave_spinning = path->leave_spinning;
Signature · 1 line
1.7.12.117.gdc24c27