Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp825486ybe; Fri, 6 Sep 2019 07:54:23 -0700 (PDT) X-Google-Smtp-Source: APXvYqzSyI+Ah1ubpKaxG2+qK7BeqVD+Lf9/EOZmGYKcy+fPTp/UCGwrmRVAkOFO2ZqMgBsMcxG5 X-Received: by 2002:a65:6904:: with SMTP id s4mr8261104pgq.33.1567781663479; Fri, 06 Sep 2019 07:54:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567781663; cv=none; d=google.com; s=arc-20160816; b=jY/TCNN5kv7mp778aNy+TVfWj897L1uOMaeI9ujTvVZIG951ZPJxx+V72myeRFNywp hjaWwqhx2DXYeW4S2+1LvwS0ZIcLaUJXgyk0o/y6gtjgAsGR0x1YdLjRHtWkvIyBsaNV mBU8y+Nv3ztYl8xs43EmxGGJ2fb5ep+LCKsTRPTQ3m22f3vawuNE0ZqYsiwKso8mElNl Ql19zcryyQzqR4C1wmH6vcsHxvdkRvMZMzvoXY0vh6CocRIt7sB39J4VAL+ot/GtJP3m APn2YS1gI38H9aSqf2VOAOiWN9glO2WHq3SwX2kdK9wSFS6RLZ1QEUQztmSUb8BBGkiP U2cQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from; bh=gxEd1qWIa9bzSNun2/1u+g/ijFB29k7R3TvHSCxz3j8=; b=jwjBc/yqhlyMoDZm68cUsVXgKi+0vdYsucTJIeS6i+smbFw1krQs7JxIqJVLZRIVCC 8+z6hBouMe5BXK1ozAOyZqHivbfpFQLJS4AOeQHrsHjyzhQXfG4T+EVfW1h01Rm89WQd vkiRlnX3e5aopDnYWWWbLPhyVz6+07tD+Eq/HZenQW7E44eUXEqDI2Tp3xFXv5jjkQus Lfryyshe8u40EcVQKlngAMRhCC9NUiRCbepY7Aed25trz9ZqESI6pBfKz8IJSDBeJ5Ny ZlSlukep+cDafX42Kno8IXKeRO4HFWkHX4jjnIzduNXZhQUgxpW7P8Jf8ofo1kmHAIyl b4mw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t13si4963470plo.287.2019.09.06.07.54.06; Fri, 06 Sep 2019 07:54:23 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391377AbfIFKyn (ORCPT + 99 others); Fri, 6 Sep 2019 06:54:43 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:6693 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728218AbfIFKym (ORCPT ); Fri, 6 Sep 2019 06:54:42 -0400 Received: from DGGEMS407-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 049A9D59D406580C3DA1; Fri, 6 Sep 2019 18:54:41 +0800 (CST) Received: from szvp000203569.huawei.com (10.120.216.130) by DGGEMS407-HUB.china.huawei.com (10.3.19.207) with Microsoft SMTP Server id 14.3.439.0; Fri, 6 Sep 2019 18:54:30 +0800 From: Chao Yu To: CC: , , , Chao Yu Subject: [PATCH] f2fs: fix to avoid accessing uninitialized field of inode page in is_alive() Date: Fri, 6 Sep 2019 18:54:26 +0800 Message-ID: <20190906105426.109151-1-yuchao0@huawei.com> X-Mailer: git-send-email 2.18.0.rc1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.120.216.130] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If inode is newly created, inode page may not synchronize with inode cache, so fields like .i_inline or .i_extra_isize could be wrong, in below call path, we may access such wrong fields, result in failing to migrate valid target block. - gc_data_segment - is_alive - datablock_addr - offset_in_addr Fixes: 7a2af766af15 ("f2fs: enhance on-disk inode structure scalability") Signed-off-by: Chao Yu --- fs/f2fs/dir.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fs/f2fs/dir.c b/fs/f2fs/dir.c index 765f13354d3f..b1840852967e 100644 --- a/fs/f2fs/dir.c +++ b/fs/f2fs/dir.c @@ -479,6 +479,9 @@ struct page *f2fs_init_inode_metadata(struct inode *inode, struct inode *dir, if (IS_ERR(page)) return page; + /* synchronize inode page's data from inode cache */ + f2fs_update_inode(inode, page); + if (S_ISDIR(inode->i_mode)) { /* in order to handle error case */ get_page(page); -- 2.18.0.rc1