Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp273911pxb; Thu, 25 Feb 2021 02:03:14 -0800 (PST) X-Google-Smtp-Source: ABdhPJz3whbZdpzwvLiZ2sw2RYniQhCPbB1SaNE/rUsB1yDEmtci6HpgSZ5Y77iEv5C3RvniAzgU X-Received: by 2002:a05:6402:1113:: with SMTP id u19mr1998233edv.205.1614247394343; Thu, 25 Feb 2021 02:03:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614247394; cv=none; d=google.com; s=arc-20160816; b=PxtVRogADwAlBLE9XK2Ar1pWDBmWkgpd4ezhvSm2wvTwG5LGLCgz77UJJTUxoAD10E EUFjeQ7dJd8od7XosbsXWoFIueuN7nj+Rjysk7QK+jlEvLNY2cmYOeAA75hm64lPMidq bbPVjLdgy1ap2OSX/FB/K2Kh9VlLzFfcLm7BjIZm7qg3Efa5TFSQWkGlFoV3F5DcB/QY rJLcz0byP7uFmfD5WZSN733uzAISwnKBi3/iN2VrdUP7d0fyMMgnHW/0fb52vOPRFK3/ e8X/XHX6tyVdXjgc/lVMa4egFUjwWE2Y5QMW559HOqT0mSnQJKQwseTfWLebWx12ACAs JXxA== 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=W0WoF8WbdXU/2uQ/lCH885Er58VOzubdGMifZQLxlIY=; b=bXzQEd4EIQ6IiiJYnJaXVmXbwHapxKrL+5ChpmdthJslvVxcVEF1HJamD1CMwEcpWi tPQufEIe8xxrZLntBJeDxcofoZKDv/kHRIzVJtOD2RUTW6557gSTDy4qdNHQoSyDqCC0 dCnwvUu+itirhl6lYQuoLnqY0t1+vW9Bef59QMEylyqLKqkLWTBqFela7OlYV2bXMVux svViTeQcXvRtzTM6gJSlPypV+6x4E+l6x0CeRJ36kL8nxOh2sVCe8b7Z9DWIFBiF8jc4 YXxGSYd4O85DcAU45BeHBdCg2S1+MUWFeOhTLUSWX8qzF/ljNJWEE16KzfiEMNMVtIJE sOqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="To/hpwsW"; 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 u2si3253208edb.405.2021.02.25.02.02.52; Thu, 25 Feb 2021 02:03:14 -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="To/hpwsW"; 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 S232949AbhBYJ6o (ORCPT + 99 others); Thu, 25 Feb 2021 04:58:44 -0500 Received: from mail.kernel.org ([198.145.29.99]:33484 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235539AbhBYJzu (ORCPT ); Thu, 25 Feb 2021 04:55:50 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 1904264F0A; Thu, 25 Feb 2021 09:54:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1614246854; bh=pEPTaD8+y1rHGyYy1dz0FtMGuda2XQ33mIeEeVCXDE0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=To/hpwsWvr3qefSyBkZXeiBDGKlSC0CANl38gRfVHbH0C4aTjuhi3MfWihrKNKcaa UMV/FDAf8X39/QFooXDd73AwidOTRnJwpqCIKpnGJrv9woPtSlUWsVMR12eJgPHmI6 AmVl4U6M47kvgB1kRoyzekT5gA+/8BLrk/menybY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Rustam Kovhaev , syzbot+c584225dabdea2f71969@syzkaller.appspotmail.com, Anton Altaparmakov , Andrew Morton , Linus Torvalds Subject: [PATCH 5.11 05/12] ntfs: check for valid standard information attribute Date: Thu, 25 Feb 2021 10:53:39 +0100 Message-Id: <20210225092515.261565343@linuxfoundation.org> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210225092515.015261674@linuxfoundation.org> References: <20210225092515.015261674@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: Rustam Kovhaev commit 4dfe6bd94959222e18d512bdf15f6bf9edb9c27c upstream. Mounting a corrupted filesystem with NTFS resulted in a kernel crash. We should check for valid STANDARD_INFORMATION attribute offset and length before trying to access it Link: https://lkml.kernel.org/r/20210217155930.1506815-1-rkovhaev@gmail.com Link: https://syzkaller.appspot.com/bug?extid=c584225dabdea2f71969 Signed-off-by: Rustam Kovhaev Reported-by: syzbot+c584225dabdea2f71969@syzkaller.appspotmail.com Tested-by: syzbot+c584225dabdea2f71969@syzkaller.appspotmail.com Acked-by: Anton Altaparmakov Cc: Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman --- fs/ntfs/inode.c | 6 ++++++ 1 file changed, 6 insertions(+) --- a/fs/ntfs/inode.c +++ b/fs/ntfs/inode.c @@ -629,6 +629,12 @@ static int ntfs_read_locked_inode(struct } a = ctx->attr; /* Get the standard information attribute value. */ + if ((u8 *)a + le16_to_cpu(a->data.resident.value_offset) + + le32_to_cpu(a->data.resident.value_length) > + (u8 *)ctx->mrec + vol->mft_record_size) { + ntfs_error(vi->i_sb, "Corrupt standard information attribute in inode."); + goto unm_err_out; + } si = (STANDARD_INFORMATION*)((u8*)a + le16_to_cpu(a->data.resident.value_offset));