summaryrefslogtreecommitdiff
path: root/fs
diff options
context:
space:
mode:
authorDavid Sterba <dsterba@suse.com>2024-02-07 00:47:13 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2024-04-13 14:10:02 +0300
commit03938619a1e718b6168ae4528e1b0f979293f1a5 (patch)
tree5991848568a1d4fb3c0451da2c0830f04b8909f6 /fs
parent484cb9563c0080932358c2e06901378e8af46056 (diff)
downloadlinux-03938619a1e718b6168ae4528e1b0f979293f1a5.tar.xz
btrfs: send: handle path ref underflow in header iterate_inode_ref()
[ Upstream commit 3c6ee34c6f9cd12802326da26631232a61743501 ] 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>
Diffstat (limited to 'fs')
-rw-r--r--fs/btrfs/send.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c
index e9516509b276..e8187669153d 100644
--- a/fs/btrfs/send.c
+++ b/fs/btrfs/send.c
@@ -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 {