From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-yw1-f173.google.com (mail-yw1-f173.google.com [209.85.128.173]) (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 5421E353EF7 for ; Sun, 16 Aug 2026 17:37:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.173 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786901838; cv=none; b=u+bgNnTyxiXIYa8830FNeM65pexPMeBeRymE1BIQYRRgzv6mkdoRkyjmGu8vgrde5D3S3UU6T/fo66mqexZI0S4N01JaRIhlLPxsDWU1JDb55Bj0MPfJQjDCk9EhjEjdC4Pas1JN8t/VVyCsHWiKxSQG5KSkdXVOy/qlFPBy3qQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786901838; c=relaxed/simple; bh=MbHSlyDWkiwWoNtZsFY4lusG9W3piH9eUQmLhq3SiuY=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=Itlejx8dYbzAD6U+30TROUspqioo1NDCpLIRrK9fyy9u7A6hIIYzl2E+B649XygOcY1YRVUbVeyyJaI024hNFK9i5LhduRqVqY8FFjoSwIHXHiFpDMDyQXerc5Txqo5fM88O2MYWjYN9G17sl9ig0/upRZaNGYCos22vEuly/gI= 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=aBmEYLeI; arc=none smtp.client-ip=209.85.128.173 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="aBmEYLeI" Received: by mail-yw1-f173.google.com with SMTP id 00721157ae682-836ce5d6e85so38139187b3.1 for ; Sun, 16 Aug 2026 10:37:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1786901836; x=1787506636; 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=oj6R0l0UjLr20BQL47faiZR3FmjRiGpl/wUyh6ZLEfA=; b=aBmEYLeI2WjBAGd92y9RYt7C8LCogCGbtmF2iuUn+zqidHSEV9DoDs8aeXRv9Bc+wk J88ZLprc0BmJg8FNDBMX76DlBPYvlxe8F32yT/bcp3z4F8HAA6GNx0cNwE+pe51ErYgy pN6GrLrtUmZCmzuLiLUX+8J6r/gH1zvROwBBda8PokDlfOVB1R0YvyHM/FFYm0WaYXzk J1DUbVqV7nXlfmHRTeyNknb/9+ptOl+AMPZpwxEP4WCHlW1ru68xj0+2zpWU/HsG0Nrs wfW7771E5t/CtFZzt9bM2hji1HArGLb+/6SccWLwjOWkvR1knvG4bSvn/OML+OM9uVqi vcrg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786901836; x=1787506636; 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=oj6R0l0UjLr20BQL47faiZR3FmjRiGpl/wUyh6ZLEfA=; b=GqPQVUfXYKQ8FdrP6SBQUmFkNO1h8pZIjJUboz34IcU5ADeO35N9otEkxflNqMVUV2 jjHDeBFdGyW6IOgbQYdCPta2kmHFcW1/CEwhs1YMlptRKYSxNWRR2Rlvuh9x2Lc8ACyx Td3lVpLWtu7fpirbl8zEkNHuCCCC0//gJXyDHIkmb4rcEZbHoMgDrpwBP1KkOra9n3NN 0REWdM9Bw7QlOmtDlvnWNMj3WWcvf2vfUhd6XzBCOv/xeJRemi0qxX0jtvTXd7nOWGkQ oxOyoLBxNkhzdtyDA+lCY4oM3elPAb6mhNuw/8hlsdaEJ8eCFgdmZCV8BdBu3r4NmUnf edJw== X-Forwarded-Encrypted: i=1; AHgh+Rowpf1YhHlTJznVQixQcRkbpH144SDxoDJIKStPsoInydZlTxSnN+6LgFs/FdYFt1OdD0M3AocPck6HiGg=@vger.kernel.org X-Gm-Message-State: AOJu0YxfD9YMJHX+4RPCFhojrawG5Ku6vpEAkZpTqVX5UxwkfbiIpL+3 wOQEfvbTnBYOiZcDGyWNzEO3K+RPZmoVSc6oGsoP1iM1l0IbdBWuPE/k X-Gm-Gg: AR+sD12EOSJ2+mLkTnAxZdr/SwFcE1w6x0aLP2xQXYU9Fb6228cJUxhUXVuTN7rmKsI 6Yzw2nkSKThFnK4exp6aaXODLwyZwRlQYrBlxnhhLi0p/XimfZABhbCqo41WXdcYtxkGLzQYWyg sn7boL+3JEX2ZWeuzWEmw4DaM7eQBGOqR4qYEpFW/dBz5BveybLoXWWJfFpy5k7U19gerC7FARI 8jsO9jQaIHNuZSXyoA7P6fZolaZ5Ugl574GVjNyKZnvvrPNDn9d9DmFEyZLpD68dXa3zeFciFEN Zyt06uPiDIAnwaw2NFoxmBz5vT4cq0ieIM1WZVdiMDhdqqc5vCQuL293ac4ocu+htnw8odhfFkF AtXxdaFj9c7qjF9HOQbYXXmVZefMHK5+emFqnqUanjmNIsqDWx4c6losQ0ie8Wo64HFkrF7Mkwc b9EwFmv2IL7bTiUOVkt9JS6QxU9qLkoGHgqnc/Wp0adlZTPu79LkNvsgRqZNM8EXzDFWE= X-Received: by 2002:a05:690c:e64c:10b0:80d:964f:88fd with SMTP id 00721157ae682-8370c265cb1mr53004147b3.5.1786901835851; Sun, 16 Aug 2026 10:37:15 -0700 (PDT) Received: from mac.lan ([136.55.173.105]) by smtp.gmail.com with ESMTPSA id 00721157ae682-836bc2a1ef4sm37839627b3.14.2026.08.16.10.37.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 16 Aug 2026 10:37:15 -0700 (PDT) From: "Cen Zhang (Microsoft)" To: almaz.alexandrovich@paragon-software.com Cc: ntfs3@lists.linux.dev, linux-kernel@vger.kernel.org, AutonomousCodeSecurity@microsoft.com, tgopinath@linux.microsoft.com, kys@microsoft.com, blbllhy@gmail.com, "Xiang Mei (Microsoft)" Subject: [PATCH] fs/ntfs3: prevent attribute-list pointer underflow Date: Sun, 16 Aug 2026 13:37:13 -0400 Message-ID: <20260816173713.28998-1-blbllhy@gmail.com> X-Mailer: git-send-email 2.52.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 attr_set_size_ex() and attr_collapse_range() use the on-disk size of a removed ATTR_LIST_ENTRY to step a pointer backward. A crafted entry whose size exceeds its offset from the attribute-list buffer start underflows the pointer, and the next entry dereference reads outside the allocation. BUG: KASAN: slab-out-of-bounds in attr_set_size_ex attr_set_size_ex fs/ntfs3/attrib.c:847 ntfs_file_release fs/ntfs3/file.c:1427 __fput fs/file_table.c:512 __x64_sys_close fs/open.c:1496 Before each backward step, reject an entry whose on-disk size exceeds its offset from the attribute-list buffer start. This prevents pointer underflow in both the shrink and collapse-range paths while preserving their existing fail-stop error handling. Commit be71b5cba2e6 ("fs/ntfs3: Add attrib operations") introduced the vulnerable implementation. Commit 12dad495eaab ("fs/ntfs3: Add Kconfig, Makefile and doc") added the local build files. Commit 6e5be40d32fb ("fs/ntfs3: Add NTFS3 in fs/Kconfig and fs/Makefile") wired them into the top-level build, making NTFS3 triggerable in standard kernels. Fixes: 6e5be40d32fb ("fs/ntfs3: Add NTFS3 in fs/Kconfig and fs/Makefile") Reported-by: AutonomousCodeSecurity@microsoft.com Reported-by: Xiang Mei (Microsoft) Reported-by: Cen Zhang (Microsoft) Signed-off-by: Cen Zhang (Microsoft) --- fs/ntfs3/attrib.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/fs/ntfs3/attrib.c b/fs/ntfs3/attrib.c index c621a4c582f9..562bfcf3561f 100644 --- a/fs/ntfs3/attrib.c +++ b/fs/ntfs3/attrib.c @@ -779,12 +779,15 @@ int attr_set_size_ex(struct ntfs_inode *ni, enum ATTR_TYPE type, u16 le_sz = le16_to_cpu(le->size); /* - * NOTE: List entries for one attribute are always - * the same size. We deal with last entry (vcn==0) - * and it is not first in entries array - * (list entry for std attribute always first). - * So it is safe to step back. + * List entries for one attribute are expected to have + * the same size. Validate the on-disk size before using + * it to step back. */ + if (le_sz > PtrOffset(ni->attr_list.le, le)) { + err = -EINVAL; + goto bad_inode; + } + mi_remove_attr(NULL, mi, attr); if (!al_remove_le(ni, le)) { @@ -2216,6 +2219,12 @@ int attr_collapse_range(struct ntfs_inode *ni, u64 vbo, u64 bytes) } continue; } + + if (le_sz > PtrOffset(ni->attr_list.le, le)) { + err = -EINVAL; + goto out; + } + le = (struct ATTR_LIST_ENTRY *)((u8 *)le - le_sz); } -- 2.52.0