From nobody Thu Sep 18 20:29:17 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4A51FC4332F for ; Fri, 2 Dec 2022 03:36:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232204AbiLBDgj (ORCPT ); Thu, 1 Dec 2022 22:36:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46674 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232129AbiLBDgU (ORCPT ); Thu, 1 Dec 2022 22:36:20 -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 D81AEDC4C3 for ; Thu, 1 Dec 2022 19:33:43 -0800 (PST) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R161e4;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=7;SR=0;TI=SMTPD_---0VWB6jkA_1669952008; Received: from e18g06460.et15sqa.tbsite.net(mailfrom:hsiangkao@linux.alibaba.com fp:SMTPD_---0VWB6jkA_1669952008) by smtp.aliyun-inc.com; Fri, 02 Dec 2022 11:33:41 +0800 From: Gao Xiang To: linux-erofs@lists.ozlabs.org, Yue Hu , Chao Yu Cc: LKML , Gao Xiang , syzbot+6f8cd9a0155b366d227f@syzkaller.appspotmail.com, Yue Hu Subject: [PATCH] erofs: fix inline pcluster memory leak Date: Fri, 2 Dec 2022 11:33:27 +0800 Message-Id: <20221202033327.52702-1-hsiangkao@linux.alibaba.com> X-Mailer: git-send-email 2.24.4 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Inline pcluster should be freed right after it is decompressed. Otherwise inline pclusters will be leaked. Reported-by: syzbot+6f8cd9a0155b366d227f@syzkaller.appspotmail.com Fixes: cecf864d3d76 ("erofs: support inline data decompression") Cc: Yue Hu Signed-off-by: Gao Xiang --- fs/erofs/zdata.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/fs/erofs/zdata.c b/fs/erofs/zdata.c index ab22100be861..e14e6c32e70d 100644 --- a/fs/erofs/zdata.c +++ b/fs/erofs/zdata.c @@ -496,7 +496,8 @@ static int z_erofs_register_pcluster(struct z_erofs_dec= ompress_frontend *fe) struct erofs_workgroup *grp; int err; =20 - if (!(map->m_flags & EROFS_MAP_ENCODED)) { + if (!(map->m_flags & EROFS_MAP_ENCODED) || + !(map->m_pa >> PAGE_SHIFT)) { DBG_BUGON(1); return -EFSCORRUPTED; } @@ -1114,6 +1115,8 @@ static int z_erofs_decompress_pcluster(struct z_erofs= _decompress_backend *be, /* pcluster lock MUST be taken before the following line */ WRITE_ONCE(pcl->next, Z_EROFS_PCLUSTER_NIL); mutex_unlock(&pcl->lock); + if (z_erofs_is_inline_pcluster(pcl)) + z_erofs_free_pcluster(pcl); return err; } =20 --=20 2.24.4