Received: by 2002:ac2:464d:0:0:0:0:0 with SMTP id s13csp2180857lfo; Fri, 20 May 2022 16:46:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxJWnF0SVXhr+qUH1n3korRAYuizqnc5sTGmt4j5S6z7w+m4Uqml2VfzuTkIrMhbZXYsbZT X-Received: by 2002:a62:1a4a:0:b0:518:357f:905b with SMTP id a71-20020a621a4a000000b00518357f905bmr12182223pfa.85.1653090377066; Fri, 20 May 2022 16:46:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653090377; cv=none; d=google.com; s=arc-20160816; b=L1LIvy4RKfLMp804leRCCR5peTQIywhJS/hk/CsBq2ybwDTR8MUx1EbAYY42kedAOp AbWcLgWOYxHPmnbvL2n5yAL0gm+qkB0TyDtk67pa37qNivuGUgofYqdWcZZWxiZ5TrTp zaWGFNh67BLhJof11N/0OnzwfwIcGTnS3Pd7kqta1LYsB0GyTaYZDjCUoTrmhvt+MnXr +3ZOvYBdSMzPYBiNagYHYkPjwbwTMsRWXGt/NhkHBD6Qa9J/77K6RDsxLmneHb0ZrEV3 Rrti1hpSH1EhFaYZekQbCWZUi+CHN8kPMhJ+GyUbEz8BTwJNaL+r0uYFpgX+D3oX3Yl6 DHmQ== 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:subject :from:references:cc:to:content-language:user-agent:mime-version:date :message-id:dkim-signature; bh=YlMUufwr0l9tO9rVDIxOV/soI8WTUMwn/+RPr0+aDoU=; b=q3E+AWfQ8hl9YSu6Q5giyLgZqt8gxiOm+QPSWblmSfoAdDVQ0aeiNWQ7ZkSQ3LIl4c BragcS+VSXO4sZk7WAqHDf9aCAZly4LEBmKoYVfrTqEoj3OcVY7xzzBqir7R73OxELLZ inFgS3phNTmzCO0spW2ssjzqA7Ko3FcnPmum+nALVmTVkeHUcOWffonLFg6nL4T9Mc8B QsAC/IW/+uGAbxrlimzyj4G0mAHRjHQiTUe4TbrbI0OJJuwD3rBFSNhKyhNwdhsj84PJ rBd3KJQWW3/ulbliqumx9itlvGbAza1Jh5DruH0TbDFeHFct4IU+d1qCe1nYlMXAYPkU YKDQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=cz0wk8lc; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-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 m8-20020a170902bb8800b00161f1fc2ed2si1051898pls.44.2022.05.20.16.45.53; Fri, 20 May 2022 16:46:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-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=cz0wk8lc; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-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 S1349287AbiETOuZ (ORCPT + 99 others); Fri, 20 May 2022 10:50:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51656 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350451AbiETOuX (ORCPT ); Fri, 20 May 2022 10:50:23 -0400 Received: from mail-pg1-x52d.google.com (mail-pg1-x52d.google.com [IPv6:2607:f8b0:4864:20::52d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 252121737D4 for ; Fri, 20 May 2022 07:50:22 -0700 (PDT) Received: by mail-pg1-x52d.google.com with SMTP id j21so7715215pga.13 for ; Fri, 20 May 2022 07:50:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=message-id:date:mime-version:user-agent:content-language:to:cc :references:from:subject:in-reply-to:content-transfer-encoding; bh=YlMUufwr0l9tO9rVDIxOV/soI8WTUMwn/+RPr0+aDoU=; b=cz0wk8lcDszKFG3qX7rWCqzlqco9Sek/q86lTVGXVgDOoWtHf6JHnKv52/V1kI8GsY tNhwHBCWrGXadYVN5kY78XCACyEuD+6h2Hi4/M3ErbKa5FZxFDBExxTLIs+GXtyLB+mE rpPWbcyQ4DRaczSqCmY9GcIY644HfOExpwuZ1zTxkdZlJksBjavAN0Yx1JMdObEEoMfq FwKDI9pJX77DEPyEmJ3qlksOG7v2PfcBVqSE0yDqwcXVEI65BIuXZT+qiJtNDO7ov/g6 JnGxVhPaVYO1ZDjM8zlutZROY7BlGoiyfmC57e8wywTsviMatf6ek/1z4itHFNcDOiHn 7rzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent :content-language:to:cc:references:from:subject:in-reply-to :content-transfer-encoding; bh=YlMUufwr0l9tO9rVDIxOV/soI8WTUMwn/+RPr0+aDoU=; b=GfhkYiQBYcWVsYMGOPtP1IeCRF5mTMIdBu78RHKNBsBpJ1sksK6xtGObKKmxqo1aCD uur8svXJ6ludQVd1xr1I91ySt2+nGpSXf7obJjpZb1BTa/uc4OMVbI5GivGAVJqRQYdi 0ZtzoxzdTsbsLwJ6gXhzq2iuF6c8zXz1fiMnZ2v317jDeKsJ65UxdqknAq5NoLLk2JKj YnDXWVLr1GhdEbRG4HDCRR+vkXLMHKUuuULVl0CznsUGrNzEFFhetLB8PHbp/VnuhNRo Ja/tjH9HVd9qGuGtFA66PdSYDYqfchniTLgq28i4DLTFoTqOHOFFU51BAejjUU554e7G DD9g== X-Gm-Message-State: AOAM532T3n1CHzozJxtqLUEOM6TBA7gc4vfsPAGl98A+aSR+sB/9FAHS fRP9ZNF8WKXFLsLKGWn5zJ4nWQ== X-Received: by 2002:a63:fc04:0:b0:3f6:4b2b:9d36 with SMTP id j4-20020a63fc04000000b003f64b2b9d36mr6451721pgi.206.1653058221601; Fri, 20 May 2022 07:50:21 -0700 (PDT) Received: from [192.168.254.17] ([50.39.160.154]) by smtp.gmail.com with ESMTPSA id d10-20020a170902654a00b0015ea9aabd19sm5892769pln.241.2022.05.20.07.50.21 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 20 May 2022 07:50:21 -0700 (PDT) Message-ID: <983bb802-d883-18d4-7945-dbfa209c1cc8@linaro.org> Date: Fri, 20 May 2022 07:50:20 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.0 Content-Language: en-US To: Jan Kara Cc: linux-ext4@vger.kernel.org, lkml , linux-fsdevel@vger.kernel.org References: <49ac1697-5235-ca2e-2738-f0399c26d718@linaro.org> <20220519122353.eqpnxiaybvobfszb@quack3.lan> <20220520095028.rq4ef2o5nwetzog3@quack3> From: Tadeusz Struk Subject: Re: kernel BUG in ext4_writepages In-Reply-To: <20220520095028.rq4ef2o5nwetzog3@quack3> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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-ext4@vger.kernel.org On 5/20/22 02:50, Jan Kara wrote: > On Thu 19-05-22 16:14:17, Tadeusz Struk wrote: >> On 5/19/22 05:23, Jan Kara wrote: >>> Hi! >>> >>> On Tue 10-05-22 15:28:38, Tadeusz Struk wrote: >>>> Syzbot found another BUG in ext4_writepages [1]. >>>> This time it complains about inode with inline data. >>>> C reproducer can be found here [2] >>>> I was able to trigger it on 5.18.0-rc6 >>>> >>>> [1] https://syzkaller.appspot.com/bug?id=a1e89d09bbbcbd5c4cb45db230ee28c822953984 >>>> [2] https://syzkaller.appspot.com/text?tag=ReproC&x=129da6caf00000 >>> >>> Thanks for report. This should be fixed by: >>> >>> https://lore.kernel.org/all/20220516012752.17241-1-yebin10@huawei.com/ >> >> >> In case of the syzbot bug there is something messed up with PAGE DIRTY flags >> and the way syzbot sets up the write. This is what triggers the crash: > > Can you tell me where exactly we hit the bug? I've now noticed that this is > on 5.10 kernel and on vanilla 5.10 there's no BUG_ON on line 2753. We are hiting this bug: https://elixir.bootlin.com/linux/latest/source/fs/ext4/inode.c#L2707 Syzbot found it in v5.10, but I recreated it on 5.18-rc7, that's why the line number mismatch. But this is the same bug. On 5.10 it's in line 2739: https://elixir.bootlin.com/linux/v5.10.117/source/fs/ext4/inode.c#L2739 > >> $ ftrace -f ./repro >> ... >> [pid 2395] open("./bus", O_RDWR|O_CREAT|O_SYNC|O_NOATIME, 000 >> [pid 2395] <... open resumed> ) = 6 >> ... >> [pid 2395] write(6, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", 22 >> ... >> [pid 2395] <... write resumed> ) = 22 >> >> One way I could fix it was to clear the PAGECACHE_TAG_DIRTY on the mapping in >> ext4_try_to_write_inline_data() after the page has been updated: >> >> diff --git a/fs/ext4/inline.c b/fs/ext4/inline.c >> index 9c076262770d..e4bbb53fa26f 100644 >> --- a/fs/ext4/inline.c >> +++ b/fs/ext4/inline.c >> @@ -715,6 +715,7 @@ int ext4_try_to_write_inline_data(struct address_space *mapping, >> put_page(page); >> goto out_up_read; >> } >> + __xa_clear_mark(&mapping->i_pages, 0, PAGECACHE_TAG_DIRTY); >> } >> ret = 1; >> >> Please let me know it if makes sense any I will send a proper patch. > > No, this looks really wrong... We need to better understand what's going > on. So I was afraid. I'm trying to diverge the ext4_writepages() to go to the out_writepages path before we hit this BOG_ON(). Any hints will be much appreciated. -- Thanks, Tadeusz