Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp1155702rwr; Fri, 5 May 2023 09:51:45 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4ZYdN76K5lYmG5NTB/hvqUlzoB2wZu9+ax79nL0o1xjl4JdqwISnmYSsC4b60BJ7jIwqw1 X-Received: by 2002:a05:6a20:440c:b0:ea:ef5f:70ce with SMTP id ce12-20020a056a20440c00b000eaef5f70cemr2803073pzb.52.1683305505358; Fri, 05 May 2023 09:51:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683305505; cv=none; d=google.com; s=arc-20160816; b=1G2m/BdvXIxjwN4ShfJDWzy0zg8T9EHKoqa5VqCUny65oHPXEEiBptblAxITZ9M1ic G6kmkn+RbinxYDx27nV2tXVysGua8JdsinJTxmp11GsDsxuFpmIw2vIYWziVIXzqQM+I gwklJR2n/CEWYIbEg5aO56yhzU937be+pIVjetnJZ11U9RijzjNe2DEpqBFiYBXBVXUs CaM+H6bL9qTXytq43MDzG82wkWri1XTOyUmZDsh1qHZsy4wY50f/ZEUGv8pDN6AJHheq kz6WCTBTOCyAfKWUg93fP43GNLrktrd5iZj+ppj9Abv6bTgOIC+Ka0Za8tEShmhTWdfk hl1w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature :dkim-signature; bh=zPT0GNbrLPn2WOzHVENqDErkuUZ+X4IxxxJ3W2ZkErM=; b=ICBPx3wRylr/OVzehCiHTHCF1c0OkLK8OxlfK9ldGUnw+ulPrQeeUw6dOJBuFQ2gK5 KP2cGdtsddueD8A7or9E5Z16Onan5wOsXbbcpJMRXZhiSqlX0hwGNjpcbpFiBT68JfYA CSVA/SrVfqYh/Hmu1deylq9Krk9Kcduv7CrxkEsBhFoqvLFONAwDKPQhZy8O5sG1ehzN t7p9OZzD6K3sl67IXRXl0R4a41LC4Yfbi1EyZK8A6QUeVJcUUXDPvx4VOnZ0ZAYNHMXL OdzcZZ3HXEhDp38vAqURCzJ94ZsFvXPt53iH2F/+sZTCDms/5vTSjcA/ZYp/MO/CBTyV OMrg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=cSVFEnb9; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k2-20020aa79982000000b0063b7bb98251si2355348pfh.216.2023.05.05.09.51.23; Fri, 05 May 2023 09:51:45 -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=@suse.cz header.s=susede2_rsa header.b=cSVFEnb9; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230387AbjEEQvA (ORCPT + 99 others); Fri, 5 May 2023 12:51:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40832 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229781AbjEEQu7 (ORCPT ); Fri, 5 May 2023 12:50:59 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DEAA113843; Fri, 5 May 2023 09:50:58 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 8F41C228C4; Fri, 5 May 2023 16:50:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1683305457; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=zPT0GNbrLPn2WOzHVENqDErkuUZ+X4IxxxJ3W2ZkErM=; b=cSVFEnb94dbwMgOTFX4MBhewNl2CKXGBZKtc/sXNdVmwvJNCkCHjoy6dW+dnR3UOjS8ys4 pbe0EcJpkahfcEdoudxVWOr8eVvpf4eexIcQ7LpCjF8Cp7Gk+6A0BNc+h7IP11qsLs10FM jjs7yAS+YBOuUHQNfNM2qyv+RKmFi8Q= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1683305457; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=zPT0GNbrLPn2WOzHVENqDErkuUZ+X4IxxxJ3W2ZkErM=; b=L5BgV2ruVzmdMQT02Xefv5VEnPbF3ZweHV39ppuRF1TjxykM4KSpUKRg4rMduaU8CKGpys 0P0FjWt+cJauaPDQ== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 7B81913513; Fri, 5 May 2023 16:50:57 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id XQEZHvEzVWSCNAAAMHmgww (envelope-from ); Fri, 05 May 2023 16:50:57 +0000 Received: by quack3.suse.cz (Postfix, from userid 1000) id 034F3A0729; Fri, 5 May 2023 18:50:56 +0200 (CEST) Date: Fri, 5 May 2023 18:50:56 +0200 From: Jan Kara To: Baokun Li Cc: linux-ext4@vger.kernel.org, tytso@mit.edu, adilger.kernel@dilger.ca, jack@suse.cz, ritesh.list@gmail.com, linux-kernel@vger.kernel.org, yi.zhang@huawei.com, yangerkun@huawei.com, yukuai3@huawei.com, syzbot+08106c4b7d60702dbc14@syzkaller.appspotmail.com Subject: Re: [PATCH] ext4: check iomap type only if ext4_iomap_begin() does not fail Message-ID: <20230505165056.7yjsh5nlaf4blvh5@quack3> References: <20230505132429.714648-1-libaokun1@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230505132429.714648-1-libaokun1@huawei.com> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,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 Fri 05-05-23 21:24:29, Baokun Li wrote: > When ext4_iomap_overwrite_begin() calls ext4_iomap_begin() map blocks may > fail for some reason (e.g. memory allocation failure, bare disk write), and > later because "iomap->type ! = IOMAP_MAPPED" triggers WARN_ON(). When ext4 > iomap_begin() returns an error, it is normal that the type of iomap->type > may not match the expectation. Therefore, we only determine if iomap->type > is as expected when ext4_iomap_begin() is executed successfully. > > Reported-by: syzbot+08106c4b7d60702dbc14@syzkaller.appspotmail.com > Link: https://lore.kernel.org/all/00000000000015760b05f9b4eee9@google.com > Signed-off-by: Baokun Li Makes sense. Feel free to add: Reviewed-by: Jan Kara Honza > diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c > index 0d5ba922e411..19c884abe52b 100644 > --- a/fs/ext4/inode.c > +++ b/fs/ext4/inode.c > @@ -3375,7 +3375,7 @@ static int ext4_iomap_overwrite_begin(struct inode *inode, loff_t offset, > */ > flags &= ~IOMAP_WRITE; > ret = ext4_iomap_begin(inode, offset, length, flags, iomap, srcmap); > - WARN_ON_ONCE(iomap->type != IOMAP_MAPPED); > + WARN_ON_ONCE(!ret && iomap->type != IOMAP_MAPPED); > return ret; > } > > -- > 2.31.1 > -- Jan Kara SUSE Labs, CR