Message ID | 20230106031937.113318-1-hsiangkao@linux.alibaba.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp616821wrt; Thu, 5 Jan 2023 19:29:09 -0800 (PST) X-Google-Smtp-Source: AMrXdXtmAe24iWyWDhNO4V23qwg/vIXlzxcbT0A+B6P9+tsnUmq6Tk3506HF7f3DlzqmYpjFUnlN X-Received: by 2002:a17:90b:394b:b0:226:d73d:12f4 with SMTP id oe11-20020a17090b394b00b00226d73d12f4mr2591025pjb.28.1672975748775; Thu, 05 Jan 2023 19:29:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672975748; cv=none; d=google.com; s=arc-20160816; b=yIwpjTzN8SOgY3G+0S79EOA9RNgpiy2wq1XHLC+2LoGp4SMpJ6dPN3HbeY1ueqMeh7 VZSTQTTUrC8eUf4HZGDtYKUi7G0mM+dMHicYXwjnfZaq9xtO+iFCsjxZEflOEwMuYhmI Zcsg6kIlQq1hlGaOjpWoNI6UYCFiVirjFVmjruT6HZtDjqrhep1WO+0ry9v/H77RXC7m gmla30RLZfJv04Ym7r6pjMCIrB2KNW11yFjwbVME2NZeqeitFnEdIfccgODm/gl1YlGc ycE5oiMOJbjRWXS2kOyIJYDDGbc1OvH6WLNIQJc4xO38gRKvRUv2kiU+uCWdVIBIygN7 WFWw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=dpK1OU0ATUUZOYg4cghlsdWpKpRop8cGc1sPBi1hB7U=; b=j8+R8pNMnhpgE3vQdeoOskR+Hij2vdyGBz60oD1USUqLquioYewFXDS4ZPml3GVLBU g1epjQpOClq9DLtIgkvIsrm6bB1Kl7ceh9wpx/SOXLXPb7CpK6NliAtD1YtLCcC9FsGa uiGx2mZEQjNP7GQJBkTMU9HmP6eqnMz0RkGkGZG9D/ukfHhMRX9TX2XyK3cdyhK0qgKH ogOYOi2QJcgjwkGK03GPIk8N8Mkyx9MBoWxph2czwk/w71hT2fbKVrlHYSeUWxem1PWN 4LJA8dJgxE1XI+VTZBznJ2WAlPPnB6DBe05IfmVzXv/rZfn82wbPdsc1+zCqtJDoeqda UO8Q== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x6-20020a17090a8a8600b00219bb19bcdfsi3725646pjn.38.2023.01.05.19.28.56; Thu, 05 Jan 2023 19:29:08 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230471AbjAFDTr (ORCPT <rfc822;tmhikaru@gmail.com> + 99 others); Thu, 5 Jan 2023 22:19:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37548 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229554AbjAFDTq (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 5 Jan 2023 22:19:46 -0500 Received: from out30-43.freemail.mail.aliyun.com (out30-43.freemail.mail.aliyun.com [115.124.30.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D8DCD34D4F for <linux-kernel@vger.kernel.org>; Thu, 5 Jan 2023 19:19:44 -0800 (PST) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R191e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018045176;MF=hsiangkao@linux.alibaba.com;NM=1;PH=DS;RN=7;SR=0;TI=SMTPD_---0VYy7CO9_1672975177; Received: from e18g06460.et15sqa.tbsite.net(mailfrom:hsiangkao@linux.alibaba.com fp:SMTPD_---0VYy7CO9_1672975177) by smtp.aliyun-inc.com; Fri, 06 Jan 2023 11:19:42 +0800 From: Gao Xiang <hsiangkao@linux.alibaba.com> To: linux-erofs@lists.ozlabs.org, Chao Yu <chao@kernel.org>, Yue Hu <huyue2@coolpad.com>, Jeffle Xu <jefflexu@linux.alibaba.com> Cc: LKML <linux-kernel@vger.kernel.org>, Gao Xiang <hsiangkao@linux.alibaba.com>, syzbot+c3729cda01706a04fb98@syzkaller.appspotmail.com Subject: [PATCH] erofs: fix kvcalloc() misuse with __GFP_NOFAIL Date: Fri, 6 Jan 2023 11:19:37 +0800 Message-Id: <20230106031937.113318-1-hsiangkao@linux.alibaba.com> X-Mailer: git-send-email 2.24.4 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-9.9 required=5.0 tests=BAYES_00, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2, SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY,USER_IN_DEF_SPF_WL 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754242219071741831?= X-GMAIL-MSGID: =?utf-8?q?1754242219071741831?= |
Series |
erofs: fix kvcalloc() misuse with __GFP_NOFAIL
|
|
Commit Message
Gao Xiang
Jan. 6, 2023, 3:19 a.m. UTC
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
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
---
fs/erofs/zdata.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
Comments
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 <hsiangkao@linux.alibaba.com> > --- > 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); > > z_erofs_parse_out_bvecs(be); > err2 = z_erofs_parse_in_bvecs(be, &overlapped);
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 <hsiangkao@linux.alibaba.com> >> --- >> 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 <chao@kernel.org> Thanks, >> z_erofs_parse_out_bvecs(be); >> err2 = z_erofs_parse_in_bvecs(be, &overlapped);
Hi Chao, On 2023/1/9 18:34, Chao Yu wrote: > 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 <hsiangkao@linux.alibaba.com> >>> --- >>> 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. Yeah, thanks for catching! I will send v2 to fix these. Thanks, Gao Xiang > > Anyway, feel free to add: > > Reviewed-by: Chao Yu <chao@kernel.org> > > Thanks, > >>> z_erofs_parse_out_bvecs(be); >>> err2 = z_erofs_parse_in_bvecs(be, &overlapped);
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); z_erofs_parse_out_bvecs(be); err2 = z_erofs_parse_in_bvecs(be, &overlapped);