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 X-Spam-Level: X-Spam-Status: No, score=-8.7 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BEC33C31E49 for ; Thu, 13 Jun 2019 16:17:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9827421721 for ; Thu, 13 Jun 2019 16:17:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1560442660; bh=Y15hjPBH+nSlxC4voQ82jeXo2L7vsIrjbrubboSV2WQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=sJjAxW9TkFiJAXpfGaOpayn6Pfem0p0Ip4Kia6WwOQM4LAFQHCJlybCTUVoP6bFwX ux8ltOMFPPFbdqmu55otxCQuKDuz4q8zVP4ht+qooXJagmTruPB74aYRhjshCL3mFY yV6zfHNW5auF17e7TvoH6d7d1M8qz9jwSgaT5rVg= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387466AbfFMQRj (ORCPT ); Thu, 13 Jun 2019 12:17:39 -0400 Received: from mail.kernel.org ([198.145.29.99]:58078 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731128AbfFMIkm (ORCPT ); Thu, 13 Jun 2019 04:40:42 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 9861D20851; Thu, 13 Jun 2019 08:40:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1560415242; bh=Y15hjPBH+nSlxC4voQ82jeXo2L7vsIrjbrubboSV2WQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qyt1E26F2Dfk1jfx6qu+0uUWhKjkhg7GuN/6RJnZLnMsaU//5yvmra0kDl12QMhil HZcsV8bdHhg/ZBtm38Vid+ugcU0bw5bYjiArlyWGQX7BAXSZAhgaD1F9cQ5U7jy6tU YcSpj0aHRT/smURsWXEABlEW2bQ2kTKeV8bApvAs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Chao Yu , Jaegeuk Kim , Sasha Levin Subject: [PATCH 4.19 037/118] f2fs: fix to clear dirty inode in error path of f2fs_iget() Date: Thu, 13 Jun 2019 10:32:55 +0200 Message-Id: <20190613075645.673000326@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190613075643.642092651@linuxfoundation.org> References: <20190613075643.642092651@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org [ Upstream commit 546d22f070d64a7b96f57c93333772085d3a5e6d ] As Jungyeon reported in bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=203217 - Overview When mounting the attached crafted image and running program, I got this error. Additionally, it hangs on sync after running the program. The image is intentionally fuzzed from a normal f2fs image for testing and I enabled option CONFIG_F2FS_CHECK_FS on. - Reproduces cc poc_test_05.c mkdir test mount -t f2fs tmp.img test sudo ./a.out sync - Messages kernel BUG at fs/f2fs/inode.c:707! RIP: 0010:f2fs_evict_inode+0x33f/0x3a0 Call Trace: evict+0xba/0x180 f2fs_iget+0x598/0xdf0 f2fs_lookup+0x136/0x320 __lookup_slow+0x92/0x140 lookup_slow+0x30/0x50 walk_component+0x1c1/0x350 path_lookupat+0x62/0x200 filename_lookup+0xb3/0x1a0 do_readlinkat+0x56/0x110 __x64_sys_readlink+0x16/0x20 do_syscall_64+0x43/0xf0 entry_SYSCALL_64_after_hwframe+0x44/0xa9 During inode loading, __recover_inline_status() can recovery inode status and set inode dirty, once we failed in following process, it will fail the check in f2fs_evict_inode, result in trigger BUG_ON(). Let's clear dirty inode in error path of f2fs_iget() to avoid panic. Signed-off-by: Chao Yu Signed-off-by: Jaegeuk Kim Signed-off-by: Sasha Levin --- fs/f2fs/inode.c | 1 + 1 file changed, 1 insertion(+) diff --git a/fs/f2fs/inode.c b/fs/f2fs/inode.c index dd608b819a3c..fae9570e6860 100644 --- a/fs/f2fs/inode.c +++ b/fs/f2fs/inode.c @@ -476,6 +476,7 @@ make_now: return inode; bad_inode: + f2fs_inode_synced(inode); iget_failed(inode); trace_f2fs_iget_exit(inode, ret); return ERR_PTR(ret); -- 2.20.1