Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp6023244rwl; Mon, 9 Jan 2023 03:14:39 -0800 (PST) X-Google-Smtp-Source: AMrXdXsHiSfnWoXdGlyiJEOOtt3cRvUq05nLnSkDs5XHQ8u38rV9hjkYtdx5INGVgziAdIfJL22j X-Received: by 2002:a17:906:36c5:b0:829:594c:8ec8 with SMTP id b5-20020a17090636c500b00829594c8ec8mr50488260ejc.29.1673262878949; Mon, 09 Jan 2023 03:14:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673262878; cv=none; d=google.com; s=arc-20160816; b=VgW1iNhCAZS93Dy8LdSjMpoOGvzrQvwCey2KG0e+/O6dhsIbLVfHHzzwrHBQqNjwSW BdURq3If8pwQYlIyk3fWq26J0Gd0UnjknvnDLFNCefGdoVBYKG8kFRvDe+JbW9nr+A7p IXO9rqPmwmrmX7qtfKXYH/V06KZpAWkELkwdV/m/f/ouHQEWRHMBVmloym+H5+c4YVOa woYlI4CAfhDyj26vKPNhLFVKu5DyNc/59jeTyyRnfXC7Tv2Oyunn9Dj7UTdxIJobE3ja 7RJuyikZqSJ227F4VwvXsUPu+lM4+MlTSJn1GsvqGDKPIAd0K29K0caYjuqgngVARW+3 snoA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=e02TDcGy26XJeDkV+Zxe7xlFfptyfBN/NRLe+/gTE84=; b=y4es3Nc256/Q+LBcu4tj99xJ7lBfopuvKYViYxXBvSlXo6keLiN/rKVbVcFGmgvwY/ AkVdTkiAlmzmw/p+xRT0nGZ9lBVYmJnFW5bH8G1cIqRw3BdpP26Um6NO8tdnZcArjJSV yLHjCWzvau1AMPusLFCP1mFiJMlBsSXeTLHlo5hf5gM12+1/ld4GCgXC+1n7iQIlRoPP QJpbMb5H99u46+iDEVR079Cbl4ZGsQUKZ1XkDonlGf8x5//pjNyb7712U7YMcbCl0pRo LFLBF+5qYh9XtuLfl0y7YkHlBGtSLsKZHsQU+gYIm/tdZE88uwT8TvwHn1TQaw/c3QeD LEwQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="KLPEab//"; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dn1-20020a17090794c100b0084cd1f106bcsi10773600ejc.467.2023.01.09.03.14.26; Mon, 09 Jan 2023 03:14:38 -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=@kernel.org header.s=k20201202 header.b="KLPEab//"; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236418AbjAIKlZ (ORCPT + 53 others); Mon, 9 Jan 2023 05:41:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51714 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236309AbjAIKkx (ORCPT ); Mon, 9 Jan 2023 05:40:53 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3EA98186DD for ; Mon, 9 Jan 2023 02:34:07 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id D37DFB80D67 for ; Mon, 9 Jan 2023 10:34:05 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 45178C433D2; Mon, 9 Jan 2023 10:34:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1673260444; bh=4+41/x4EC6NqU/+mehLq4YWojS5p6S0n539ic8Dxjzw=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=KLPEab//TbD4tEXztACY7jbMKY+V1PEisPOaSjv53K9s1ByZnszapjf+hp8j8dmhi leIHi11Gd8rl48LQZ8vil32FY7RbME1aNmOmiBluphjCExSZsRigCOrCe5je6n1/p7 4T2w42Rt/WZEcBi43oaGadZGQdo6NdFHoXlyg9Bm7iKPptP/fEsS5UeTRNA4k2S+VJ 8ipXpJIAz9S6AMtWHo7xrZ50LDuI2+VbTVYTAwzZPUxevZXffjzMRR/VnOtmm2rchD 1o38xyqI+HesP2tnGi0fm2nmZOpQWv7Qz1ti5s8qutSR9sZ6TDdcqnQNTSMdxX2ERY cTsMFikSbH74A== Message-ID: Date: Mon, 9 Jan 2023 18:34:01 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.6.1 Subject: Re: [PATCH] erofs: fix kvcalloc() misuse with __GFP_NOFAIL Content-Language: en-US To: Gao Xiang , linux-erofs@lists.ozlabs.org, Yue Hu , Jeffle Xu Cc: LKML , syzbot+c3729cda01706a04fb98@syzkaller.appspotmail.com References: <20230106031937.113318-1-hsiangkao@linux.alibaba.com> From: Chao Yu In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_HI,SPF_HELO_NONE,SPF_PASS autolearn=ham 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 On 2023/1/6 13:06, Gao Xiang wrote: > > > On 2023/1/6 11:19, Gao Xiang wrote: >> As reported by syzbot [1], kvcalloc() cannot work with  __GFP_NOFAIL. >> Let's use kcalloc() instead. >> >> [1] https://lore.kernel.org/r/0000000000007796bd05f1852ec2@google.com >> Reported-by: syzbot+c3729cda01706a04fb98@syzkaller.appspotmail.com > > Fixes: fe3e5914e6dc ("erofs: try to leave (de)compressed_pages on stack if possible") > Fixes: 4f05687fd703 ("erofs: introduce struct z_erofs_decompress_backend") > >> Signed-off-by: Gao Xiang >> --- >>   fs/erofs/zdata.c | 8 ++++---- >>   1 file changed, 4 insertions(+), 4 deletions(-) >> >> diff --git a/fs/erofs/zdata.c b/fs/erofs/zdata.c >> index ccf7c55d477f..08e982c77985 100644 >> --- a/fs/erofs/zdata.c >> +++ b/fs/erofs/zdata.c >> @@ -1032,12 +1032,12 @@ static int z_erofs_decompress_pcluster(struct z_erofs_decompress_backend *be, >>       if (!be->decompressed_pages) >>           be->decompressed_pages = >> -            kvcalloc(be->nr_pages, sizeof(struct page *), >> -                 GFP_KERNEL | __GFP_NOFAIL); >> +            kcalloc(be->nr_pages, sizeof(struct page *), >> +                GFP_KERNEL | __GFP_NOFAIL); >>       if (!be->compressed_pages) >>           be->compressed_pages = >> -            kvcalloc(pclusterpages, sizeof(struct page *), >> -                 GFP_KERNEL | __GFP_NOFAIL); >> +            kcalloc(pclusterpages, sizeof(struct page *), >> +                GFP_KERNEL | __GFP_NOFAIL); How about using kfree instead of kvfree for .decompressed_pages and .compressed_pages memory release? It's trivial though. Anyway, feel free to add: Reviewed-by: Chao Yu Thanks, >>       z_erofs_parse_out_bvecs(be); >>       err2 = z_erofs_parse_in_bvecs(be, &overlapped);