summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Sterba <dsterba@suse.com>2016-11-07 13:58:51 +0100
committerDavid Sterba <dsterba@suse.com>2016-11-09 13:47:35 +0100
commit92847b5cd68d601b5ebadb74d17985b6421960bc (patch)
tree7b0b53e082227a8b5f7a4f3fa78ec39b1226e87b
parent0bd0d9c062d1b02978161c356057122c865f5ad0 (diff)
btrfs-progs: crc32: use fallback implementation for unaligned buffers
ASAN reports that at some point the crc function gets an unaligned buffer. It's the optimized intel version that casts char to ulong, the buffer is the embedded filename in the directory items. Signed-off-by: David Sterba <dsterba@suse.com>
-rw-r--r--kernel-lib/crc32c.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/kernel-lib/crc32c.c b/kernel-lib/crc32c.c
index dfa4e6c1..29fd01d4 100644
--- a/kernel-lib/crc32c.c
+++ b/kernel-lib/crc32c.c
@@ -218,5 +218,9 @@ u32 __crc32c_le(u32 crc, unsigned char const *data, size_t length)
u32 crc32c_le(u32 crc, unsigned char const *data, size_t length)
{
+ /* Use by-byte access for unaligned buffers */
+ if ((unsigned long)data % sizeof(unsigned long))
+ return __crc32c_le(crc, data, length);
+
return crc_function(crc, data, length);
}