From nobody Fri Jul 24 21:52:29 2026 Received: from mail-ej1-f47.google.com (mail-ej1-f47.google.com [209.85.218.47]) (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 8587A3CF208 for ; Thu, 23 Jul 2026 22:10:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784844661; cv=none; b=nBrK7k58M3OZlnUlCmjPCQHh7upIZHdfzBlBxidw4q+Jp7HmS67whvQG/XW1PpKQrHqhaVn95BoSKaDvguhODMAvWghRIKT4/xu3uW9dEH0e46ZbiwVpnIXB0KEo/K7JFZLeFZPS8QTSKhzK4WEV//SJQ0GMlo6SMYQ+5OOyFP0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784844661; c=relaxed/simple; bh=C2Zn4CbY0hbSGyEmBt2MEmF1iqU58U4gSfRk9aHfces=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=Y/BHuCxqb44Mho4CeQWb/6djmIUh8dV5KGX9b/r92vEflGzg6va1qXwqV7W9PfHY401fi4FRvVUMOyBGbFv0ysSJaW/3h4KAeTdskujDZq1roOvJDekFziEP1kUvN9gxS2OYyBWMwKrSLsWLIpk42FmGKxM3Nxion2UkY1nPYTw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=ZRsAf77j; arc=none smtp.client-ip=209.85.218.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ZRsAf77j" Received: by mail-ej1-f47.google.com with SMTP id a640c23a62f3a-c1671ec8692so143551166b.0 for ; Thu, 23 Jul 2026 15:10:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1784844658; x=1785449458; 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:content-type; bh=n3sImDHanXm/nP3OwyjC3fU83vihxLVlwyFoNqtWFgU=; b=ZRsAf77jzBdCVplXum1b+cqawbil6autyF44PDzTpfxcIe1nkfTYLz5n/vWqYQt0lF XiMeTdt2C5EXt/bGzvdurxs5MK396TXhMBjB4LcIg0XdIDjyOztUBsJnC6hVJG7AoCIV qFa5jWwcqFCoGu0yMnIX0PFXpXpLrZ9VgpwvuQtiMdnfaIz7Es6OXO2coX52KLlC+JFG 425kYAeRgYV54CgCkk0nvEP+IfiHJLsZTqeaahCqHamBkluvzqiBSLZa2JvQuP3uUhhD 60WH3/xrnJv5ffELmbtALODgc9eNeA98bu3a6NaF/UZV7p3vfxsJHLzicfKCUPkCmvKK MI7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784844658; x=1785449458; 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:content-type; bh=n3sImDHanXm/nP3OwyjC3fU83vihxLVlwyFoNqtWFgU=; b=YzXLwaY9yEBR+vlqOdGl5EUBRhB0+SOxPmDzDk7YU+R4r7Qeg7c5q/6Zldin8S6KQK TMwiTJgUZC5WWX6kTwzdTtBnh9QpamGet+mpxjJcEMJoWJuvMhv/kt8QhIfCDhvRVTL/ W/x6yMTHHL9MSgd5QYmAip4yvG09D54nnz8y+5kbkgYsFhQAAVNkS2gqbJ9TejeKM2rl Cig3TA3yux9u1qt3O3abeBAXe3V1up5CMwEJ6ySQQKKMn3m5+m1FUjS7RDXeJuR2x6Q7 1Rz3N1sqhvZ/X389NWnDg6P1XUD8Ek+gcp31tuBkFTR4+nVQSQnOswWYQMJTziwGbYRU EZ/g== X-Forwarded-Encrypted: i=1; AHgh+RoV56TawdVoaANXTwl+HhXOSOkjS69KxXqvrKbpMNtlJeuR8PIi1qz2SEKzUDICHI2pMS+N0DpsPF2aQKU=@vger.kernel.org X-Gm-Message-State: AOJu0YxR3FjAP135/EYtUAaf56AqZSpmCsLRvL2Mh1nOano9kILR8T6J 163N8yOrJOi4dp+a9DCh0fD2+xwVGIJ3j8vKmFfAJnvQdB3soTDSYuhA X-Gm-Gg: AR+sD11VoO+/cCQJsbqfiKs1TFGCR7Hto2VdRe2upzg3krbOPjaQ8xXqlv1QpxqgyvW FPqPhQBKHVE0FRlj+ArxXDjJsZKPV1wVwBAiunvacNA2iSNzZa/aj+ZO+dpUPurNk0rtN8amyuF YctGPY4daWnF+8XB47FU4c8UtD4qaUg2OpyfOucv02SnBJlZH5aqBCgInAQVZcUkPWYwdj4jaEX 8/nTpOI7go/UXjmxHgJ3Gcx+5ykn6NEViL4ryOqwubsYe1TY1Hz9rBnLpn+F0GL0ZxUEcuqc7Wg tx6HMdefBMOgxcWPJtK6p4iKbYoRDDVRgSg2vCvYZqN7pq07NZMrj26yEVOwxaGilaMvOehZkRH ugHu4/GCOC+2wrCzKXQhptiwW68Qo4FgpzKP1cc1ps4z85ddlahk2drz5CA89x7imqJ+dg01td0 cpKe4z X-Received: by 2002:a17:906:7304:b0:c1c:62b4:1ebf with SMTP id a640c23a62f3a-c1c62b41f9emr108510166b.60.1784844657499; Thu, 23 Jul 2026 15:10:57 -0700 (PDT) Received: from beelink.. ([186.247.163.143]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-c1c32c90205sm280929566b.33.2026.07.23.15.10.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Jul 2026 15:10:57 -0700 (PDT) From: Your Name X-Google-Original-From: Your Name To: ntfs3@lists.linux.dev Cc: almaz.alexandrovich@paragon-software.com, linux-kernel@vger.kernel.org, Aldo Ariel Panzardo , stable@vger.kernel.org Subject: [PATCH] fs/ntfs3: validate that EA entry size covers its name and value Date: Thu, 23 Jul 2026 19:10:45 -0300 Message-ID: <20260723221045.529665-1-you@example.com> 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: quoted-printable Content-Type: text/plain; charset="utf-8" From: Aldo Ariel Panzardo ntfs_read_ea() walks the on-disk $EA attribute and checks each EA_FULL entry for consistency. For an entry with a non-zero ef->size (the offset to the next entry) the loop only verifies that this stride fits in the remaining buffer, and then continues: if (ef->size) { ea_size =3D le32_to_cpu(ef->size); if (ea_size > bytes) goto out1; continue; } It never verifies that the entry's own name (ef->name_len) and value (ef->elength) actually fit inside ef->size. A later reader trusts ef->elength unconditionally; ntfs_get_ea() does: len =3D le16_to_cpu(ea->elength); /* up to 0xffff */ ... if (len > size) /* size is the user buffer */ return -ERANGE; memcpy(buffer, ea->name + ea->name_len + 1, len); A crafted image with a small but valid ef->size (e.g. 24) and ef->elength =3D=3D 0xffff therefore passes validation, and a getxattr() with a large enough user buffer copies up to 64 KiB starting just past the short entry -- an out-of-bounds read of the ea_all allocation that leaks adjacent kernel heap memory to userspace. BUG: KASAN: slab-out-of-bounds in ntfs_get_ea+0x2b8/0x3f0 Read of size 65535 ... ntfs_get_ea -> ntfs_getxattr -> vfs_getxattr -> do_getxattr The zero-ef->size branch already computes the same struct_size() to derive the stride; mirror that in the non-zero branch and reject the entry when its declared size cannot hold the name and value. Fixes: 0e8235d28f3a ("fs/ntfs3: Check fields while reading") Cc: stable@vger.kernel.org Signed-off-by: Aldo Ariel Panzardo --- fs/ntfs3/xattr.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/fs/ntfs3/xattr.c b/fs/ntfs3/xattr.c index 04814dd29375..57114fb726f7 100644 --- a/fs/ntfs3/xattr.c +++ b/fs/ntfs3/xattr.c @@ -155,6 +155,24 @@ static int ntfs_read_ea(struct ntfs_inode *ni, struct = EA_FULL **ea, ea_size =3D le32_to_cpu(ef->size); if (ea_size > bytes) goto out1; + + /* Check if we can use fields ef->name_len and ef->elength. */ + if (bytes < offsetof(struct EA_FULL, name)) + goto out1; + + /* + * The declared entry size (ef->size) must be large + * enough to hold the name and value. Otherwise a later + * reader such as ntfs_get_ea() copies ef->elength bytes + * starting past the entry, reading out of bounds of the + * ea buffer and leaking adjacent heap memory to + * userspace via getxattr(). + */ + if (struct_size(ef, name, + 1 + ef->name_len + + le16_to_cpu(ef->elength)) > + ea_size) + goto out1; continue; } =20 --=20 2.43.0