Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp280121pxb; Thu, 25 Feb 2021 02:15:14 -0800 (PST) X-Google-Smtp-Source: ABdhPJyKYx+/NVyDIQJBC/fTqyk3ldFmbYYBk7/0Qfxpekqkv00TqkR91hgxGgryc1UG02PwQ7Ep X-Received: by 2002:a05:6402:1155:: with SMTP id g21mr2083166edw.279.1614248114746; Thu, 25 Feb 2021 02:15:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614248114; cv=none; d=google.com; s=arc-20160816; b=fauOIOMqYt9FlOSUHqlAKo6vA+Mr4WZ+3lr8pRDjnlo29y1XvxxLDj9yj1PzETptIP FidBXd961QL83AYjF3tbbl+h0hzuAxqkiSwhADES8Pwyk4YcZpg1cF6LNaCjOEX5XXxq qmaDhOX8l9AQR/tVGqeQWiiudTFeRusRDv8pRXW4ooLR1dWLniB1LMin/HlkHXLROAQJ OGfAn75tMQSoGRi+GQb3UGVhGjFOIJNHJ9KqcWGUWahLzF4FHnz4w1BZ8FfGLc7cP5rb wh7jdc/8m+HiHl5zR5VlrEWa5An1/B5Qqzi1BwraIhBoQNAZyYLVvbS5YzklANww+hDz F2pg== 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=FtPhve0XOi7wmo/OUifbfZHDjlVufoWR4m1gzKDvTtarPJBDLqNPJGZVDTLRZ/+cK3 f/7o5/AcTFeULhWNYdQvr0OFh4yWSIZPpRbmjguzmHd3vMMNr9n0XaC+8/YyCn2rqp/C PNbFTuiGP+wUKmCLjSsuiFZ279JQdSU3xz1tABRusfEHgVJHx5G23CwW8cQOztN1Su8u kks+AnAzOakDeSk3mr5QgYYgb2WmqJa/nN5NTG4z6+m0vXjNgB9DxFLuPBjvTtVuc0j8 4MPHw3y3VSBQc3ibCxxTdPvLw6r4E3AinPIox9xCVMEbedD0sx5A/nywxbOG7jiTEmPW GlTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ALyDQdUF; 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 b7si2723486ejv.268.2021.02.25.02.14.51; Thu, 25 Feb 2021 02:15: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=ALyDQdUF; 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 S234931AbhBYKMt (ORCPT + 99 others); Thu, 25 Feb 2021 05:12:49 -0500 Received: from mail.kernel.org ([198.145.29.99]:34112 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232821AbhBYJ66 (ORCPT ); Thu, 25 Feb 2021 04:58:58 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 3EA5E64F16; Thu, 25 Feb 2021 09:54:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1614246899; bh=pEPTaD8+y1rHGyYy1dz0FtMGuda2XQ33mIeEeVCXDE0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ALyDQdUF41llEQNwdw+MHGEm+LOt8aSmblHKzTj3Gdu90O+M/keHzGyqGUPeV2rm+ i6GYbKK+eljaf1NYFYbdcPVXKivyqcMD8wF6mSwYAyKb/MdA43uyC1azMmtLXEnCAh Kk1VSEmj5ORItOtIDntZFkqqxc0/OGSmK83XFwrM= 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.10 08/23] ntfs: check for valid standard information attribute Date: Thu, 25 Feb 2021 10:53:39 +0100 Message-Id: <20210225092516.936771047@linuxfoundation.org> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210225092516.531932232@linuxfoundation.org> References: <20210225092516.531932232@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));