Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp6580702pxb; Wed, 17 Feb 2021 08:05:25 -0800 (PST) X-Google-Smtp-Source: ABdhPJyp8W3Xz925di/XyQgh9ys/M//W0TCjEYKIodjCPGSAAz9VauwRkT8vqGkWSiSInTMt4QED X-Received: by 2002:a05:6402:558:: with SMTP id i24mr27215950edx.190.1613577925619; Wed, 17 Feb 2021 08:05:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613577925; cv=none; d=google.com; s=arc-20160816; b=WSKXuNKLaUXHEcxYCVkgCSiWLTCYwtfRBnEeQcS5uxVA5aQguX0rM3BZarbXRwbAhk 2TuIKoTDoym4dplbn84q9tH1bhbMsGXS+l3FZJKSfLPwOZM2oCEPEtF924dzxgERUVlO JoijTQ/AlQ1FfI5OSLRxHYcJ6onxy+KBVVBvJ/+tG3Q/lLQ3EzumXpCTmebYEFdv807/ cyw4m/LtRHSYwMTZyl2//1zJo3rrChabRF4q68RS8hmxU9DZo5QCdKCFrEBPxNZhcefW 9A5VG+xgxUj6moghvvBMshZowtV1E/uv+c1479NbwrCXW7M8aS5ox1blQZHCkuZJ03jl FT+Q== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=GOQVmvgp4dt65rKsAQWxL7KavP/pmOa+Mhm9+94yhA0=; b=qLaP3i59hcMDVbj/ChF+ggKWVWde1n5bEiC0zgrlcGk7ujFNLD31SRm3bKhvLp1+fG o/Wob/+MwlS0hkdEf3srIfoXtkvPeH/yCNz+FIPrMXZRUxApI9PwoElxMGdzxvOObPHW wMO/ybii/oxqY78n/M4yFQtR/XYaFB+rxRwnJ1YOjd79ICDlSF7cvUY0UzL/wASJzZ0J tqhDc61ZYGv5ebLRiFwVFn1YLiw2Q8pn5xm68rguwKh1gUnaQpszKVWQMnFrLCqx/bA8 ADflhoUIRGp28gRKDyw9EHsG4GGEgN8MphLe330ive0CnfUMojo7+cJ/pko1edfeVsCP 3Lig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=OgWgfmcX; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d15si1460461edq.404.2021.02.17.08.05.01; Wed, 17 Feb 2021 08:05:25 -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=@gmail.com header.s=20161025 header.b=OgWgfmcX; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233924AbhBQQAv (ORCPT + 99 others); Wed, 17 Feb 2021 11:00:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39700 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233887AbhBQQAt (ORCPT ); Wed, 17 Feb 2021 11:00:49 -0500 Received: from mail-pg1-x535.google.com (mail-pg1-x535.google.com [IPv6:2607:f8b0:4864:20::535]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 446AEC061574 for ; Wed, 17 Feb 2021 08:00:09 -0800 (PST) Received: by mail-pg1-x535.google.com with SMTP id b21so8751956pgk.7 for ; Wed, 17 Feb 2021 08:00:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=GOQVmvgp4dt65rKsAQWxL7KavP/pmOa+Mhm9+94yhA0=; b=OgWgfmcXzUIfi/RaYLY+BdMNraMTmk6AGXnvuMXh263tKqYsVRvv5S6QkszHfK6p9e R7ugb2dwa7Sys1Pdo2kHaqCYHLUo4t7HGHzt1X7d0Y5gqr7awVtUJh1+VKnQsDtsgcb4 MpHY6dJyhLutgPzx08UrSWpabf4/q+scQi3p4S74LBkq2x4/NrxQf1OnXUdk8O7Imu/6 TvoJ/FFTaQtt3bW4ciD5DSBsDjfrdLaDM+AgRwWLbDTTqnO9XUvrbuuKVQBDNbWRjS1Q xUFs4lmZmP95+DzJefEFUcvMVvKjAVpMWcJzx7vOpqzCw1FIW7Nq3cVS5VBu++zkbnWI WVzw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=GOQVmvgp4dt65rKsAQWxL7KavP/pmOa+Mhm9+94yhA0=; b=L4DQje9CZcOgcL55HQo2cODp/KyaFmhhZ8F+elO28ospPN0Eh0pi7wpJD5336FJwaL kLDmhtP1XmE8qArZwWpdS2FFc/mIKDajOsK7O9Cok9fRrQNBOjM1LxPJJS0j3HpZl8Uw LTXh1A6M2vHfCO/+jVPIIdCtIaJIU97uVqXtPfmcmPITp0QdyLnWCNc9SuVbM5wyK/Ed Gl758Nhv1xpadqJlrk4Lpj52ORJNPGMXr++cfjLSWj/CD8sT7hbeJHNrJ1nBvYag+phH OB6lKqFhGsjtGvxbxUnfC2xDrw8CXmYD56VDHjcSlAOMD5baky0t9DV4UU4PPXbSgEKA 5pRw== X-Gm-Message-State: AOAM531qmfmdX8sM5wpSgnsoG03T0bEJVscYRMas4iGN9BPl2t/c8nx9 k8LrXbZVziTde77LUPm/+b8= X-Received: by 2002:a63:e602:: with SMTP id g2mr57105pgh.290.1613577608768; Wed, 17 Feb 2021 08:00:08 -0800 (PST) Received: from nuc10.amust.local (104.36.148.139.aurocloud.com. [104.36.148.139]) by smtp.gmail.com with ESMTPSA id 74sm2911183pfw.53.2021.02.17.08.00.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Feb 2021 08:00:08 -0800 (PST) From: Rustam Kovhaev To: anton@tuxera.com, linux-ntfs-dev@lists.sourceforge.net Cc: linux-kernel@vger.kernel.org, gregkh@linuxfoundation.org, Rustam Kovhaev Subject: [PATCH] ntfs: check for valid standard information attribute Date: Wed, 17 Feb 2021 07:59:30 -0800 Message-Id: <20210217155930.1506815-1-rkovhaev@gmail.com> X-Mailer: git-send-email 2.30.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org we should check for valid STANDARD_INFORMATION attribute offset and length before trying to access it Reported-and-tested-by: syzbot+c584225dabdea2f71969@syzkaller.appspotmail.com Signed-off-by: Rustam Kovhaev Acked-by: Anton Altaparmakov Link: https://syzkaller.appspot.com/bug?extid=c584225dabdea2f71969 --- fs/ntfs/inode.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/fs/ntfs/inode.c b/fs/ntfs/inode.c index f7e4cbc26eaf..be4ff9386ec0 100644 --- a/fs/ntfs/inode.c +++ b/fs/ntfs/inode.c @@ -629,6 +629,12 @@ static int ntfs_read_locked_inode(struct inode *vi) } 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)); -- 2.30.0