Skip to contentSkip to conversation

fix (latent?) memory corruption in btrfs_encode_fh()

PATCH New Jan Beulich 1 participant 1 message Oct 7, 2010 Btrfs file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fix (latent?) memory corruption in btrfs_encode_fh()

The earlier checks only cover the two smaller cases, and hence if the caller specified size is less than what's needed to fit parent_root_objectid unrelated memory may get overwritten.

---
 fs/btrfs/export.c |    2 ++
 1 file changed, 2 insertions(+)
fs/btrfs/export.c +2 -0
@@ -46,6 +46,8 @@ static int btrfs_encode_fh(struct dentry
 		spin_unlock(&dentry->d_lock);
 
 		if (parent_root_id != fid->root_objectid) {
+			if (*max_len < BTRFS_FID_SIZE_CONNECTABLE_ROOT)
+				return 255;
 			fid->parent_root_objectid = parent_root_id;
 			len = BTRFS_FID_SIZE_CONNECTABLE_ROOT;
 			type = FILEID_BTRFS_WITH_PARENT_ROOT;