From patchwork Tue Jan 24 11:32:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Potapenko X-Patchwork-Id: 47671 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2096757wrn; Tue, 24 Jan 2023 03:33:53 -0800 (PST) X-Google-Smtp-Source: AMrXdXuMCTVnvav1LYWEPbYph0VQQcK7PVPovtUt6rKFmxwMXHYBbq6i7VHhfuFldZbMBArVXpGt X-Received: by 2002:a17:907:c609:b0:862:c1d5:ea1b with SMTP id ud9-20020a170907c60900b00862c1d5ea1bmr32179683ejc.8.1674560032858; Tue, 24 Jan 2023 03:33:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674560032; cv=none; d=google.com; s=arc-20160816; b=MTGFDfwTPfUOL6pmKsckQ4nrQzGaj+pe8jfyFljhdLKwC4CuU66mpkfIxDvaWYCx+A g0Y8AN+J5oFOHug6+wpA+Cecjck8PIO/Cj2c+gFCAHo5MB3U5NsCIPASuUZAyZIbqUd0 4PlavbHdFVbAF4aU4bSf2LMfpjPMbVytv/GB3XvnOVyyazxXD7v3FVWlVeHidf07Kqrz Yw4+igCiie09WhAbaj/zz9IaRYuxU9JT+BLz0z6bgCQ8Lt9HkMPV7OdkfOrfC5kruGIi GL0tuMdIYt7B+JwQFNRC8QcRdEoy0nPhpuFpYDwdbe+mu0fZRnw3onhTU0vVJylLciOA PYVQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:mime-version:date :dkim-signature; bh=eUs+oxPX+Th3wCoMo6p6epBi5r7JS+DC4cGwD7gny+c=; b=DODrrHxs2LcLASMlUUNT8jRh/KbqNtUh6149CAiGoU8kRMV7xUqOIVMFcqcgDTkQs0 vnkWfIHM2CkbTOTEOKXIFejbYxCuNl6OrGcE5gxrMD8lLM0pcQAB22L8vDeXOnpogq4r Mq9k0c8nYj/+XaPWry/r67rA5CEj1c5lbyiKQ2haJOyrVGarGwbrGm7ArWLqnyQGSoiN 2DAlAfZX1Kdl8PEmW8/I1Diq1w1mcxieB9+kAN4LCVMwsmjn59mvYiTCXdanZqJgnZxk uD8ULydQ1uIjXTRqd+vz11Md7epI/15hleHgynw04Jtc95PlyPfSVt83U4YLqZCBZ3In b/lQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b="CqGd/97P"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ep16-20020a1709069b5000b0086d9b57a751si2091273ejc.270.2023.01.24.03.33.29; Tue, 24 Jan 2023 03:33:52 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b="CqGd/97P"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234099AbjAXLcr (ORCPT + 99 others); Tue, 24 Jan 2023 06:32:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58212 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234101AbjAXLcp (ORCPT ); Tue, 24 Jan 2023 06:32:45 -0500 Received: from mail-ed1-x549.google.com (mail-ed1-x549.google.com [IPv6:2a00:1450:4864:20::549]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ADCA13EC61 for ; Tue, 24 Jan 2023 03:32:41 -0800 (PST) Received: by mail-ed1-x549.google.com with SMTP id y21-20020a056402359500b0049e171c4ad0so10411563edc.6 for ; Tue, 24 Jan 2023 03:32:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=eUs+oxPX+Th3wCoMo6p6epBi5r7JS+DC4cGwD7gny+c=; b=CqGd/97PcLQj91KKCP5sxd4iglhV1eOb7dm0qEy1kEmbfQ9dWO/BilGXTlraPVU/uo 8qVKcb+sPAZUz5xOgKIa8tqZcq9ak5jafw0trh0fnw2+7H5ymJnBuBw8kJfjeRVRG4VP RiWvT1jniMcwmDlrK9v0dqfsVJOfnFcJB+PvBMXGMGisiwZzxRtzvJL+lkIIh76o5joG cyWQhxAKNfEW8OSBUCiXWoOYRJ+k76EgWktoj1igjFT+++pLILH6yGzoIVZMHLcJIjCG Vl57c4dYpI7JkJH/Sh2ILc8hmtPb+3gyWYt+tC54dYHroPPOyPo4CWmLj0hAQkYO8u/+ ST3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=eUs+oxPX+Th3wCoMo6p6epBi5r7JS+DC4cGwD7gny+c=; b=etBVYzDMCaSWKYo3VRWMXOlzTamqPr1hu7u5po0IdmY5fQsFBGfCzc12WYHAOAf6vI SV3fgaqAMhPRm92Go6DHSvT0DlBNrJ957d3NXMgie8Ffc0UxVA+E5RYKzM2O0h5Qmwp6 sV57uy7mT8JvkMdRHh5dLi0ywv/WvAjLx2GozJ0pdnBvxxrzZSnHp4d2wbTYgq9lTRGy 0G5TJ8HypXVBrqOgQTGVOm0rtOeyuofUnkFrE6pvI4Z0lGIclT245tAoYEH515Le7UzR yj0KXPN9WyyJtG+Lebmv4acGd/p4YgNZRZCEZglEgA8ugYRdHEvnk4oG48ROme1YE9uL ZgZA== X-Gm-Message-State: AFqh2kqq5rwy5lEO5G0KuRVReWP/44z2efiTT2BezG77p/m6h14tqNaI Ug2NXQ0owRx9EUn+y9ZjJpRl2MHer7M= X-Received: from glider.muc.corp.google.com ([2a00:79e0:9c:201:21dc:97d0:ed7:bbcd]) (user=glider job=sendgmr) by 2002:a05:6402:d2:b0:48e:bad6:720c with SMTP id i18-20020a05640200d200b0048ebad6720cmr3152609edu.2.1674559959884; Tue, 24 Jan 2023 03:32:39 -0800 (PST) Date: Tue, 24 Jan 2023 12:32:34 +0100 Mime-Version: 1.0 X-Mailer: git-send-email 2.39.0.246.g2a6d74b583-goog Message-ID: <20230124113234.2070729-1-glider@google.com> Subject: [PATCH] btrfs: zlib: zero-initialize zlib workspace From: Alexander Potapenko To: glider@google.com Cc: clm@fb.com, dsterba@suse.com, josef@toxicpanda.com, linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org, ebiggers@kernel.org, syzbot+14d9e7602ebdf7ec0a60@syzkaller.appspotmail.com X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1755903461158834341?= X-GMAIL-MSGID: =?utf-8?q?1755903461158834341?= 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 Signed-off-by: Alexander Potapenko --- fs/btrfs/zlib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/btrfs/zlib.c b/fs/btrfs/zlib.c index 01a13de118320..da7bb9187b68a 100644 --- a/fs/btrfs/zlib.c +++ b/fs/btrfs/zlib.c @@ -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; /*