From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6202D8F57 for ; Mon, 13 Feb 2023 14:57:31 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DC4ADC4339E; Mon, 13 Feb 2023 14:57:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1676300251; bh=r/OMLJzhlrHg+5uzhwT/c328dR87L/lltmas73C3t4o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Q/4I7nh840XHUEBNEva4nJypFa7KiwhQdu4w17skYHLiaBluCkXmPUSNPsuglSqiF VBkebDICSguUVvXQ+KvebcjsTcSpYpZlNH00uDIDyu15BiI3yCCoO8UjLIUAKsiQAT OaiKOQHCbqflwQj9HINlN8Jjs6rbu8c3XeHugy78= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, syzbot+14d9e7602ebdf7ec0a60@syzkaller.appspotmail.com, Alexander Potapenko , David Sterba Subject: [PATCH 5.15 07/67] btrfs: zlib: zero-initialize zlib workspace Date: Mon, 13 Feb 2023 15:48:48 +0100 Message-Id: <20230213144732.658331810@linuxfoundation.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230213144732.336342050@linuxfoundation.org> References: <20230213144732.336342050@linuxfoundation.org> User-Agent: quilt/0.67 Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Alexander Potapenko commit eadd7deca0ad8a83edb2b894d8326c78e78635d6 upstream. 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. Link: https://zlib.net/zlib_faq.html#faq36 Reported-by: syzbot+14d9e7602ebdf7ec0a60@syzkaller.appspotmail.com CC: stable@vger.kernel.org # 5.4+ Signed-off-by: Alexander Potapenko Reviewed-by: David Sterba Signed-off-by: David Sterba Signed-off-by: Greg Kroah-Hartman --- fs/btrfs/zlib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/fs/btrfs/zlib.c +++ b/fs/btrfs/zlib.c @@ -63,7 +63,7 @@ struct list_head *zlib_alloc_workspace(u 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; /*