summaryrefslogtreecommitdiffstats
path: root/fs/bcachefs/snapshot.c
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@linux.dev>2024-02-24 07:18:45 +0100
committerKent Overstreet <kent.overstreet@linux.dev>2024-02-25 02:47:47 +0100
commitc4333eb541b92d91be57f757dccf6d4368516746 (patch)
treed18a2d02477c15b7ab2b036782e8233b29226cbf /fs/bcachefs/snapshot.c
parentbcachefs: Fix bch2_journal_flush_device_pins() (diff)
downloadlinux-c4333eb541b92d91be57f757dccf6d4368516746.tar.xz
linux-c4333eb541b92d91be57f757dccf6d4368516746.zip
bcachefs: Fix check_snapshot() memcpy
check_snapshot() copies the bch_snapshot to a temporary to easily handle older versions that don't have all the fields of the current version, but it lacked a min() to correctly handle keys newer and larger than the current version. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to '')
-rw-r--r--fs/bcachefs/snapshot.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/fs/bcachefs/snapshot.c b/fs/bcachefs/snapshot.c
index 45f67e8b29eb..ac6ba04d5521 100644
--- a/fs/bcachefs/snapshot.c
+++ b/fs/bcachefs/snapshot.c
@@ -728,7 +728,7 @@ static int check_snapshot(struct btree_trans *trans,
return 0;
memset(&s, 0, sizeof(s));
- memcpy(&s, k.v, bkey_val_bytes(k.k));
+ memcpy(&s, k.v, min(sizeof(s), bkey_val_bytes(k.k)));
id = le32_to_cpu(s.parent);
if (id) {