Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3686411pxb; Mon, 24 Jan 2022 15:20:56 -0800 (PST) X-Google-Smtp-Source: ABdhPJwu/J47Bb90/d99cAwEsPNIUPPyMrja6sBDWJ3IdkAQQOBtzeXVlHRwWN/O1xmmmU+UXjDZ X-Received: by 2002:a63:2b84:: with SMTP id r126mr13362215pgr.624.1643066330065; Mon, 24 Jan 2022 15:18:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643066330; cv=none; d=google.com; s=arc-20160816; b=SbpeYbwZcTGBiE19XBudIclUkLXJSkEh3uBxLh4ulU628x1drdiMTvSi2+ptYWleOH DcFLGOdHWorgsOvOcG4LrUmJA2ZE1wo6KVwZn9XXam/0X4k4R3KCVmvnANAC3155sUES gvKF6DL6HuJ3ahNmIeJcs2wAHqFHq2WgKiodKVc9Xk/jkSdTMcGEe9QGSK1I3LGD8aAw 7VPB162LgrjVhFbK0Tm6hWWM9L63FujJMy54MMboyFbyq0AcuLR9KHJOD5Fn3DUjMT+/ EfmamPwOGHiCVK+cR9oqPuELsB97cvnD/f/pGW/Fu7HKDsvOjAYACmj/XmWQkPvsbb4I AVmA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=wOr1xmQW3Tb2/i4fsBBxjiLgf+T+VTAUOn4jLB1gguE=; b=C3FsYjPAYGy0G2SBHsTSVuU0fLDxag0SCIhnO0xBSH/eDdASNd717cmw/WHTy97VaZ knSQM0x1j+0OyDM4Ai2VMu1Rlfa7rKQvnOr23drUhyWmm2c1OpzWmdyQGEz87SlwLcJO oP+pZP5mjbFwcj2N64UOpF/szMg+Yym/e1EWFh2ie4rX8pjkTXz18isBQDxd3V3ohtyC VKXQsjBaTPzkGv3cEburfWXrCDuIgq9ge5V0B8Ero8eGDyzl/0Z3LfDixvehcA9T9Suz qgMURy/x50nz1MKLBob0zVpGZVHiKIoEkfIdGR0Pn6VQY7j5S26r9atUvmCBpbd/IlUU c+Pg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=sbYd6o4O; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l7si13833873plt.163.2022.01.24.15.18.38; Mon, 24 Jan 2022 15:18:50 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=sbYd6o4O; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1846378AbiAXXPu (ORCPT + 99 others); Mon, 24 Jan 2022 18:15:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37664 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1584691AbiAXWVd (ORCPT ); Mon, 24 Jan 2022 17:21:33 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C111AC041883; Mon, 24 Jan 2022 12:52:55 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 6190F611F9; Mon, 24 Jan 2022 20:52:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3F3CDC340EA; Mon, 24 Jan 2022 20:52:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643057574; bh=jfuQ8/SSqqyyt5xvg642+GN2e1J3uMhRUlEhGKuxvSs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sbYd6o4OTYEelV+sjCyH77yhzhsV5Sv9M6aQcgzAXs3QohWNE8pNTCOy3++9xm/DD xdmJc176xvEXfS0q0IHLbmlRY4SHy+EIlBqAoTGJRKkAv3nlAPW0ZwAWEKB31MsgU/ y6k33IMzrPRjRBLUtNd+OyuyIScK2sKSVatvMUBw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Chao Yu , Jaegeuk Kim Subject: [PATCH 5.16 0011/1039] f2fs: fix to do sanity check in is_alive() Date: Mon, 24 Jan 2022 19:30:00 +0100 Message-Id: <20220124184125.525171284@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184125.121143506@linuxfoundation.org> References: <20220124184125.121143506@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Chao Yu commit 77900c45ee5cd5da63bd4d818a41dbdf367e81cd upstream. In fuzzed image, SSA table may indicate that a data block belongs to invalid node, which node ID is out-of-range (0, 1, 2 or max_nid), in order to avoid migrating inconsistent data in such corrupted image, let's do sanity check anyway before data block migration. Cc: stable@vger.kernel.org Signed-off-by: Chao Yu Signed-off-by: Jaegeuk Kim Signed-off-by: Greg Kroah-Hartman --- fs/f2fs/gc.c | 3 +++ 1 file changed, 3 insertions(+) --- a/fs/f2fs/gc.c +++ b/fs/f2fs/gc.c @@ -1026,6 +1026,9 @@ static bool is_alive(struct f2fs_sb_info set_sbi_flag(sbi, SBI_NEED_FSCK); } + if (f2fs_check_nid_range(sbi, dni->ino)) + return false; + *nofs = ofs_of_node(node_page); source_blkaddr = data_blkaddr(NULL, node_page, ofs_in_node); f2fs_put_page(node_page, 1);