Skip to contentSkip to conversation

btrfs: zlib: zero-initialize zlib workspace

PATCH In review Alexander Potapenko 2 participants 2 messages Jan 24, 2023 Btrfs file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 btrfs: zlib: zero-initialize zlib workspace

KMSAN reports uses of uninitialized memory in zlib's longest_match() called on memory originating from zlib_alloc_workspace(). This issue is known by zlib maintainers and is claimed to be harmless, but to be on the safe side we'd better initialize the memory.

---
 fs/btrfs/zlib.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/btrfs/zlib.c +1 -1
index 01a13de118320..da7bb9187b68a 100644
@@ -63,7 +63,7 @@ struct list_head *zlib_alloc_workspace(unsigned int level)
 
 	workspacesize = max(zlib_deflate_workspacesize(MAX_WBITS, MAX_MEM_LEVEL),
 			zlib_inflate_workspacesize());
-	workspace->strm.workspace = kvmalloc(workspacesize, GFP_KERNEL);
+	workspace->strm.workspace = kvzalloc(workspacesize, GFP_KERNEL);
 	workspace->level = level;
 	workspace->buf = NULL;
 	/*
Signature · 1 line
2.39.0.246.g2a6d74b583-goog