bcachefs: Fix some memcpy() warnings
authorKent Overstreet <kent.overstreet@linux.dev>
Wed, 28 Dec 2022 20:17:07 +0000 (15:17 -0500)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 22 Oct 2023 21:09:48 +0000 (17:09 -0400)
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>
fs/bcachefs/buckets.c

index 49cb2589f47cb5d7a670835919867d7052a49f77..137a9aef69875ddfc5bd7d6217f359a0447eec60 100644 (file)
@@ -156,7 +156,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));