From patchwork Mon Feb 20 06:32:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Konstantin Komarov X-Patchwork-Id: 59267 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1165859wrn; Sun, 19 Feb 2023 22:59:03 -0800 (PST) X-Google-Smtp-Source: AK7set80uvOoX7XtCinX0B9/+fdEsnqoff68ELJ+06ltpv+pq0DVCcdIdrkuhD3MfcRC76SXc8Jg X-Received: by 2002:a05:6a21:7899:b0:c6:bd82:ea2d with SMTP id bf25-20020a056a21789900b000c6bd82ea2dmr12179119pzc.2.1676876343595; Sun, 19 Feb 2023 22:59:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676876343; cv=none; d=google.com; s=arc-20160816; b=YL/qTZtYhdtIhtq4ZVPpuAwb3dnklQU0FUt1VcFNhqP8HZzlsPsO8gZFCZTbmICAkN A5IOUkRmnDHuTn9ZToYdN4S4XgEbkvYgPtrdPndsZqwQWKNfokgTuXhyIyQ+f8pUwpcy xfK/bet3TtfdM41O21xbQuYMLwvk/0RhfAfekPFVdYdgvVW7vgtgup6wGIJK0p5df4CC R5c8rH1e0BJx96vk/ki7RRJ9JxM5C8v7yUi56eFnoLYxMmAIvghMFVWvET7gGkBJpnBc +K/iAZzqKARFNzzOJDLTo0xbzKSIaL8+7uqVpas4vyiS4ar+Lhd3NaIxlcrEHuabrfOL c3bg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:subject:from:cc:to :content-language:user-agent:mime-version:date:message-id :dkim-signature; bh=YtXxZ6e5RLyaBmSaXafOMars1uaos3f4mgep2CPSeUg=; b=nQQv804hqbUpOEYskPORDQJ+QKlwG+HokIltgY8rM4FQV+JPOu1OQA43Ry23DssWsy 07q4b4sp3RhPh4J7ijJr1utJMjrUrqAyE7PVzvo4L7uUqpNVQvfKgxwjgJMnKnQaO/pk 4t7evMCR6K8mpZAv2dPuyLhHiXB2QquVwp6TU0bT0aiY1PY3OgfjEjRmi0wkzho3AUcA 2RcuVH+iz8WeE0ru8VbZDqPX/Tn+cHx5V2WXvJnbfThAiJs1by6SnAKmPoXGipz+aiJb 7ZMBbuhD5pzrqJwyLlFFIoXDZMW2anntKpb1GCyH1XIT8KlF+boy09Q4wyqY/NitDPMb fIfA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@paragon-software.com header.s=mail header.b=u7g0ARmw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=paragon-software.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h21-20020a056a00219500b005a8bdfeef8csi14218647pfi.367.2023.02.19.22.58.50; Sun, 19 Feb 2023 22:59:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@paragon-software.com header.s=mail header.b=u7g0ARmw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=paragon-software.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230250AbjBTGc1 (ORCPT + 99 others); Mon, 20 Feb 2023 01:32:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53214 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229662AbjBTGc0 (ORCPT ); Mon, 20 Feb 2023 01:32:26 -0500 Received: from relayaws-01.paragon-software.com (relayaws-01.paragon-software.com [35.157.23.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 59F34EB7C; Sun, 19 Feb 2023 22:32:23 -0800 (PST) Received: from dlg2.mail.paragon-software.com (vdlg-exch-02.paragon-software.com [172.30.1.105]) by relayaws-01.paragon-software.com (Postfix) with ESMTPS id DE1851D3F; Mon, 20 Feb 2023 06:28:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paragon-software.com; s=mail; t=1676874488; bh=YtXxZ6e5RLyaBmSaXafOMars1uaos3f4mgep2CPSeUg=; h=Date:To:CC:From:Subject; b=u7g0ARmwjwMj+BrUnDHQHYScdnAKxkHcDoIuM8/l0sq0TGUvtf55cvGSbGxGxkfUl lLN9gyOdwkhB8es6fmxcw+FuoZX1M78QQ3kxLzbl9giqeaXM1ETMq1ZuPSH04UXHJT IkXjgJ8BFbxJDL9dadnp/eADPac2HQMQ64+ZkyUk= Received: from [192.168.211.142] (192.168.211.142) by vdlg-exch-02.paragon-software.com (172.30.1.105) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.7; Mon, 20 Feb 2023 09:32:20 +0300 Message-ID: <5de3e85e-3c8e-cc80-c825-481ac9f94f9a@paragon-software.com> Date: Mon, 20 Feb 2023 10:32:20 +0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.8.0 Content-Language: en-US To: CC: Linux Kernel Mailing List , , Dan Carpenter From: Konstantin Komarov Subject: [PATCH] fs/ntfs3: Fix root inode checking X-Originating-IP: [192.168.211.142] X-ClientProxiedBy: vobn-exch-01.paragon-software.com (172.30.72.13) To vdlg-exch-02.paragon-software.com (172.30.1.105) X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1758332288671338867?= X-GMAIL-MSGID: =?utf-8?q?1758332288671338867?= Separate checking inode->i_op and inode itself. Reported-by: kernel test robot Reported-by: Dan Carpenter Link: https://lore.kernel.org/r/202302162319.bDJOuyfy-lkp@intel.com/ Signed-off-by: Konstantin Komarov ---  fs/ntfs3/super.c | 11 ++++++++++-  1 file changed, 10 insertions(+), 1 deletion(-)          err = -ENOMEM; diff --git a/fs/ntfs3/super.c b/fs/ntfs3/super.c index e0f78b306f15..5158dd31fd97 100644 --- a/fs/ntfs3/super.c +++ b/fs/ntfs3/super.c @@ -1347,12 +1347,21 @@ static int ntfs_fill_super(struct super_block *sb, struct fs_context *fc)      ref.low = cpu_to_le32(MFT_REC_ROOT);      ref.seq = cpu_to_le16(MFT_REC_ROOT);      inode = ntfs_iget5(sb, &ref, &NAME_ROOT); -    if (IS_ERR(inode) || !inode->i_op) { +    if (IS_ERR(inode)) {          err = PTR_ERR(inode);          ntfs_err(sb, "Failed to load root (%d).", err);          goto out;      } +    /* +     * Final check. Looks like this case should never occurs. +     */ +    if (!inode->i_op) { +        err = -EINVAL; +        ntfs_err(sb, "Failed to load root (%d).", err); +        goto put_inode_out; +    } +      sb->s_root = d_make_root(inode);      if (!sb->s_root) {