Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp785477pxb; Tue, 12 Apr 2022 13:24:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJydrct2E+3H1C7xKOIbvhufqUPfZ1CGqu+FRbQlzRwA/11R0RbtXjJJNhAEaYIieCdvbH/I X-Received: by 2002:a17:90b:1806:b0:1c7:852d:e853 with SMTP id lw6-20020a17090b180600b001c7852de853mr6984895pjb.106.1649795063549; Tue, 12 Apr 2022 13:24:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649795063; cv=none; d=google.com; s=arc-20160816; b=X94BLIoUcGEGjHA1+1WR5SvYdfn+8labaOp1iGdfNKLl296SzYhLSqCAlVIBrOcasv 6elMOpUEKW+eLPYqTExWx9+pUGHw1kaDojDChBtOpjXwe8zVY3bIdq7VqUAoWeAEMESp OoYEOUbDoIy7lcN0+dlGQ9emlN2Y0T5RwJBAnv9jAFss+GgTE6izRtBNLpdUIbd3D7aA WOA2jJe1489rOtof+zsz/lnVqhb7oYl5g7edJHWWmlrNBSktapRfFG8d1uUwv1wYpw9I BSe44c8Wx+KSsLl07HKp2FKwGfQ8ytFmeF/xU2zFGRj0wFd20poSDuGYpdY2JPDwlTeR foAw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=0gFBQzsLD7TWyy7Jhgu5MKcgQWgf6yqeknlQekcRPdU=; b=HtdiYBm8HiZyD5eGvigLczxepQr7RgPCvgt3ECAtx+FX6MGh4LSS5bNoaXpE5YiYiP hgTBO4KAdcZqmoF6yyj0rOJqg6XsZp9Gxd5gX+XbbXR8RR77Zfus3vGO9W+tZyT6FJpg 02/rB0wP2O+empz95uYmJNmdhwVPxMYj6+H5zFct97AjbTHDr6MB/xrordoIeOS+cKXZ Wn+2YMAFqw5RHAfUZV7a6QF0gZ+4RWP5wATK4KfT/YChGlrxK3pIteOC9a2Qr09x2nBU fMN5FBJouYZk4wK4YWeOhkxNw/LAgF++2I0FI1olJvt0FXysD3WIFweBbAhXL89ByKQG ZC1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=E9glXHmd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id c4-20020a63ef44000000b0039cce49c42esi3470261pgk.117.2022.04.12.13.24.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Apr 2022 13:24:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=E9glXHmd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 5A2449AE43; Tue, 12 Apr 2022 13:04:27 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242221AbiDKJ4Q (ORCPT + 99 others); Mon, 11 Apr 2022 05:56:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56732 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344928AbiDKJ4H (ORCPT ); Mon, 11 Apr 2022 05:56:07 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AB8904160F for ; Mon, 11 Apr 2022 02:53:42 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id D7066CE170D for ; Mon, 11 Apr 2022 09:53:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 22668C385AA; Mon, 11 Apr 2022 09:53:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1649670819; bh=lKIoE+fCrKnnFm+3QbNw32clo6tQo6WExWhfT9DKIPc=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=E9glXHmdjnSJGsaaNhsUd3ai286WN/l7Go/zk/ufh7o+jTun3W13zlsjZq4AM+hnX lx/ZTMLWGrJ73xGXmNeESe7KWHEhdrMC6zwcMUsfxCmFtKzLxbcUqnvg6ecBkFUfLi flQq39/uaEIIarJcJXMlzu9Xz29GHz52OMdl+s4FQd9e96zcAAH2dG4FKMMIInLrBn tyL8Jhs8QC6OT9YE3QCrwshvSDj//MociQ5v8LEd459du73AVopB55ulCFTfUzDuRX 6e62qpz/O6oudwwIHDYtl4pVzn6PMNntcaI0DvB6tzYLx2NzFFqdns86DujXWbjuu0 SktrikGrdeD/g== Message-ID: Date: Mon, 11 Apr 2022 17:53:33 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.7.0 Subject: Re: [f2fs-dev] [PATCH] fs: f2fs: remove WARN_ON in f2fs_is_valid_blkaddr Content-Language: en-US To: Eric Biggers , Dongliang Mu Cc: Dmitry Vyukov , Jaegeuk Kim , Dongliang Mu , linux-kernel , syzbot+763ae12a2ede1d99d4dc@syzkaller.appspotmail.com, linux-f2fs-devel@lists.sourceforge.net References: <20220408052207.209856-1-dzm91@hust.edu.cn> <7e896205-027d-32e2-32b5-8951231132ac@kernel.org> <2f5b7291-da06-0895-8e75-c7a37251b47e@kernel.org> From: Chao Yu In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-3.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, NICE_REPLY_A,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE 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 On 2022/4/11 14:14, Eric Biggers wrote: > On Mon, Apr 11, 2022 at 01:06:09PM +0800, Dongliang Mu wrote: >> On Mon, Apr 11, 2022 at 11:10 AM Chao Yu wrote: >>> >>> On 2022/4/9 14:42, Dongliang Mu wrote: >>>> On Sat, Apr 9, 2022 at 11:46 AM Chao Yu wrote: >>>>> >>>>> On 2022/4/9 9:34, Dongliang Mu wrote: >>>>>> On Sat, Apr 9, 2022 at 8:27 AM Chao Yu wrote: >>>>>>> >>>>>>> On 2022/4/8 13:22, Dongliang Mu wrote: >>>>>>>> From: Dongliang Mu >>>>>>>> >>>>>>>> In f2fs_is_valid_blkaddr, if type is DATA_GENERIC_ENHANCE or >>>>>>>> DATA_GENERIC_ENHANCE_READ, it invokes WARN_ON(1) not matter >>>>>>>> blkaddr is in the range or not. >>>>>>> >>>>>>> If we run into the path where we invoke WARN_ON(1) in f2fs_is_valid_blkaddr(), >>>>>>> It means f2fs image may be broken, or there is a bug in f2fs. >>>>>>> >>>>>>> So, do you suffer any related issue in your environment? >>>>>> >>>>>> related issue? Can you explain a little? >>>>>> >>>>>> If you mean if this warning occurs, any other issues or crash >>>>> >>>>> I mean have you seen any warning info printed in the path of >>>>> f2fs_is_valid_blkaddr() before applying this patch, and if so, w/ what >>>>> reproducer? or you just figure out this patch from perspective of code >>>>> review? >>>> >>>> Yes, I have seen both warning information from Syzbot [1] and my local >>>> syzkaller instance. >>>> >>>> In f2fs_is_valid_blkaddr, if the following condition is satisfied, >>>> i.e., blkaddr is not in the right range [2], it will directly invoke >>>> one WARN_ON. >>>> >>>> if (unlikely(blkaddr >= MAX_BLKADDR(sbi) || >>>> blkaddr < MAIN_BLKADDR(sbi))) { >>>> >>>> This is the case on Syzbot. >>>> >>>> Otherwise, it will jump into __is_bitmap_valid. And if the following >>>> condition is satisfied [3], it will trigger another WARN_ON. >>>> >>>> exist = f2fs_test_bit(offset, se->cur_valid_map); >>>> if (!exist && type == DATA_GENERIC_ENHANCE) { >>>> >>>> This appears in my local syzbot instance, but unfortunately it does >>>> not get any reproducer. >>> >>> Oh, it occurs in syzbot test, I guess it is possible that f2fs prints such >>> warning info after blkaddr of node/data block was fuzzed to invalid one. >>> >>> I prefer to keep WARN_ON() to catch more info of bugs found by non-fuzzed >>> type test. >>> >>> Thoughts? >> >> I am fine with both options. I can remove the WARN_ON in my local >> syzkaller instance and continue fuzzing Linux kernel. >> >> +Dmitry Vyukov how do you think? If WARN_ON is kept, this crash will >> occur on Syzbot from time to time. > > WARN_ON is for kernel bugs; please refer to the documentation in > include/asm-generic/bug.h. If this is a kernel bug, then the kernel bug needs > to be fixed. Otherwise, the WARN_ON needs to be removed. Alright, so how about using dump_stack() instead as suggested in doc? Thanks, > > - Eric