Skip to content

Commit

Permalink
btrfs: send: handle path ref underflow in header iterate_inode_ref()
Browse files Browse the repository at this point in the history
[ Upstream commit 3c6ee34 ]

Change BUG_ON to proper error handling if building the path buffer
fails. The pointers are not printed so we don't accidentally leak kernel
addresses.

Signed-off-by: David Sterba <dsterba@suse.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
kdave authored and gregkh committed Apr 13, 2024
1 parent 484cb95 commit 0393861
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion fs/btrfs/send.c
Expand Up @@ -1070,7 +1070,15 @@ static int iterate_inode_ref(struct btrfs_root *root, struct btrfs_path *path,
ret = PTR_ERR(start);
goto out;
}
BUG_ON(start < p->buf);
if (unlikely(start < p->buf)) {
btrfs_err(root->fs_info,
"send: path ref buffer underflow for key (%llu %u %llu)",
found_key->objectid,
found_key->type,
found_key->offset);
ret = -EINVAL;
goto out;
}
}
p->start = start;
} else {
Expand Down

0 comments on commit 0393861

Please sign in to comment.