summaryrefslogtreecommitdiff
path: root/drivers/md/bcache/bcache_ondisk.h
diff options
context:
space:
mode:
authorKees Cook <keescook@chromium.org>2023-01-06 09:02:33 +0300
committerKees Cook <keescook@chromium.org>2023-01-25 23:24:50 +0300
commitbe0d8f48ad97f5b775b0af3310343f676dbf318a (patch)
tree8c4851f5a035dc2a6f18df9438a57506358f9cde /drivers/md/bcache/bcache_ondisk.h
parente6a71160cc145e18ab45195abf89884112e02dfb (diff)
downloadlinux-be0d8f48ad97f5b775b0af3310343f676dbf318a.tar.xz
bcache: Silence memcpy() run-time false positive warnings
struct bkey has internal padding in a union, but it isn't always named the same (e.g. key ## _pad, key_p, etc). This makes it extremely hard for the compiler to reason about the available size of copies done against such keys. Use unsafe_memcpy() for now, to silence the many run-time false positive warnings: memcpy: detected field-spanning write (size 264) of single field "&i->j" at drivers/md/bcache/journal.c:152 (size 240) memcpy: detected field-spanning write (size 24) of single field "&b->key" at drivers/md/bcache/btree.c:939 (size 16) memcpy: detected field-spanning write (size 24) of single field "&temp.key" at drivers/md/bcache/extents.c:428 (size 16) Reported-by: Alexandre Pereira <alexpereira@disroot.org> Link: https://bugzilla.kernel.org/show_bug.cgi?id=216785 Acked-by: Coly Li <colyli@suse.de> Cc: Kent Overstreet <kent.overstreet@gmail.com> Cc: linux-bcache@vger.kernel.org Signed-off-by: Kees Cook <keescook@chromium.org> Link: https://lore.kernel.org/r/20230106060229.never.047-kees@kernel.org
Diffstat (limited to 'drivers/md/bcache/bcache_ondisk.h')
-rw-r--r--drivers/md/bcache/bcache_ondisk.h3
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/md/bcache/bcache_ondisk.h b/drivers/md/bcache/bcache_ondisk.h
index 97413586195b..f96034e0ba4f 100644
--- a/drivers/md/bcache/bcache_ondisk.h
+++ b/drivers/md/bcache/bcache_ondisk.h
@@ -106,7 +106,8 @@ static inline unsigned long bkey_bytes(const struct bkey *k)
return bkey_u64s(k) * sizeof(__u64);
}
-#define bkey_copy(_dest, _src) memcpy(_dest, _src, bkey_bytes(_src))
+#define bkey_copy(_dest, _src) unsafe_memcpy(_dest, _src, bkey_bytes(_src), \
+ /* bkey is always padded */)
static inline void bkey_copy_key(struct bkey *dest, const struct bkey *src)
{