* [PATCH] ntfs3: add permission checks for NTFS system attributes
@ 2026-08-20 8:55 Hongling Zeng
2026-11-18 16:47 ` Konstantin Komarov
0 siblings, 1 reply; 2+ messages in thread
From: Hongling Zeng @ 2026-08-20 8:55 UTC (permalink / raw)
To: almaz.alexandrovich
Cc: ntfs3, linux-kernel, zhongling0719, Hongling Zeng, stable
ntfs3_setxattr() allows system.dos_attrib, system.ntfs_attrib, and
system.ntfs_attrib_be to update NTFS file attributes without permission
checks. These attributes affect the inode mode because the READONLY flag
is mapped to write permission bits, allowing unprivileged users to bypass
file access controls.
system.ntfs_security allows modifying NTFS security descriptors which
control access control. Similar to POSIX ACLs where file owners can
modify access permissions, require inode owner or CAP_FOWNER for these
NTFS system attributes.
Fixes: 4534a70b7056 ("fs/ntfs3: Add headers and misc files")
Cc: stable@vger.kernel.org
Signed-off-by: Hongling Zeng <zenghongling@kylinos.cn>
---
fs/ntfs3/xattr.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/fs/ntfs3/xattr.c b/fs/ntfs3/xattr.c
index 7a81369a1173..4e41aca0d5c7 100644
--- a/fs/ntfs3/xattr.c
+++ b/fs/ntfs3/xattr.c
@@ -868,6 +868,22 @@ static noinline int ntfs_setxattr(const struct xattr_handler *handler,
struct ntfs_inode *ni = ntfs_i(inode);
enum FILE_ATTRIBUTE new_fa;
+ /*
+ * system.dos_attrib and system.ntfs_attrib affect file permissions
+ * because the READONLY flag is mapped to write permission bits.
+ * system.ntfs_security controls NTFS security descriptors.
+ *
+ * Require the caller to own the inode or hold CAP_FOWNER before allowing
+ * these NTFS system attributes to be changed.
+ */
+ if (!strcmp(name, SYSTEM_DOS_ATTRIB) ||
+ !strcmp(name, SYSTEM_NTFS_ATTRIB) ||
+ !strcmp(name, SYSTEM_NTFS_ATTRIB_BE) ||
+ !strcmp(name, SYSTEM_NTFS_SECURITY)) {
+ if (!inode_owner_or_capable(idmap, inode))
+ return -EPERM;
+ }
+
/* Dispatch request. */
if (!strcmp(name, SYSTEM_DOS_ATTRIB)) {
if (sizeof(u8) != size)
--
2.25.1
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH] ntfs3: add permission checks for NTFS system attributes
2026-08-20 8:55 [PATCH] ntfs3: add permission checks for NTFS system attributes Hongling Zeng
@ 2026-11-18 16:47 ` Konstantin Komarov
0 siblings, 0 replies; 2+ messages in thread
From: Konstantin Komarov @ 2026-11-18 16:47 UTC (permalink / raw)
To: Hongling Zeng; +Cc: ntfs3, linux-kernel, zhongling0719, stable
On 8/20/26 10:55, Hongling Zeng wrote:
> ntfs3_setxattr() allows system.dos_attrib, system.ntfs_attrib, and
> system.ntfs_attrib_be to update NTFS file attributes without permission
> checks. These attributes affect the inode mode because the READONLY flag
> is mapped to write permission bits, allowing unprivileged users to bypass
> file access controls.
>
> system.ntfs_security allows modifying NTFS security descriptors which
> control access control. Similar to POSIX ACLs where file owners can
> modify access permissions, require inode owner or CAP_FOWNER for these
> NTFS system attributes.
>
> Fixes: 4534a70b7056 ("fs/ntfs3: Add headers and misc files")
> Cc: stable@vger.kernel.org
> Signed-off-by: Hongling Zeng <zenghongling@kylinos.cn>
> ---
> fs/ntfs3/xattr.c | 16 ++++++++++++++++
> 1 file changed, 16 insertions(+)
>
> diff --git a/fs/ntfs3/xattr.c b/fs/ntfs3/xattr.c
> index 7a81369a1173..4e41aca0d5c7 100644
> --- a/fs/ntfs3/xattr.c
> +++ b/fs/ntfs3/xattr.c
> @@ -868,6 +868,22 @@ static noinline int ntfs_setxattr(const struct xattr_handler *handler,
> struct ntfs_inode *ni = ntfs_i(inode);
> enum FILE_ATTRIBUTE new_fa;
>
> + /*
> + * system.dos_attrib and system.ntfs_attrib affect file permissions
> + * because the READONLY flag is mapped to write permission bits.
> + * system.ntfs_security controls NTFS security descriptors.
> + *
> + * Require the caller to own the inode or hold CAP_FOWNER before allowing
> + * these NTFS system attributes to be changed.
> + */
> + if (!strcmp(name, SYSTEM_DOS_ATTRIB) ||
> + !strcmp(name, SYSTEM_NTFS_ATTRIB) ||
> + !strcmp(name, SYSTEM_NTFS_ATTRIB_BE) ||
> + !strcmp(name, SYSTEM_NTFS_SECURITY)) {
> + if (!inode_owner_or_capable(idmap, inode))
> + return -EPERM;
> + }
> +
> /* Dispatch request. */
> if (!strcmp(name, SYSTEM_DOS_ATTRIB)) {
> if (sizeof(u8) != size)
Hello,
Your patch is applied, thank you.
Regards,
Konstantin
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-18 16:47 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-08-20 8:55 [PATCH] ntfs3: add permission checks for NTFS system attributes Hongling Zeng
2026-11-18 16:47 ` Konstantin Komarov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®