Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp10787137imu; Thu, 6 Dec 2018 06:49:40 -0800 (PST) X-Google-Smtp-Source: AFSGD/U/0v4y79OIAu2QNZ7/Y8VzqdCl/RdgvsPO+Kh6Kmjr7Kd11vwqM8jjgZ6IdJb1huC9NeCy X-Received: by 2002:a17:902:a9c4:: with SMTP id b4mr28553723plr.298.1544107780257; Thu, 06 Dec 2018 06:49:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544107780; cv=none; d=google.com; s=arc-20160816; b=TSta3NxExY2KUG9stfn//lAWUeJqNonDIcflC0TZt035qOKD9jFWx7KxCvGWa4mX3u AfVbEdA8OWg4vL68p6CWRO1mkAieWwFX3/UmraRGPDwOP3e5P8Hkf0xngx1bY9P1DhBH 6gbFnM0QzDsk1cCk+sV07Wgq2BGWT7oeTfrdxV1JypAzkJJrZrdvL1bn/5A30VQcpYUx tscvJGGjARDd7a2RNLnDa5rYAKUQp8HFQJ+Tn75muZTduoghd7GttJ/roj0cbpB8z/h5 CFgQyXEKhf/FbDFcbOyWTlOEUqiZGKzg+QYQe2j774upfFb5kVy9zFLunHaBRwHuQtHt OMaA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=PuCjCRcjUnmcDd0Kz/HVUClVD1cR3GPVrC3Gxq4v3qw=; b=XrgstXKuSrA7rqmI1o0zv0JQmIjGxi+oxlYq2DfEzsJjXAAaUCKZzfY0IJYhxdfJSR tQw9pgoUp7kidTBnEVk8uhVTJIwBTzahwOljTA+Nv86crWVFhQWZ2SNiz8lWMK8HPJkl LGelvyAzxhIkC784QAeToghPk1jgwvNmB8QbXpu1hxp+RbgfI04uWixp/+JyQDt2ByaY kaFwNkhF1AL0RVSxbw12gBnvIFplvS4BnD26+wENvu1HXBSX7pP/GK36AXMUljnNNJF8 PvaQS7kTPMLk2g+Cob2Z4KCEbDpNg6w3szp6bPnwITt36AAaGkwi6BxtwihGSsRtP/F9 8KaA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=PB0JYf23; 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 w19si441436pgc.96.2018.12.06.06.49.19; Thu, 06 Dec 2018 06:49:40 -0800 (PST) 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; dkim=pass header.i=@kernel.org header.s=default header.b=PB0JYf23; 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 S1730678AbeLFOr5 (ORCPT + 99 others); Thu, 6 Dec 2018 09:47:57 -0500 Received: from mail.kernel.org ([198.145.29.99]:52932 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731503AbeLFOru (ORCPT ); Thu, 6 Dec 2018 09:47:50 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.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 B1B9621479; Thu, 6 Dec 2018 14:47:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1544107670; bh=nLNTGs0u1yjXrSpnDEKfdMLhqPbEcTYKzgcL1P8ZKbo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PB0JYf23W+6egPKpnzZUHkWJgMZbIzhY0+ZWpQyfN/2YGPigxCLkLo0oD92SZ16l+ k2VZB2fbvCfTMuy+GmAcJMzI0vS3c+2MTyfxjlL3n/s7/rIMbe0qki/Q6mGIPQ44jD PR5uEk8yct55zWdM3G/RpJSZBkkNymWZf2tZkuug= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jaegeuk Kim , Chao Yu , Ben Hutchings Subject: [PATCH 4.9 094/101] f2fs: Add sanity_check_inode() function Date: Thu, 6 Dec 2018 15:39:33 +0100 Message-Id: <20181206143018.404273274@linuxfoundation.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181206143011.174892052@linuxfoundation.org> References: <20181206143011.174892052@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Ben Hutchings This was done as part of commits 5d64600d4f33 "f2fs: avoid bug_on on corrupted inode" and 76d56d4ab4f2 "f2fs: fix to do sanity check with extra_attr feature" upstream, but the specific checks they added are not applicable to 4.9. Cc: Jaegeuk Kim Cc: Chao Yu Signed-off-by: Ben Hutchings Signed-off-by: Greg Kroah-Hartman --- fs/f2fs/inode.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) --- a/fs/f2fs/inode.c +++ b/fs/f2fs/inode.c @@ -104,6 +104,13 @@ static void __recover_inline_status(stru return; } +static bool sanity_check_inode(struct inode *inode) +{ + struct f2fs_sb_info *sbi = F2FS_I_SB(inode); + + return true; +} + static int do_read_inode(struct inode *inode) { struct f2fs_sb_info *sbi = F2FS_I_SB(inode); @@ -153,6 +160,11 @@ static int do_read_inode(struct inode *i get_inline_info(inode, ri); + if (!sanity_check_inode(inode)) { + f2fs_put_page(node_page, 1); + return -EINVAL; + } + /* check data exist */ if (f2fs_has_inline_data(inode) && !f2fs_exist_data(inode)) __recover_inline_status(inode, node_page);