Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp3292762rwa; Tue, 23 Aug 2022 02:08:13 -0700 (PDT) X-Google-Smtp-Source: AA6agR4y/gthNeC7jp/PTshoeFcrQ7ng3N/G5tEKbfhEJVLPIE0K+YXMcRwuPrthi+QTbXZT0Ew0 X-Received: by 2002:a17:907:2cea:b0:73d:a431:6b6c with SMTP id hz10-20020a1709072cea00b0073da4316b6cmr813218ejc.423.1661245692818; Tue, 23 Aug 2022 02:08:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661245692; cv=none; d=google.com; s=arc-20160816; b=uAO/E11e5SRD+xhCex/fNc7rfGA0r3q+N43udVY1FUy+VVeflD0WAAgJO6P/6/D84q N9AQ62dj2sIkILYAAfnT6Xi8TeE64++fHkYkTjBkLfuEwq8kl9InhzDKs2xsxk8vW1pM KeyIXnW+v9n72ZPBl4AvG3xslb7hXFX4NBJuUsAmEzv7vwL5cEXJp5sypyPosioq8MMQ 1erTag3xkp9+9ulIo4YoKRPoltLPLRzyM33WzcSdpE+fv2YLmkyBqQz9Z7fjsG97J/0c dRq9FejeS6kBqri8iBpOoXDDlLJTDkpi3ZjQEACiVEnjGcHuhXsqI5Rj3rJ3KjH+KDJ/ hGRg== 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=5Zngt3veOpNK9Lst+B9V5WP3u8SidCOjft0SFAtKKxk=; b=ne8t/C6gpBycldeT2vPXjMXpQI4opOb9tbDTajzSIHQ5bCv8BUbpslxAHh5u+9nTU4 5e9VvxZy8QdLZ1MjdePXcXFKJMly/xqipGh3ZSHYAk8XHVrxDCMohmiIz9FqpMgMgUpY zEu3GmLIMkV3iZYHMU234NvmDPpYt9AiGJdbwDmME5TIF6Agu7pScVAgRH0v0YSRl7gj 9BhmsmuJZTkcAz34v90aW+YyBwiYyjBYkNnXVAg7fia9G4FuGhCZxiBTvRWvf1cvISfX zw1IxP8beBkeDNudZDNSmasEsHhNvZTxBF9RbsG+yqpBW02FV9pmmxffyqvusCO93Cwo LRUg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=CiooeHt8; 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=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hz1-20020a1709072ce100b007316cc27ab0si10524519ejc.980.2022.08.23.02.07.45; Tue, 23 Aug 2022 02:08:12 -0700 (PDT) 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=@linuxfoundation.org header.s=korg header.b=CiooeHt8; 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=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344438AbiHWInC (ORCPT + 99 others); Tue, 23 Aug 2022 04:43:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46810 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346629AbiHWIk1 (ORCPT ); Tue, 23 Aug 2022 04:40:27 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 64D115F9BD; Tue, 23 Aug 2022 01:18:50 -0700 (PDT) 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 1476061367; Tue, 23 Aug 2022 08:17:57 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0EBDFC433C1; Tue, 23 Aug 2022 08:17:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1661242676; bh=g0ljEhDQMy0x7RlhJ7S6O9duSphc00Lp5+QaDZm3Jek=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CiooeHt8h8MixqlG/UtXqhVo8im7C792c1uAshkvUXOeMlotT2ppsQnR0ckY+HqsW nQ5Pnn8Ak+EhlF4z0HB70G/4Znb2qu1zZptFb05YToWF2kkqzMdkSIPNA9HZH+jXON PK4oQpcxjD6gqntR/GT9ULBDoUA7Ucxe8KhFCs5A= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Pavel Skripkin , Konstantin Komarov , syzbot+c95173762127ad76a824@syzkaller.appspotmail.com Subject: [PATCH 5.19 161/365] fs/ntfs3: Fix NULL deref in ntfs_update_mftmirr Date: Tue, 23 Aug 2022 10:01:02 +0200 Message-Id: <20220823080124.951238235@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220823080118.128342613@linuxfoundation.org> References: <20220823080118.128342613@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 From: Pavel Skripkin commit 321460ca3b55f48b3ba6008248264ab2bd6407d9 upstream. If ntfs_fill_super() wasn't called then sbi->sb will be equal to NULL. Code should check this ptr before dereferencing. Syzbot hit this issue via passing wrong mount param as can be seen from log below Fail log: ntfs3: Unknown parameter 'iochvrset' general protection fault, probably for non-canonical address 0xdffffc0000000003: 0000 [#1] PREEMPT SMP KASAN KASAN: null-ptr-deref in range [0x0000000000000018-0x000000000000001f] CPU: 1 PID: 3589 Comm: syz-executor210 Not tainted 5.18.0-rc3-syzkaller-00016-gb253435746d9 #0 ... Call Trace: put_ntfs+0x1ed/0x2a0 fs/ntfs3/super.c:463 ntfs_fs_free+0x6a/0xe0 fs/ntfs3/super.c:1363 put_fs_context+0x119/0x7a0 fs/fs_context.c:469 do_new_mount+0x2b4/0xad0 fs/namespace.c:3044 do_mount fs/namespace.c:3383 [inline] __do_sys_mount fs/namespace.c:3591 [inline] Fixes: 82cae269cfa9 ("fs/ntfs3: Add initialization of super block") Reported-and-tested-by: syzbot+c95173762127ad76a824@syzkaller.appspotmail.com Signed-off-by: Pavel Skripkin Signed-off-by: Konstantin Komarov Signed-off-by: Greg Kroah-Hartman --- fs/ntfs3/fsntfs.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) --- a/fs/ntfs3/fsntfs.c +++ b/fs/ntfs3/fsntfs.c @@ -831,10 +831,15 @@ int ntfs_update_mftmirr(struct ntfs_sb_i { int err; struct super_block *sb = sbi->sb; - u32 blocksize = sb->s_blocksize; + u32 blocksize; sector_t block1, block2; u32 bytes; + if (!sb) + return -EINVAL; + + blocksize = sb->s_blocksize; + if (!(sbi->flags & NTFS_FLAGS_MFTMIRR)) return 0;