1 From e12129979dea129e7f04a91533e4109b6cbbe40a Mon Sep 17 00:00:00 2001
2 From: Sasha Levin <sashal@kernel.org>
3 Date: Tue, 6 Feb 2024 22:47:13 +0100
4 Subject: btrfs: send: handle path ref underflow in header iterate_inode_ref()
6 From: David Sterba <dsterba@suse.com>
8 [ Upstream commit 3c6ee34c6f9cd12802326da26631232a61743501 ]
10 Change BUG_ON to proper error handling if building the path buffer
11 fails. The pointers are not printed so we don't accidentally leak kernel
14 Signed-off-by: David Sterba <dsterba@suse.com>
15 Signed-off-by: Sasha Levin <sashal@kernel.org>
17 fs/btrfs/send.c | 10 +++++++++-
18 1 file changed, 9 insertions(+), 1 deletion(-)
20 diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c
21 index 9900f879fa346..f1ef176a64242 100644
24 @@ -976,7 +976,15 @@ static int iterate_inode_ref(struct btrfs_root *root, struct btrfs_path *path,
28 - BUG_ON(start < p->buf);
29 + if (unlikely(start < p->buf)) {
30 + btrfs_err(root->fs_info,
31 + "send: path ref buffer underflow for key (%llu %u %llu)",
32 + found_key->objectid,