Re: [syzbot] Re: KMSAN: uninit-value in __crc32c_le_base
From: syzbot
Date: Fri Nov 15 2024 - 10:22:01 EST
For archival purposes, forwarding an incoming command email to
linux-kernel@xxxxxxxxxxxxxxx, syzkaller-bugs@xxxxxxxxxxxxxxxx.
***
Subject: Re: KMSAN: uninit-value in __crc32c_le_base
Author: dmantipov@xxxxxxxxx
#syz test https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git cfaaa7d010d1fc58f9717fcc8591201e741d2d49
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index b11bfe68dd65..e0b515aa1c63 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -18,6 +18,9 @@
#include <linux/crc32c.h>
#include <linux/sched/mm.h>
#include <linux/unaligned.h>
+#ifdef CONFIG_KMSAN
+#include <linux/kmsan-checks.h>
+#endif
#include <crypto/hash.h>
#include "ctree.h"
#include "disk-io.h"
@@ -93,6 +96,10 @@ static void csum_tree_block(struct extent_buffer *buf, u8 *result)
num_pages = num_extent_pages(buf);
}
+#ifdef CONFIG_KMSAN
+ kmsan_unpoison_memory(kaddr + BTRFS_CSUM_SIZE,
+ first_page_part - BTRFS_CSUM_SIZE);
+#endif
crypto_shash_update(shash, kaddr + BTRFS_CSUM_SIZE,
first_page_part - BTRFS_CSUM_SIZE);
@@ -104,6 +111,9 @@ static void csum_tree_block(struct extent_buffer *buf, u8 *result)
*/
for (i = 1; i < num_pages && INLINE_EXTENT_BUFFER_PAGES > 1; i++) {
kaddr = folio_address(buf->folios[i]);
+#ifdef CONFIG_KMSAN
+ kmsan_unpoison_memory(kaddr, PAGE_SIZE);
+#endif
crypto_shash_update(shash, kaddr, PAGE_SIZE);
}
memset(result, 0, BTRFS_CSUM_SIZE);