From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751594AbeA2IaF (ORCPT ); Mon, 29 Jan 2018 03:30:05 -0500 Received: from szxga05-in.huawei.com ([45.249.212.191]:4741 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751127AbeA2IaA (ORCPT ); Mon, 29 Jan 2018 03:30:00 -0500 From: Chao Yu To: CC: , , , Chao Yu Subject: [PATCH] f2fs: add sanity check for quota sysfile ino Date: Mon, 29 Jan 2018 16:29:33 +0800 Message-ID: <20180129082933.64556-1-yuchao0@huawei.com> X-Mailer: git-send-email 2.15.0.55.gc2ece9dc4de6 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 List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add missing sanity check for quota sysfile ino. Signed-off-by: Chao Yu --- fs/f2fs/super.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c index 368f63d7bad2..6011071688ca 100644 --- a/fs/f2fs/super.c +++ b/fs/f2fs/super.c @@ -2116,6 +2116,25 @@ static int sanity_check_raw_super(struct f2fs_sb_info *sbi, return 1; } + /* check quota sysfile ino info */ + if (raw_super->feature & cpu_to_le32(F2FS_FEATURE_QUOTA_INO)) { + if (le32_to_cpu(raw_super->qf_ino[0]) != 4 || + le32_to_cpu(raw_super->qf_ino[1]) != 5) { + f2fs_msg(sb, KERN_INFO, + "Invalid Quota Ino: user_ino(%u), grp_ino(%u)", + le32_to_cpu(raw_super->qf_ino[0]), + le32_to_cpu(raw_super->qf_ino[1])); + return 1; + } + if (raw_super->feature & cpu_to_le32(F2FS_FEATURE_PRJQUOTA) && + le32_to_cpu(raw_super->qf_ino[2]) != 6) { + f2fs_msg(sb, KERN_INFO, + "Invalid Quota Ino: prj_ino(%u)", + le32_to_cpu(raw_super->qf_ino[2])); + return 1; + } + } + if (le32_to_cpu(raw_super->segment_count) > F2FS_MAX_SEGMENT) { f2fs_msg(sb, KERN_INFO, "Invalid segment count (%u)", -- 2.15.0.55.gc2ece9dc4de6