From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pf1-f177.google.com (mail-pf1-f177.google.com [209.85.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8B5A5265620 for ; Fri, 3 Jul 2026 22:23:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.177 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783117417; cv=none; b=tSuoV1gCK3XiS84/5/K8X3AmBW9myd2SLR1bcIUZSKJemeJ/PvA185LYsZYQoLpoj6+B7XrVE4TBOGAK5HQvgCMBMUG5H3bMidpnQZzKi77XI5WlBHlFRq8tPD13LFsvCXVhZwfaCNwGHDHGDbJB/y+tp+J38jRuOZe0EvpyEHM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783117417; c=relaxed/simple; bh=2D3XGUlwVZW00eMlzle7gzXP64x8TCutNOJpjvlqbUM=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=H90XYEf6pEvUQAYjCmeuwJCqa2ST4umZRiETLyZXeM5K1j07GZvtmAqfSUN2ltdThAVelLE51ZhNBYOykvGrjRC7SCjkeSfmroe5DXyDAYOz/kUCG/hoy8en386NoQnFdxpHJYQEI8CsnR5bds8Tmd+EBlB0sLPlU6K7j2rGe2M= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=asu.edu; spf=pass smtp.mailfrom=asu.edu; dkim=pass (2048-bit key) header.d=asu.edu header.i=@asu.edu header.b=r7/ZaNRu; arc=none smtp.client-ip=209.85.210.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=asu.edu Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=asu.edu Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=asu.edu header.i=@asu.edu header.b="r7/ZaNRu" Received: by mail-pf1-f177.google.com with SMTP id d2e1a72fcca58-847a52edeb2so776470b3a.0 for ; Fri, 03 Jul 2026 15:23:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=asu.edu; s=google; t=1783117416; x=1783722216; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=b+vTkdbSXPjSdgLA8x1Ws1Zl8rwmKCRXfmB69wKCqSA=; b=r7/ZaNRukDfZ5E1Mbq+OPgso2KVcvEXAxM0/EKRc30+9W5TDkbOpKqMmtnKB7/KLEE 3mvGevGyUbq/uBmvBjaV8pZlZIt+mZvaROSIiNrdGjQVL71JmcGRqq781v86hIdwcHGN iUU3c6+MgE8uwkGEa51H9ZeKdhAZzHa0IUTFtebIox2Qip2rQxNQ6cyCnNtv7Z/1pkwa 21HRBfGhCbWciq1xHBI6XnHoTABaiTm7D76OV8pEhfrjCNcQmi7SnLFbiyGuZwm3vOaj OMzvBp354DZh71IlBEND2EXUpdHw0JQfuAfzIPn/+BjJ0N0D5J8F7GCuTzwlj852tvdW Q4sA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783117416; x=1783722216; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=b+vTkdbSXPjSdgLA8x1Ws1Zl8rwmKCRXfmB69wKCqSA=; b=c9ud54tEVR19tE+uS2O8Fk/NZkN/mwlC2pXV5Q2GlyI2iF+/B0rgEBLZT/uwd7XiWH Jg9WCqFHA1dR7MX9tEs2MSD4PJMmsBNI15q4pMoKCxT1cOvOO/c9e3zssKcwDj6ZDeeW vtIsqmz132YpkqIF6sLtbCo3RxYLA2WcJgt5ZeilhK4O/SDjj9aS/fPfjxRj/RK+m5pf G7sLz28Mivm4pJ38wQx65PJTPKBcFQ9WwSlzPv8n5bvdLi/jonIkRPlSpEknSMeFRZVP qh8tWlDlupAkW1W7E7P8JcbyqYcU1JtHZYR8G0nynTGobntALdPTBxf/aRZgAPJoR0T1 T5MQ== X-Gm-Message-State: AOJu0YzOBxX3uzoKdCB8qa+bgMuRzJx6B0I7AslxB/XrTWFpQssQ0NFN HsoFWg36OeOQN2OmxNx3Em9ZlrKArlmZadkj4NZ9v43GQ4ioICFH2yz2X/P5n1DP6kySpuOo1T+ 9BMU= X-Gm-Gg: AfdE7cngA+1uYb6A2+4FO/eR1yvmipkg/3arPJFwy/fS6rAR76DEiz4WTrWfhJkTQ5f Fk/sv2uM8OarGf6kOhVdA4yAOqdD41hFrU9Lzi8beKIWUtXohOyTC4BlGis7/aqy/ZylQR6s4qj DGeIAIqlg019SA3Q9y/zM5ksETFbuvMR3Z1HTANDM935oFayAwCv8KrjH/HqlE0+bGsaJUrdSi/ U3OYBShnO08vQD216q5llojh/o61mV1ZG5i4t0l16nXNsR14u8063NqQrhtGduBRdOQlz4jsPqI Ypu+YALoOr2IXIr8vUz91wL+2G1mlFr8NM1zNo8Dn5NJPcR2XRaudSs/Yr4NioxfI9RJP0h7LBQ ocHqH07Ak1clu3R3XfMX/2H8qwFUpqAnql9zcy3qXocXnaiQdPwGDQCLSiaWcYKUp1bvdY2xb7w == X-Received: by 2002:a05:6a00:1894:b0:845:d286:1fb8 with SMTP id d2e1a72fcca58-847f6fb2c87mr990757b3a.54.1783117415764; Fri, 03 Jul 2026 15:23:35 -0700 (PDT) Received: from p1.. ([2607:fb91:150e:5967:2305:366e:197d:e318]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-847f6b64faesm396027b3a.10.2026.07.03.15.23.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Jul 2026 15:23:35 -0700 (PDT) From: Xiang Mei To: Konstantin Komarov , ntfs3@lists.linux.dev Cc: linux-kernel@vger.kernel.org, Weiming Shi , Xiang Mei Subject: [PATCH ntfs3] fs/ntfs3: validate EA entry layout against ef->size in ntfs_read_ea Date: Fri, 3 Jul 2026 15:23:33 -0700 Message-ID: <20260703222333.94030-1-xmei5@asu.edu> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit In ntfs_read_ea(), the ef->size branch only checks that the declared entry size fits the remaining buffer; unlike the zero-size branch it never verifies that the entry's own name and value fit inside ef->size. A crafted image can thus present an in-bounds ef->size with an arbitrary elength, which find_ea()/ntfs_get_ea() later use as the memcpy length, reading past the allocation and leaking adjacent heap memory: BUG: KASAN: slab-out-of-bounds in ntfs_get_ea (fs/ntfs3/xattr.c:302) Read of size 65535 at addr ffff888010770b0f by task exploit/142 ... __asan_memcpy (mm/kasan/shadow.c:105) ntfs_get_ea (fs/ntfs3/xattr.c:302) ntfs_getxattr (fs/ntfs3/xattr.c:848) __vfs_getxattr (fs/xattr.c:446) vfs_getxattr (fs/xattr.c:479) do_getxattr (fs/xattr.c:808) filename_getxattr (fs/xattr.c:837) path_getxattrat (fs/xattr.c:876) do_syscall_64 (arch/x86/entry/syscall_64.c:94) ... The buggy address is located 15 bytes inside of allocated 20-byte region, cache kmalloc-32 Validate the name/value layout in the ef->size branch too, bounding it against ef->size, as the zero-size branch validates it against the buffer. Fixes: be71b5cba2e6 ("fs/ntfs3: Add attrib operations") Reported-by: Weiming Shi Assisted-by: Claude:claude-opus-4-8 Signed-off-by: Xiang Mei --- fs/ntfs3/xattr.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/fs/ntfs3/xattr.c b/fs/ntfs3/xattr.c index 04814dd29375..259d7f53b77b 100644 --- a/fs/ntfs3/xattr.c +++ b/fs/ntfs3/xattr.c @@ -155,6 +155,11 @@ static int ntfs_read_ea(struct ntfs_inode *ni, struct EA_FULL **ea, ea_size = le32_to_cpu(ef->size); if (ea_size > bytes) goto out1; + if (bytes < offsetof(struct EA_FULL, name)) + goto out1; + if (struct_size(ef, name, 1 + ef->name_len + + le16_to_cpu(ef->elength)) > ea_size) + goto out1; continue; } -- 2.43.0