Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp5398461rwb; Sun, 4 Dec 2022 21:02:47 -0800 (PST) X-Google-Smtp-Source: AA0mqf6pimdBE+5lpdrvPvXZZXMIsRCsuUvV/dxMnF6XGlDIlA1MYBdMTjmsnfIsj4cPEnZnuFL+ X-Received: by 2002:a17:907:a0ce:b0:7c0:cf15:eb8b with SMTP id hw14-20020a170907a0ce00b007c0cf15eb8bmr8925316ejc.678.1670216567020; Sun, 04 Dec 2022 21:02:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670216567; cv=none; d=google.com; s=arc-20160816; b=H4ebk02IyM+Gigyuenxj1J6dAyt2gwIfMSI9HC8U9dL2XjNZvGBGRwuq7JoLLH91mZ /0T1luwuS7kKJDuSOAehSa14NeEYFVt+WDsh2IOq0OEQQsyQ0pn0jgskhfSNoxMe7UjE IebtAhAUeVw8nVx8DxqzfbMej3hjhwF6YCKk65vUU+rT7MyNu9ZCWCBPE/X6460fBwYt spZEo1Wt+KhNOf9f044rSaSrZIcesR6DAT8Gbc00ddoZ5TS15iPokE25CBMBt0q4XM0z x02fxfKxO6l2izsXNPXdm+hRRQplqCPGg/H+uNpIi/uV9IPvqcWtCn4fmbGT6+85YDwl m91w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=BwZ79B7+vw0Xk0W07C18KlR4Ta5W6ZSJX332glYaiVo=; b=IRuJ2kvS42EUGa0c7+nf+1KQnZ6y+xXawSiV0MOwH2RaQpH8V4PmwEP5HaKaKClqOy Ip0yj/51GaztTQbFwZ01mlng4ucyC3OtYLU7cVLcOTHwdxGkwntie2GLADdbSqAsu1rz 6Mled+F5DDLw2UGcoqyqgPAkCE34APWv6rX1ztbbwGpjtFy26BI+YXuviZ0xKw3dF3zr BSot9Vu8BXXNrGmkTrKB9DHcxk6wyuVHmpWHANxiUODWW/eeNn8VYJ8hlnaks13lLe2M Q/tRw4se0TyxkKCoxoy8karFrF4q81UWTJA5AC17+L0vQdzXl7jcWGp8cfAw4RmrwgVM /Fpw== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id sb40-20020a1709076da800b007bebf105450si12503926ejc.235.2022.12.04.21.02.25; Sun, 04 Dec 2022 21:02:47 -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 S231367AbiLEEix (ORCPT + 82 others); Sun, 4 Dec 2022 23:38:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48720 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231298AbiLEEiv (ORCPT ); Sun, 4 Dec 2022 23:38:51 -0500 Received: from out30-45.freemail.mail.aliyun.com (out30-45.freemail.mail.aliyun.com [115.124.30.45]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 30D64BE3 for ; Sun, 4 Dec 2022 20:38:48 -0800 (PST) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R131e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018045192;MF=hsiangkao@linux.alibaba.com;NM=1;PH=DS;RN=8;SR=0;TI=SMTPD_---0VWMtcWg_1670215124; Received: from B-P7TQMD6M-0146.local(mailfrom:hsiangkao@linux.alibaba.com fp:SMTPD_---0VWMtcWg_1670215124) by smtp.aliyun-inc.com; Mon, 05 Dec 2022 12:38:45 +0800 Date: Mon, 5 Dec 2022 12:38:43 +0800 From: Gao Xiang To: Chen Zhongjin Cc: syzbot+6f8cd9a0155b366d227f@syzkaller.appspotmail.com, linux-erofs@lists.ozlabs.org, linux-kernel@vger.kernel.org, xiang@kernel.org, chao@kernel.org, huyue2@coolpad.com, jefflexu@linux.alibaba.com Subject: Re: [PATCH -next v3] erofs: Fix pcluster memleak when its block address is zero Message-ID: References: <20221205034957.90362-1-chenzhongjin@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20221205034957.90362-1-chenzhongjin@huawei.com> 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: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Dec 05, 2022 at 11:49:57AM +0800, Chen Zhongjin wrote: > syzkaller reported a memleak: > https://syzkaller.appspot.com/bug?id=62f37ff612f0021641eda5b17f056f1668aa9aed > > unreferenced object 0xffff88811009c7f8 (size 136): > ... > backtrace: > [] z_erofs_do_read_page+0x99b/0x1740 > [] z_erofs_readahead+0x24e/0x580 > [] read_pages+0x86/0x3d0 > ... > > syzkaller constructed a case: in z_erofs_register_pcluster(), > ztailpacking = false and map->m_pa = zero. This makes pcl->obj.index be > zero although pcl is not a inline pcluster. > > Then following path adds refcount for grp, but the refcount won't be put > because pcl is inline. > > z_erofs_readahead() > z_erofs_do_read_page() # for another page > z_erofs_collector_begin() > erofs_find_workgroup() > erofs_workgroup_get() > > Since it's illegal for the block address of a pcluster to be zero, add > check here to avoid registering the pcluster which would be leaked. > > Fixes: cecf864d3d76 ("erofs: support inline data decompression") > Reported-by: syzbot+6f8cd9a0155b366d227f@syzkaller.appspotmail.com > Signed-off-by: Chen Zhongjin Reviewed-by: Gao Xiang Thanks, Gao Xiang