From nobody Sun May 24 18:41:55 2026 Received: from out30-112.freemail.mail.aliyun.com (out30-112.freemail.mail.aliyun.com [115.124.30.112]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 280EB35AC2F for ; Fri, 22 May 2026 08:27:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=115.124.30.112 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779438446; cv=none; b=UD1zdKCCDhIIXfiPuznZ6z6nnkkN7YvFcyK34wnp69JR+QYdgAOnBs7PII3fsWUUSGsNAGf6DagVLDL/160lXmVD9R0wj5MH42FUB+2vbL+5tKJXAG4pqOFZVS23bcgyEYzRC86zlgyhnLd5UJskwWlVvE8iA1sbKVbY7XRcq2M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779438446; c=relaxed/simple; bh=c5sBmgKN2vye+zkjlCUow158r/Y1mFaTUCkM3DS6vps=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=BvCdX6iTK6XJa3kvmgYA17E66ek3BO4+Idb/Hgzm9HkHu8q61bVX992U5Nf774xA6WesvJqfYiojtc+aens2pcDI4gXs4Kc5oBUA3b+2aV0TrrgBjArpEf31ZjXv9UqjCObrdceA3Zn+RuYzew/YxFfDrMzQH2LSrRwzp5rRefc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com; spf=pass smtp.mailfrom=linux.alibaba.com; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b=AokCYS9r; arc=none smtp.client-ip=115.124.30.112 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b="AokCYS9r" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1779438442; h=From:To:Subject:Date:Message-ID:MIME-Version; bh=Av3NOw2DfrctqHU3cMGoOQFqriKBG8U8dr2oCOma5UM=; b=AokCYS9rmwFMHOXnFD/PshTau75f+enNhZGYh0grcJvzfd9vkLZKLQE621rkFADANQxjezzvgsClrZKcT1gxcSPhCLyhI7Lc4IZXPh2ZP8x4fl61NwWuYjLmMsqMdF+ObSteVWKpdhrdcopC4dkJRaFogaNGOSxI8cnOUFByY+g= X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R141e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=maildocker-contentspam033037033178;MF=hsiangkao@linux.alibaba.com;NM=1;PH=DS;RN=6;SR=0;TI=SMTPD_---0X3O3ZGO_1779438437; Received: from x31i01179.sqa.na131.tbsite.net(mailfrom:hsiangkao@linux.alibaba.com fp:SMTPD_---0X3O3ZGO_1779438437 cluster:ay36) by smtp.aliyun-inc.com; Fri, 22 May 2026 16:27:21 +0800 From: Gao Xiang To: linux-erofs@lists.ozlabs.org, Chao Yu Cc: LKML , oliver.yang@linux.alibaba.com, Gao Xiang , syzbot+52bae5c495dbe261a0bc@syzkaller.appspotmail.com Subject: [PATCH] erofs: fix use-after-free on sbi->sync_decompress Date: Fri, 22 May 2026 16:27:16 +0800 Message-ID: <20260522082716.3598160-1-hsiangkao@linux.alibaba.com> X-Mailer: git-send-email 2.43.5 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" z_erofs_decompress_kickoff() can race with filesystem unmount, causing a use-after-free on sbi->sync_decompress. When I/O completes, z_erofs_endio() calls z_erofs_decompress_kickoff() to queue z_erofs_decompressqueue_work() asynchronously. Then, after all folios are unlocked, unmount workflow can proceed and sbi will be freed before accessing to sbi->sync_decompress. Thread (unmount) I/O completion kworker queue_work z_erofs_decompressqueue_work (all folios are unlocked) cleanup_mnt .. erofs_kill_sb erofs_sb_free kfree(sbi) access sbi->sync_decompress // UAF!! Fixes: 40452ffca3c1 ("erofs: add sysfs node to control sync decompression s= trategy") Reported-by: syzbot+52bae5c495dbe261a0bc@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=3D52bae5c495dbe261a0bc Signed-off-by: Gao Xiang Reviewed-by: Chao Yu --- fs/erofs/zdata.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fs/erofs/zdata.c b/fs/erofs/zdata.c index 27ab7bd844ec..c6240dccbb0f 100644 --- a/fs/erofs/zdata.c +++ b/fs/erofs/zdata.c @@ -1455,6 +1455,9 @@ static void z_erofs_decompress_kickoff(struct z_erofs= _decompressqueue *io, if (atomic_add_return(bios, &io->pending_bios)) return; if (z_erofs_in_atomic()) { + /* See `sync_decompress` in sysfs-fs-erofs for more details */ + if (sbi->sync_decompress =3D=3D EROFS_SYNC_DECOMPRESS_AUTO) + sbi->sync_decompress =3D EROFS_SYNC_DECOMPRESS_FORCE_ON; #ifdef CONFIG_EROFS_FS_PCPU_KTHREAD struct kthread_worker *worker; =20 @@ -1471,9 +1474,6 @@ static void z_erofs_decompress_kickoff(struct z_erofs= _decompressqueue *io, #else queue_work(z_erofs_workqueue, &io->u.work); #endif - /* See `sync_decompress` in sysfs-fs-erofs for more details */ - if (sbi->sync_decompress =3D=3D EROFS_SYNC_DECOMPRESS_AUTO) - sbi->sync_decompress =3D EROFS_SYNC_DECOMPRESS_FORCE_ON; return; } gfp_flag =3D memalloc_noio_save(); --=20 2.43.5