Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp623272pxx; Wed, 28 Oct 2020 12:40:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwV1Ex7a1M7dPeImvfbRlUokWuZYA3A0cnn6XisOQGnYVDq3A/U4+xEFz7WgJPICHJov1/V X-Received: by 2002:a17:907:270f:: with SMTP id w15mr615154ejk.505.1603914029946; Wed, 28 Oct 2020 12:40:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603914029; cv=none; d=google.com; s=arc-20160816; b=udePjYUcIiJ9y6l2N3qzy1jhCXXEMo2Rpkx6UzbNYvQsWw5AN5VCSthuU3QS8naxFq erSldLDP6eHHWjr6uqWiXbpPYx7VdLZCyk+FRiQM3KFEtDj6y8wgKqE0wSrpfz+nSUxy yCvncNd6zfJB1IghnnEonRTKItPeGqzaGBfEIffsL4/LZAM38qwkyO/G3KvFIFe4CQzE YN2SqXBcPrSq4YkCJP9E42nLrjJXfpixaR/Zc7FuQB/RNzA/hTf4x0NOH4NoMiOVYG63 prQqZsJEolko0+dCu6WdfY6F4oErJyHFfaebRCP6G6fip9OQ97zBmJ9aH5+SXExQjBMF inhQ== 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=oU/t8YKiS2uyoLe7zzpZFRc9QKxoBE5pBwSULRHNf8M=; b=HnqbDTLDI4pbBgCuWdo59y1wQcjM99sK3Seq+Cgq7in07JpnvkGp465zQpTIsA5zbh supm4utSNJ12wwnBqQ2iygrTfx6Yb66h0mzk+lnX0yh3EH2iGSU2l9QdiXTJSDqWkJzh vDIS5EITeb0QLxsJTwlS5gV9A3HSXyeUY7IrlPDZRKAkohTFLEZOWYR9GUgOaaGbBXA0 VhOtT65aBIYY/Ts2uihR5aHTpGi0i1CaP3/tOqPufy1+17K0wc5Xw+7AALlVTrKzb5Da maGeXowLrJdQ0xMSA04OHTDBokapfgMrwc9xj2u8SwN27PRWnPqumWjLOlFJQ8zJ+dlB /bwQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=BVbz4zUq; 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=fail (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 j13si1208edj.549.2020.10.28.12.40.07; Wed, 28 Oct 2020 12:40:29 -0700 (PDT) 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=@kernel.org header.s=default header.b=BVbz4zUq; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1827709AbgJ0S05 (ORCPT + 99 others); Tue, 27 Oct 2020 14:26:57 -0400 Received: from mail.kernel.org ([198.145.29.99]:47762 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753576AbgJ0OAX (ORCPT ); Tue, 27 Oct 2020 10:00:23 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 2A2F921D7B; Tue, 27 Oct 2020 14:00:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603807222; bh=qr5IBMUcnmL6i6o7msUoTodHVxH92J3rwPTt3mSQ8hE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BVbz4zUqmhkUhKLcQlrE1qTjr+UkoTJOolCM6FIqxyoHHx+IjKF3bvuhk8I19Qxzq JJn+8M1fKx8hqQqJXRUyvqoumzrqaIjDfex7/Dtp4QuHJhSYSWOklbGgGMRXNBA3VC F4KdDmCUtMIwP3WcpFVguLJtMNuslGnMdSaN6V04= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot+aed06913f36eff9b544e@syzkaller.appspotmail.com, Rustam Kovhaev , Andrew Morton , Anton Altaparmakov , Linus Torvalds , Sasha Levin Subject: [PATCH 4.4 087/112] ntfs: add check for mft record size in superblock Date: Tue, 27 Oct 2020 14:49:57 +0100 Message-Id: <20201027134904.659373069@linuxfoundation.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201027134900.532249571@linuxfoundation.org> References: <20201027134900.532249571@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 [ Upstream commit 4f8c94022f0bc3babd0a124c0a7dcdd7547bd94e ] Number of bytes allocated for mft record should be equal to the mft record size stored in ntfs superblock as reported by syzbot, userspace might trigger out-of-bounds read by dereferencing ctx->attr in ntfs_attr_find() Reported-by: syzbot+aed06913f36eff9b544e@syzkaller.appspotmail.com Signed-off-by: Rustam Kovhaev Signed-off-by: Andrew Morton Tested-by: syzbot+aed06913f36eff9b544e@syzkaller.appspotmail.com Acked-by: Anton Altaparmakov Link: https://syzkaller.appspot.com/bug?extid=aed06913f36eff9b544e Link: https://lkml.kernel.org/r/20200824022804.226242-1-rkovhaev@gmail.com Signed-off-by: Linus Torvalds Signed-off-by: Sasha Levin --- fs/ntfs/inode.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/fs/ntfs/inode.c b/fs/ntfs/inode.c index d284f07eda775..38260c07de8b5 100644 --- a/fs/ntfs/inode.c +++ b/fs/ntfs/inode.c @@ -1844,6 +1844,12 @@ int ntfs_read_inode_mount(struct inode *vi) brelse(bh); } + if (le32_to_cpu(m->bytes_allocated) != vol->mft_record_size) { + ntfs_error(sb, "Incorrect mft record size %u in superblock, should be %u.", + le32_to_cpu(m->bytes_allocated), vol->mft_record_size); + goto err_out; + } + /* Apply the mst fixups. */ if (post_read_mst_fixup((NTFS_RECORD*)m, vol->mft_record_size)) { /* FIXME: Try to use the $MFTMirr now. */ -- 2.25.1