summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@linux.dev>2022-12-28 15:17:07 -0500
committerKent Overstreet <kent.overstreet@linux.dev>2023-01-06 19:48:02 -0500
commite06dd7096aa64cd599887b383a6dc815cdc4a26b (patch)
tree82d8624c66bf48aeea270bb4f76f8d1db05eb190
parent06c1aeca3373a9d522d5ed17b469c3cc9fe10b67 (diff)
bcachefs: Fix some memcpy() warnings
With CONFIG_FORTIFY_SOURCE, the compiler attempts to warn about mempcys that extend past struct field boundaries. This results in some spurious warnings where we use embedded variable length structs, this patch switches to unsafe_mecpy() to fix the warnings. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
-rw-r--r--fs/bcachefs/buckets.c3
-rw-r--r--fs/bcachefs/journal_io.c2
2 files changed, 3 insertions, 2 deletions
diff --git a/fs/bcachefs/buckets.c b/fs/bcachefs/buckets.c
index a33a4700f4f2..89ce7fadd5f3 100644
--- a/fs/bcachefs/buckets.c
+++ b/fs/bcachefs/buckets.c
@@ -157,7 +157,8 @@ retry:
do {
seq = read_seqcount_begin(&c->usage_lock);
- memcpy(&ret->u, c->usage_base, u64s * sizeof(u64));
+ unsafe_memcpy(&ret->u, c->usage_base, u64s * sizeof(u64),
+ "embedded variable length struct");
for (i = 0; i < ARRAY_SIZE(c->usage); i++)
acc_u64s_percpu((u64 *) &ret->u, (u64 __percpu *) c->usage[i], u64s);
} while (read_seqcount_retry(&c->usage_lock, seq));
diff --git a/fs/bcachefs/journal_io.c b/fs/bcachefs/journal_io.c
index ce54e1507f27..a2d837f9c35b 100644
--- a/fs/bcachefs/journal_io.c
+++ b/fs/bcachefs/journal_io.c
@@ -154,7 +154,7 @@ replace:
i->nr_ptrs = 0;
i->csum_good = entry_ptr.csum_good;
i->ignore = false;
- memcpy(&i->j, j, bytes);
+ unsafe_memcpy(&i->j, j, bytes, "embedded variable length struct");
i->ptrs[i->nr_ptrs++] = entry_ptr;
if (dup) {