Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp297379pxx; Wed, 28 Oct 2020 05:17:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwtBBo5zxKJ4yAcL61qwyo38MAOWNO5vz/WdeSjxZa2EY+uGMHhcNO3PVScOxbrSG0iOnTl X-Received: by 2002:a17:906:abcf:: with SMTP id kq15mr7021123ejb.208.1603887470031; Wed, 28 Oct 2020 05:17:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603887470; cv=none; d=google.com; s=arc-20160816; b=ZeA+7QOUClHAfiai3q+7dtv8y0dxx84AhrL1M35Hqd1LmCZuQDHAP3cFglouUKT/LZ 4J75EDkSrEAYRKc8CrGxKLG3cV3V4vS55c3RIU86cw7dqlp0JaXWAfYr/gMcA/xGY+ym 82U4byFyhMqiuFqGc3VMZ0+K1O+5im0gTzgfvXbzyB3vmFA28gwWD4XJTWXK0dwEfv1r vKB/HmwroLqHNeb/O24Q0+lnT2WbWlyTuy62CPuzFOA1JzzLjimZOaL75LUvzRynQiaj KkdEcSr8ZKQAMWAR5zOW5imZYaP1U8tEG7VuZI1Dy4PCRQDi0lau7y44HnfUxATpBSFB hnvw== 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=MdYpqr2TPu5XfT+YCg4kvE0wZrzHlQCykOnpBmAMwhw=; b=gWG9RrJuR63MpkjtHpikwJySuLoVsYfwclseHapr0aicVpY6lU40r4PhmBZcaB42tJ YXRHEZXpcPfi1i+HhdaXhuvZ9BUpN8uxhz84Ww5mfuNGNdAjzVKUAcxku4ARrYn3BG3p rpQmHYoaaMPFDXQMQZPHc96/uP14IC6q+OzsUsmvss27j6ZVMW8c2fsbg6dzV2UKe263 dAvHN2jBheBIKKcHmeHJn4zZC36B/kx6kJzv6Js0UfQ+Lf2h13Sz8uRX6C55zB1KRwl0 bl14lWCnnan5/JEAIuNz3wZWi2gUAzB34Um6OSwUCssSZXXAOKAjB3O353/ZJwRn1Th0 XvSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Hy+2q2le; 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 bt10si1135660edb.503.2020.10.28.05.17.26; Wed, 28 Oct 2020 05:17:50 -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=Hy+2q2le; 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 S1796346AbgJ0PRg (ORCPT + 99 others); Tue, 27 Oct 2020 11:17:36 -0400 Received: from mail.kernel.org ([198.145.29.99]:50424 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1794794AbgJ0PNi (ORCPT ); Tue, 27 Oct 2020 11:13:38 -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 1E86620728; Tue, 27 Oct 2020 15:13:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603811616; bh=v1Z+kyM00XJqxJX/GQ2PGnu5D3WwgfqCSvSBlCHzPZw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Hy+2q2leV0rVsVwtzAsjennezfifGxKxyZzJrgEqQM1Uw1KiQkNMqaIh7EyOXhZ4P bb6NEN+nAo2qYu4kVVQNQHg/UP2OxjG7YA9hBWKk9dhNBW/xblgg9LfVeHUWQa5qDm OzsY680IUUHmS5WQLxBY4KO3SJmESD8Ozjx87DVA= 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 5.8 557/633] ntfs: add check for mft record size in superblock Date: Tue, 27 Oct 2020 14:55:00 +0100 Message-Id: <20201027135548.941425792@linuxfoundation.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201027135522.655719020@linuxfoundation.org> References: <20201027135522.655719020@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 d4359a1df3d5e..84933a0af49b6 100644 --- a/fs/ntfs/inode.c +++ b/fs/ntfs/inode.c @@ -1809,6 +1809,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