Received: by 2002:a05:7412:bbc7:b0:fc:a2b0:25d7 with SMTP id kh7csp595851rdb; Thu, 1 Feb 2024 19:34:09 -0800 (PST) X-Google-Smtp-Source: AGHT+IGWN71t6myzXFkaLBXOne9x5ddXPYe3iwlafs/qmAoDWIL8wX/snlnVK/clQ15bRtItK9Eq X-Received: by 2002:a05:6808:1292:b0:3be:24d2:6d74 with SMTP id a18-20020a056808129200b003be24d26d74mr8057097oiw.38.1706844849025; Thu, 01 Feb 2024 19:34:09 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706844848; cv=pass; d=google.com; s=arc-20160816; b=Jc5QhLHUdQC124rbFePlH++GaS2nEnERI+WmjnwatPghMYl2fNOTlA/LFKpqFPJl0F uEhRxfH3zmxQuMjGhNQGL6Oih0B0uCxFUY3+7zJ3O+DOZ9S5E5WYEYwU7H5f5wvQKQ1W KfjF6uUlwTqbhUvCqk4iEqmZKUEEwroS23eBK4koxe2zVrkeDH0OZNAdKcMVGmcwXekt UK4yfas44yMc+ouA1NrKIbHTwzuwwLua1TeLe1cFBPLbB10L2GKz1ackjVqcZE5BLv94 SPtoorBgDWnOOs7M3TR0bDlIigzWvvOvEgRCsnmGqK/A+yfq6KIZcuPNkpwNRheLFo4R f1hA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=ZB6EemBjg4kqn54hPi694lZL5cl9eBwRNQ7kuQcXWig=; fh=TozcoM0f6jwqIGnx/uxitYq5rDPlEbMzJ3eItIZt2PM=; b=L8Es4tZo9l5pYXu/7V1Jl1AfH31YO03/pMChZYUucoMgKL2cnyZ+a3e0C5aksz8t4V tmTU7pbxgWjqruNlhgHeondPcIPsv66qUMO1J5aqgwmm8iSMz5rvtzO/uTeqmSi/M1Bj rIGsE0ohbgx/HWY4sDPusNOKOIYvSnAQRRt+RW/PbY4cghQPRZqNvNe8K2g5hJqRYW+Y qxS7DKSjOzXUmh5sEuxL/ZFXGH5agB2o12YiAm3cqhXg1GG7azvVHC6/oqJJoYcgIYNX OD9OUXDTNkW7/0SXM+yGfSLJ+uuGm6XfT7EwRZp6fM380dCAVTsbpYNYC/pb994q/Cs/ fbTQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@windriver.com header.s=PPS06212021 header.b=Gulj+Tu+; arc=pass (i=1 spf=pass spfdomain=windriver.com dkim=pass dkdomain=windriver.com dmarc=pass fromdomain=windriver.com); spf=pass (google.com: domain of linux-kernel+bounces-49152-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-49152-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=windriver.com X-Forwarded-Encrypted: i=1; AJvYcCVHGrhSHac/KgJP4El2486mtTDek1ZwTHTEoBZ4LJ9unafWEv3aLWNT0zA9uB0sy01H8RmR6n+uBYzfxb5ytozumL8TIgehNekg3QuZtQ== Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id d3-20020a056a0010c300b006dde19538e2si797736pfu.343.2024.02.01.19.34.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Feb 2024 19:34:08 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-49152-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@windriver.com header.s=PPS06212021 header.b=Gulj+Tu+; arc=pass (i=1 spf=pass spfdomain=windriver.com dkim=pass dkdomain=windriver.com dmarc=pass fromdomain=windriver.com); spf=pass (google.com: domain of linux-kernel+bounces-49152-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-49152-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=windriver.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id A98BA28D57F for ; Fri, 2 Feb 2024 03:34:08 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E9541EAFD; Fri, 2 Feb 2024 03:33:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=windriver.com header.i=@windriver.com header.b="Gulj+Tu+" Received: from mx0b-0064b401.pphosted.com (mx0b-0064b401.pphosted.com [205.220.178.238]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C99DBE54E; Fri, 2 Feb 2024 03:33:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.178.238 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706844839; cv=none; b=KNJZA9lo3ajFf2IMDSOLcArd0PxNYN9l8/gunVDByVs1Eg/w6EBzDl1cOrZhsq2CwI7zcI7GqlOFu4Zl9rFTmCnKZhb+5g5mbkMysgqKX+iTmxJdFVW3hK+4ZspAJmLgDdMQhEaKV8U2Kl3eLR+fJHD9VPSXoWCqMMPrD+pK6vU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706844839; c=relaxed/simple; bh=OyxBJ+A0yGlHECRXeVfAbJEuoSWpFLSlFOQ48riM33o=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=i4sSGl/U8dp8p6aswXslzMU4LJU9ZDraxfh2qWqI2U1ReF8xkusyuqOi8aoD3tEInb+cjsIoUJmyJCvga1T++t+xRIq8DL00DKv/7taexMCj5/haVe1LXZC7uN+K+YQOu+CdkVqO1FHvIRWi754ZwxM+uYrqjjeENIoNfuugJaI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=windriver.com; spf=pass smtp.mailfrom=windriver.com; dkim=pass (2048-bit key) header.d=windriver.com header.i=@windriver.com header.b=Gulj+Tu+; arc=none smtp.client-ip=205.220.178.238 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=windriver.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=windriver.com Received: from pps.filterd (m0250812.ppops.net [127.0.0.1]) by mx0a-0064b401.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 4121b31T011765; Fri, 2 Feb 2024 03:33:39 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=windriver.com; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding:content-type; s= PPS06212021; bh=ZB6EemBjg4kqn54hPi694lZL5cl9eBwRNQ7kuQcXWig=; b= Gulj+Tu+3crXaFoBEGXPli3BzPOFtQ0HZxb/51R5LRhLop95qlGv2fEQRsFSZKhb fsaOaieQDWOx1q6tlCRC11ZwoaADhez6zTlMsMfvwMTjG6gGj+Bb6pijCcVUNM2Z IkGJQ18zpO2QlQa+kxCxqXr8knJv4bQcN3Q8S+If+5CGdK0TYVeFrlon9h7LlQq3 3gXNWYNKDCTTKqCMsyI3Uj46r1lnCHjgbYrGsXGSPhg82MaPuvUNAWZWRKPMhG6g iNje9YaYkf/zvHoP866ZE4kqR/nzQPcfpnFsW1efHL0Woa44Xnvobgxg/K2P9Omg eVxkjPyhvlmAbKXcPxsGKQ== Received: from ala-exchng02.corp.ad.wrs.com (ala-exchng02.wrs.com [147.11.82.254]) by mx0a-0064b401.pphosted.com (PPS) with ESMTPS id 3w0pvcr28v-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT); Fri, 02 Feb 2024 03:33:38 +0000 (GMT) Received: from ALA-EXCHNG02.corp.ad.wrs.com (147.11.82.254) by ALA-EXCHNG02.corp.ad.wrs.com (147.11.82.254) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Thu, 1 Feb 2024 19:33:34 -0800 Received: from pek-lpd-ccm6.wrs.com (147.11.136.210) by ALA-EXCHNG02.corp.ad.wrs.com (147.11.82.254) with Microsoft SMTP Server id 15.1.2507.35 via Frontend Transport; Thu, 1 Feb 2024 19:33:32 -0800 From: Lizhi Xu To: CC: , , , , Subject: [PATCH] fs/ntfs3: fix oob in mi_enum_attr Date: Fri, 2 Feb 2024 11:33:34 +0800 Message-ID: <20240202033334.1784409-1-lizhi.xu@windriver.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <00000000000012d4ed0610537e34@google.com> References: <00000000000012d4ed0610537e34@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-GUID: jK86FqcCVEdZqEKrJxt2Cghy_RGh0MBu X-Proofpoint-ORIG-GUID: jK86FqcCVEdZqEKrJxt2Cghy_RGh0MBu X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-02-01_10,2024-01-31_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 malwarescore=0 bulkscore=0 clxscore=1011 mlxscore=0 spamscore=0 phishscore=0 mlxlogscore=574 suspectscore=0 priorityscore=1501 lowpriorityscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2401310000 definitions=main-2402020023 When the value of attr->size is too large, it can cause overflow when taking the next attr. Here, off is used to determine the offset first to avoid problems. Reported-and-tested-by: syzbot+a426cde6dee8c2884b0b@syzkaller.appspotmail.com Signed-off-by: Lizhi Xu --- fs/ntfs3/record.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/ntfs3/record.c b/fs/ntfs3/record.c index 53629b1f65e9..a435df98c2b1 100644 --- a/fs/ntfs3/record.c +++ b/fs/ntfs3/record.c @@ -243,14 +243,14 @@ struct ATTRIB *mi_enum_attr(struct mft_inode *mi, struct ATTRIB *attr) off += asize; } - asize = le32_to_cpu(attr->size); - /* Can we use the first field (attr->type). */ if (off + 8 > used) { static_assert(ALIGN(sizeof(enum ATTR_TYPE), 8) == 8); return NULL; } + asize = le32_to_cpu(attr->size); + if (attr->type == ATTR_END) { /* End of enumeration. */ return NULL; -- 2.43.0