From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 61412C636D4 for ; Tue, 14 Feb 2023 01:47:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230130AbjBNBq7 (ORCPT ); Mon, 13 Feb 2023 20:46:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50336 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229977AbjBNBq5 (ORCPT ); Mon, 13 Feb 2023 20:46:57 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5D14219F2E for ; Mon, 13 Feb 2023 17:46:56 -0800 (PST) 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 ams.source.kernel.org (Postfix) with ESMTPS id ECFA6B819C8 for ; Tue, 14 Feb 2023 01:46:54 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 253CBC4339B; Tue, 14 Feb 2023 01:46:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1676339213; bh=+0BJys0OpkHX3oV/BPdHXI+zldnOERXmDqR0P9RpspE=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=dBHUmqKkkQYUMGwN2daTFvHHXIf0WEA/iUz8y2sfkXN+O7WxIT6UjFwCFAuZeXKus ArNFD1M10ZtrGJ5bZD7a2rzWPtJ5EoqV85m+I0G44h1tU6FfKUlbs15be7oWhawOOu qy1Mgk9Sb4ztJjLsGbYPGjw4yOcoCmBKK/eFlDiaUrjd7XvRE26JGZxo8ZJKuLLyMv OgPIscKmxUrD5jPeEibLDqFFQXGw/EMVZFikHOKcC+4awXtQaAtsjJDAxTSrouqMDR 6awrjgPzt8PN4Cq/xQLo0W068pjFp8VePeGmHdIstf/M6XTiJP+a8zcxY8IqzQ3QM9 O3XKveaBoWWoQ== Message-ID: <6160a9a2-16b9-e37c-eabc-57f71a1932af@kernel.org> Date: Tue, 14 Feb 2023 09:46:50 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.7.2 Subject: Re: [f2fs-dev] [PATCH] f2fs: synchronize atomic write aborts Content-Language: en-US To: Daeho Jeong Cc: linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, kernel-team@android.com, Daeho Jeong , syzbot+823000d23b3400619f7c@syzkaller.appspotmail.com References: <20230209181819.2333522-1-daeho43@gmail.com> <18916dd5-67cc-fe21-f78b-8a6dfbcb1c97@kernel.org> From: Chao Yu In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2023/2/14 4:14, Daeho Jeong wrote: >>> diff --git a/fs/f2fs/inode.c b/fs/f2fs/inode.c >>> index 28c9c72dda2a..7bf660d4cad9 100644 >>> --- a/fs/f2fs/inode.c >>> +++ b/fs/f2fs/inode.c >>> @@ -777,11 +777,18 @@ int f2fs_write_inode(struct inode *inode, struct writeback_control *wbc) >>> void f2fs_evict_inode(struct inode *inode) >>> { >>> struct f2fs_sb_info *sbi = F2FS_I_SB(inode); >>> - nid_t xnid = F2FS_I(inode)->i_xattr_nid; >>> + struct f2fs_inode_info *fi = F2FS_I(inode); >>> + nid_t xnid = fi->i_xattr_nid; >>> int err = 0; >>> >>> f2fs_abort_atomic_write(inode, true); >>> >>> + if (fi->cow_inode) { >>> + clear_inode_flag(fi->cow_inode, FI_COW_FILE); >>> + iput(fi->cow_inode); >>> + fi->cow_inode = NULL; >>> + } >> >> It looks "fi->cow_inode = NULL" here may race w/ cow_inode allocation in >> f2fs_ioc_start_atomic_write due to f2fs_write_inode() has not been covered >> by inode_lock()? IIUC. > > Sorry, I couldn't understand it, since I couldn't find any relation > between f2fs_ioc_start_atomic_write and f2fs_write_inode. Could you > elaborate more on this? I thought the code might be safe, since it > happens in the inode eviction phase. int f2fs_write_inode(struct inode *inode, struct writeback_control *wbc) void f2fs_evict_inode(struct inode *inode) Oops, it looks I was misled by f2fs_write_inode() above f2fs_evict_inode(), please ignore my comments, sorry. :( Thanks, From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.sourceforge.net (lists.sourceforge.net [216.105.38.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B8DFBC636CC for ; Tue, 14 Feb 2023 01:47:03 +0000 (UTC) Received: from [127.0.0.1] (helo=sfs-ml-4.v29.lw.sourceforge.com) by sfs-ml-4.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1pRkPP-0004y5-5m; Tue, 14 Feb 2023 01:47:03 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-4.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1pRkPN-0004xx-Pk for linux-f2fs-devel@lists.sourceforge.net; Tue, 14 Feb 2023 01:47:01 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:Content-Type:In-Reply-To: From:References:Cc:To:Subject:MIME-Version:Date:Message-ID:Sender:Reply-To: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=Z/AWFKn+ye+JRc5p2EQDhkyJhm1dx9oxgRHnD/NCG/E=; b=ASL5ocEa4LVQbUS0HvOsUDGKP9 X9T7m1zm+MAUHevE2YdDW2gV5M2URZQZNGpDKntwyRboPqqGYY15vnrorG/TJYNEA0fo/pTy8CwK8 S4CtWrNSqVD61beX5T7gTy1Y0Hsb3Y6pjjlecjU4ffrgnmpWTiUVDpGvItOKrGKxgITc=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:Content-Type:In-Reply-To:From:References:Cc:To: Subject:MIME-Version:Date:Message-ID:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=Z/AWFKn+ye+JRc5p2EQDhkyJhm1dx9oxgRHnD/NCG/E=; b=S2QMW7BDvAZIR8lTk6b/m+CH/X x0YvksYDYn29XFUJwJdKgggltGrP7gIuIMWGhDn+3zr3lhSheSrolhqKgELRhCKGGD2U2MD1+t8V0 6mg5G0TWaAD9Noae4AsHtvTCDjd2zcVjnZ/9Vgg31V4Vm8HZ60It5tN8Cpu+5JZrq/xg=; Received: from dfw.source.kernel.org ([139.178.84.217]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1pRkPK-0005Al-Bv for linux-f2fs-devel@lists.sourceforge.net; Tue, 14 Feb 2023 01:46:59 +0000 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 dfw.source.kernel.org (Postfix) with ESMTPS id B5B9461372; Tue, 14 Feb 2023 01:46:53 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 253CBC4339B; Tue, 14 Feb 2023 01:46:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1676339213; bh=+0BJys0OpkHX3oV/BPdHXI+zldnOERXmDqR0P9RpspE=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=dBHUmqKkkQYUMGwN2daTFvHHXIf0WEA/iUz8y2sfkXN+O7WxIT6UjFwCFAuZeXKus ArNFD1M10ZtrGJ5bZD7a2rzWPtJ5EoqV85m+I0G44h1tU6FfKUlbs15be7oWhawOOu qy1Mgk9Sb4ztJjLsGbYPGjw4yOcoCmBKK/eFlDiaUrjd7XvRE26JGZxo8ZJKuLLyMv OgPIscKmxUrD5jPeEibLDqFFQXGw/EMVZFikHOKcC+4awXtQaAtsjJDAxTSrouqMDR 6awrjgPzt8PN4Cq/xQLo0W068pjFp8VePeGmHdIstf/M6XTiJP+a8zcxY8IqzQ3QM9 O3XKveaBoWWoQ== Message-ID: <6160a9a2-16b9-e37c-eabc-57f71a1932af@kernel.org> Date: Tue, 14 Feb 2023 09:46:50 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.7.2 Content-Language: en-US To: Daeho Jeong References: <20230209181819.2333522-1-daeho43@gmail.com> <18916dd5-67cc-fe21-f78b-8a6dfbcb1c97@kernel.org> From: Chao Yu In-Reply-To: X-Headers-End: 1pRkPK-0005Al-Bv Subject: Re: [f2fs-dev] [PATCH] f2fs: synchronize atomic write aborts X-BeenThere: linux-f2fs-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Daeho Jeong , kernel-team@android.com, linux-kernel@vger.kernel.org, syzbot+823000d23b3400619f7c@syzkaller.appspotmail.com, linux-f2fs-devel@lists.sourceforge.net Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net On 2023/2/14 4:14, Daeho Jeong wrote: >>> diff --git a/fs/f2fs/inode.c b/fs/f2fs/inode.c >>> index 28c9c72dda2a..7bf660d4cad9 100644 >>> --- a/fs/f2fs/inode.c >>> +++ b/fs/f2fs/inode.c >>> @@ -777,11 +777,18 @@ int f2fs_write_inode(struct inode *inode, struct writeback_control *wbc) >>> void f2fs_evict_inode(struct inode *inode) >>> { >>> struct f2fs_sb_info *sbi = F2FS_I_SB(inode); >>> - nid_t xnid = F2FS_I(inode)->i_xattr_nid; >>> + struct f2fs_inode_info *fi = F2FS_I(inode); >>> + nid_t xnid = fi->i_xattr_nid; >>> int err = 0; >>> >>> f2fs_abort_atomic_write(inode, true); >>> >>> + if (fi->cow_inode) { >>> + clear_inode_flag(fi->cow_inode, FI_COW_FILE); >>> + iput(fi->cow_inode); >>> + fi->cow_inode = NULL; >>> + } >> >> It looks "fi->cow_inode = NULL" here may race w/ cow_inode allocation in >> f2fs_ioc_start_atomic_write due to f2fs_write_inode() has not been covered >> by inode_lock()? IIUC. > > Sorry, I couldn't understand it, since I couldn't find any relation > between f2fs_ioc_start_atomic_write and f2fs_write_inode. Could you > elaborate more on this? I thought the code might be safe, since it > happens in the inode eviction phase. int f2fs_write_inode(struct inode *inode, struct writeback_control *wbc) void f2fs_evict_inode(struct inode *inode) Oops, it looks I was misled by f2fs_write_inode() above f2fs_evict_inode(), please ignore my comments, sorry. :( Thanks, _______________________________________________ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel