Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp3514382pxb; Mon, 1 Mar 2021 12:00:20 -0800 (PST) X-Google-Smtp-Source: ABdhPJx0L3Gs70j7IXknfv1GrS6ejLPMetkFwao5FvuG5XYTpnbaMRcXhZA85ibOEFDgaAzbukx1 X-Received: by 2002:a05:6402:215:: with SMTP id t21mr18212952edv.363.1614628820284; Mon, 01 Mar 2021 12:00:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614628820; cv=none; d=google.com; s=arc-20160816; b=n77eSKI6HdBBs9XpEyUceQkiEKy0InlMjpLtOjEnuwCG5TIeYTUotnGhT/SAhSmWLZ rf1UqO8R6Sz0/HsV/sHw+KVVr+IgfKkLZx9bY3/y6WJq4gcYB3rbqn2lYo1uX2PW7DBh 2ExzCx1jFEOfsYA+aBCKFQQ1QUNmzwA8Pfdgu4m/EqyyKnza5TJe8HvjvsdRETO3pdbX sgOao8tNsljzpyIxh++jbrq2dGxTeWR/DX4bWG0Vj3+elfKzbbaJZKrGQFWQLCIqkUUs s8g5PZFTnQWsFgeA6VvzsghgcXyHjEjviAuGHg2jxeIZqavH8XSYE7yeVcfBDp5sNdvV /fRw== 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=MACB9ZsQq6gaEhsNS9vqsrMNsEzfvfiUGzoIi6NakSQ=; b=Ibr25EB822fJs3UA2DmSGJtlLW3qhib9nZH0atSbqN0MzHxHqFC2yvJONhpnr4QPAM Itpn4MiAZFj0GRL3H+w1//HIbt5Yw3qVkVIE0Syi9iTyhlk0FVr8yA4uYD87s4Gohf/S zLUd3FDb2llkOr5ov+Fk2UTRFopQfEBQyhLeNbUtSfnor1OYANLsdqwqWpNYQOtG2em9 hnivy3hEQ12YpWKlK8FTN7MAbOfYF4/hz6Q2SGffc3NLXVeXQghtwURQ9jkkOjb+BbQu fWbiq1sUIevt7QcaoLonGlqKSrocR8MfOkJztFIrnwW/SS6UCrOA0DUcnuVjlmU+lzx5 3VYA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=IdtPu6zo; 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 u4si11886163eje.631.2021.03.01.11.59.57; Mon, 01 Mar 2021 12:00:20 -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=IdtPu6zo; 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 S242518AbhCAT61 (ORCPT + 99 others); Mon, 1 Mar 2021 14:58:27 -0500 Received: from mail.kernel.org ([198.145.29.99]:59150 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236122AbhCAQ6K (ORCPT ); Mon, 1 Mar 2021 11:58:10 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 8D0BD64F5A; Mon, 1 Mar 2021 16:36:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1614616585; bh=r/akzR047z3giKvarUyMXMxiaP4ebxAXYihbJubkWHU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IdtPu6zoBywYjcqoyBUqNITr0eRlQ0a5OcpH9edNLTxBbZOrYyHoRlW+jMVH9Ryfh kobqP2eHoqkcvrig3rNQ2A0QU6zX7DfP9n7Bhdef0syKCPRWqOrFW87bKc8U1TuAXZ WP6zJ9shdsYRmb/gV4S/qIMoEH32KUcE12kqd73Y= 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 4.19 004/247] ntfs: check for valid standard information attribute Date: Mon, 1 Mar 2021 17:10:24 +0100 Message-Id: <20210301161031.905298809@linuxfoundation.org> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210301161031.684018251@linuxfoundation.org> References: <20210301161031.684018251@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 @@ -654,6 +654,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));