Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp6443804rwb; Mon, 14 Nov 2022 21:08:16 -0800 (PST) X-Google-Smtp-Source: AA0mqf4akXUD3E4Wj38QfBOkMCIT5iaQQ7RAn1SjWoh+G0osuW7i7Gd9eoWe/ZkDZDhMRVJldr2t X-Received: by 2002:a05:6402:3983:b0:467:69e3:c25b with SMTP id fk3-20020a056402398300b0046769e3c25bmr12334067edb.3.1668488896041; Mon, 14 Nov 2022 21:08:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668488896; cv=none; d=google.com; s=arc-20160816; b=whfUo367K7wZhc5oB5gE/CDIny0FYLe/9fYC3tN/yHKckhws6G12/PwQiPmDZyeKNg LsUKym+n/hTLCFroZnKEPTZxoJI/qyvinaO0CAyoC/tD7Szwq7Fl2R7WvgMFtGqxdHMM 1AHOkPdEQTC5Bpk0f0+sUeAkfMKkrTgb05ow08bsjH7EHGCwQUZRViJE+fz+AEC/gvAY /dqMqq8l6DBEg7xflR9NRjapuUusSEY9INBivZLjgmQixvks/KoiJtoOotPHP2b2c1Pn YCu8dA77D5Vt32Y8WJ3iyIcqdMfgoegREAVtOyKt1f+SYemlUjPQ+PRQIbdATylDJJEE 4g1w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=wqQy12XFUgnRX9khT+cCXlW9/foyJ4blhF6LQ95A76o=; b=MJ0UtJ2BAAziFO42YuhQJ3GuEF3Xllj9NkUUz/Ji6tKpWlTgxAUfI/oGaiYaptRTGF DzUmH2LZFmd7V8FCX11ooLrXSW+yBlNWWYX/OMqhpyRPG7L+90yqMZEe1p08ls6y459j nUz0eWFHrZJMfHUKnPYNGxw4FMEtG+sb5C4PCkVJM9ii6NAO7lKxmlFyAnzbwPWjwgTe osYmQEnvLPtNzIMoLgrep0nh5fuV8WRDqGLgDUCohrpisH/0tVioE8jr1SiHgOsi7OYb vd2BfBiwAjh7Lebm/3eXITMZc2U17MSwnxoOFdzNc8G9F8W8ob4vpiUDlJ0l8siKp2Wq MjXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ymIiSOwr; 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=linaro.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g8-20020a056402090800b00462847f2128si12043332edz.107.2022.11.14.21.07.53; Mon, 14 Nov 2022 21:08:16 -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=@linaro.org header.s=google header.b=ymIiSOwr; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231992AbiKOElr (ORCPT + 88 others); Mon, 14 Nov 2022 23:41:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51792 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231598AbiKOElp (ORCPT ); Mon, 14 Nov 2022 23:41:45 -0500 Received: from mail-lf1-x132.google.com (mail-lf1-x132.google.com [IPv6:2a00:1450:4864:20::132]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 95B4565B8 for ; Mon, 14 Nov 2022 20:41:43 -0800 (PST) Received: by mail-lf1-x132.google.com with SMTP id b3so22661337lfv.2 for ; Mon, 14 Nov 2022 20:41:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=wqQy12XFUgnRX9khT+cCXlW9/foyJ4blhF6LQ95A76o=; b=ymIiSOwr+xJ3hkk1bsxngM5c4I/NcP7YEEPNxG3Y0tSJVubX1CM7f9DK23Umg9yJ44 NiwO7ZJOb3I09eUX9A+4FyeXqRy1lKcInvlXti9nkJYn6sJFNcKAS5qLW60M3oDcIYln aa69ezSd+XqwdoyMTmViJHv2l4lwwlwGJW6ltlJhfqoYjmwRZZ7e+YKwNRsCuucO+rKK lJ6Aj4ldHwdR80NXKzch3WnPjDLkHB8XGE9A6eTCdHB54VXSkN+L7ROyKXlQ1plT+yz+ 4wu9JXdR1406uHMAza5i/VlOolSdxPILa6+9GE69yaSpFlawxywxnVkAm6iauQiEJ30w fc/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=wqQy12XFUgnRX9khT+cCXlW9/foyJ4blhF6LQ95A76o=; b=VCS3rcR6FT178dkmpHQR/EvmIkoNZf9qysawNSxewP+n+EzVBLKOKLBggiqYjk16re BPP6ICWPGDepJZKkoiOCUqpcNEVEBuTQYBf0e5275uCbD78U23XyFinIwhJ02xCFHpwg 7xr//t6+33x1oh9mYFMwPV04cKexDscEpduOXq/ps/AVbLi0ciLYUMr/PrfpSKQFzhaT 9eIusV8svnVrEenieAYLsqNH5kv6tx+BLnH+7cJMujRsdwoclAwlioSWQjKFVJDDHsqQ EC3ppKD4k47PX1erpIvIb6tkHMZfB9ltPUbX3VLW44ndGPoI+WudfCmIMbM8Kww/JOfE UEOg== X-Gm-Message-State: ANoB5plimLiZkvSyo1j+BBaRI/DIWN3RxERBVzMJSQkuudErbEvYyRMg Islp7d0+MVW6nuXs1YYqnI1mLLbkAVS40n2XCqDYsg== X-Received: by 2002:a19:7411:0:b0:4b1:215b:167d with SMTP id v17-20020a197411000000b004b1215b167dmr5423887lfe.558.1668487301857; Mon, 14 Nov 2022 20:41:41 -0800 (PST) MIME-Version: 1.0 References: <697a57bd-8507-1477-0176-e840b2e2f809@kernel.org> In-Reply-To: <697a57bd-8507-1477-0176-e840b2e2f809@kernel.org> From: Jun Nie Date: Tue, 15 Nov 2022 12:41:30 +0800 Message-ID: Subject: Re: [BUG REPORT] f2fs: use-after-free during garbage collection To: Chao Yu Cc: jaegeuk@kernel.org, linux-f2fs-devel@lists.sourceforge.net, Linux Kernel Mailing List , Lee Jones , davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, netdev@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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 Chao Yu =E4=BA=8E2022=E5=B9=B411=E6=9C=8815=E6=97=A5=E5= =91=A8=E4=BA=8C 00:02=E5=86=99=E9=81=93=EF=BC=9A > > On 2022/11/14 9:47, Jun Nie wrote: > > Hi Chao & Jaegeuk, > > > > There is a KASAN report[0] that shows invalid memory > > access(use-after-free) in f2fs garbage collection process, and this > > issue is fixed by a recent f2fs patch set[1]. The KASAN report is cause= d > > by an abnormal sum->ofs_in_node value 0xc3f1 in the first check. And > > the investigation indicates that the f2fs_summary_block address range > > is not from f2fs_kzalloc() in build_curseg(). The memory > > allocation/free happens in non-f2fs thread, such as network. So I > > guess the f2fs subsystem is accessing memory that's not belong to f2fs > > in some cases. With the below commit merged into mainline recently, > > this use-after-free issue disappears. But there is another thread > > blocked issue as below. The patch c6ad7fd16657 check the valid > > ofs_in_node and stop further gc. I am not sure whether it is expected > > that the f2fs_summary_block address in gc thread is not from > > allocation in build_curseg(). Because I am not familiar with f2fs. > > > > Could you help comment on my question and new issue? Is there any work > > in progress to fix the new blocked issue? Thanks! > > Please check below patch: > > https://git.kernel.org/pub/scm/linux/kernel/git/chao/linux.git/commit/?h= =3Ddev-test&id=3D2272d08781a73b6d7039ed70f6d68d87ac82f256 > Thanks for the patch! I cherry pick below 3 patches from your branch to mai= nline to test the bug. It is not reproduced any more. b380cedda7c3 f2fs: fix to do sanity check on i_extra_isize in is_alive() cdcb173c158e f2fs: Fix the race condition of resize flag between resizefs c316fb60f5fb f2fs: should put a page when checking the summary info BTW: below log line is repeated endless if cdcb173c158e is missing. [ 142.766237][ T9] F2FS-fs (loop0): Inconsistent blkaddr offset: base:9, ofs_in_node:50161, max:923, ino:8, nid:8 Regards, Jun > Thanks, > > > > > [0] https://syzkaller.appspot.com/bug?id=3D4cbcff00422ea402c2e5be2bc041= a8f4196d608c > > [1] c6ad7fd16657 f2fs: fix to do sanity check on summary info > >