From: Ze Tan <tanze@kylinos.cn>
To: sfrench@samba.org, pc@manguebit.org, sprasad@microsoft.com,
linkinjeon@kernel.org, senozhatsky@chromium.org,
chenxiaosong@chenxiaosong.com, linux-cifs@vger.kernel.org,
samba-technical@lists.samba.org
Cc: linux-kernel@vger.kernel.org
Subject: [RFC PATCH 8/9] ksmbd: support trusted EAs
Date: Wed, 15 Jul 2026 15:48:49 +0800 [thread overview]
Message-ID: <20260715074908.641940-9-tanze@kylinos.cn> (raw)
In-Reply-To: <20260715074908.641940-1-tanze@kylinos.cn>
generic/093 uses "setfattr -n trusted.name" and getfattr to check that a
write does not clear the trusted xattr. ksmbd stores the attribute as
user.trusted.name on the backing filesystem.
Map trusted names to the trusted xattr namespace for set, get, and list
operations. Filter the internal POSIX ACL xattrs.
Signed-off-by: Ze Tan <tanze@kylinos.cn>
---
fs/smb/server/smb2pdu.c | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)
diff --git a/fs/smb/server/smb2pdu.c b/fs/smb/server/smb2pdu.c
index ea622798f34e..649aa9f484b7 100644
--- a/fs/smb/server/smb2pdu.c
+++ b/fs/smb/server/smb2pdu.c
@@ -2734,6 +2734,19 @@ static bool smb2_is_private_ea(const char *name, size_t name_len)
return false;
}
+static bool ksmbd_is_internal_acl_ea_name(const char *name, size_t name_len)
+{
+ return (name_len == sizeof(XATTR_NAME_POSIX_ACL_ACCESS) - 1 &&
+ !strncmp(name, XATTR_NAME_POSIX_ACL_ACCESS, name_len)) ||
+ (name_len == sizeof(XATTR_NAME_POSIX_ACL_DEFAULT) - 1 &&
+ !strncmp(name, XATTR_NAME_POSIX_ACL_DEFAULT, name_len)) ||
+ (name_len == sizeof(XATTR_TRUSTED_PREFIX "SGI_ACL_FILE") - 1 &&
+ !strncmp(name, XATTR_TRUSTED_PREFIX "SGI_ACL_FILE", name_len)) ||
+ (name_len == sizeof(XATTR_TRUSTED_PREFIX "SGI_ACL_DEFAULT") - 1 &&
+ !strncmp(name, XATTR_TRUSTED_PREFIX "SGI_ACL_DEFAULT",
+ name_len));
+}
+
static bool ksmbd_is_security_capability_ea_name(const char *name,
size_t name_len)
{
@@ -2756,6 +2769,18 @@ static bool ksmbd_is_posix_ea_name(const char *name, size_t name_len)
if (ksmbd_is_security_xfstests_ea_name(name, name_len))
return true;
+ /*
+ * POSIX ACL xattrs are filesystem-internal ACL records, not
+ * user-visible EAs. XFS may also expose trusted.SGI_ACL_* aliases
+ * through listxattr(), so filter those as well.
+ */
+ if (ksmbd_is_internal_acl_ea_name(name, name_len))
+ return false;
+
+ if (name_len > XATTR_TRUSTED_PREFIX_LEN &&
+ !strncmp(name, XATTR_TRUSTED_PREFIX, XATTR_TRUSTED_PREFIX_LEN))
+ return true;
+
return false;
}
@@ -2763,6 +2788,9 @@ static int ksmbd_map_ea_name_to_xattr(bool posix_extensions,
const char *ea_name, size_t ea_name_len,
char *attr_name)
{
+ if (ksmbd_is_internal_acl_ea_name(ea_name, ea_name_len))
+ return -EINVAL;
+
if (posix_extensions &&
ksmbd_is_posix_ea_name(ea_name, ea_name_len)) {
if (ea_name_len > XATTR_NAME_MAX)
--
2.43.0
next prev parent reply other threads:[~2026-07-15 7:50 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-15 7:48 [RFC PATCH 0/9] smb: support security and trusted xattrs over EAs Ze Tan
2026-07-15 7:48 ` [RFC PATCH 1/9] smb: client: support security.capability " Ze Tan
2026-07-15 7:48 ` [RFC PATCH 2/9] smb: client: support security.xfstests " Ze Tan
2026-07-15 7:48 ` [RFC PATCH 3/9] smb: client: support trusted xattrs " Ze Tan
2026-07-15 7:48 ` [RFC PATCH 4/9] ksmbd: extract SMB EA backing xattr name mapping Ze Tan
2026-07-15 7:48 ` [RFC PATCH 5/9] ksmbd: extract SMB EA response name handling Ze Tan
2026-07-15 7:48 ` [RFC PATCH 6/9] ksmbd: support security.capability EAs Ze Tan
2026-07-15 7:48 ` [RFC PATCH 7/9] ksmbd: support security.xfstests EAs Ze Tan
2026-07-15 7:48 ` Ze Tan [this message]
2026-07-15 7:48 ` [RFC PATCH 9/9] ksmbd: avoid self oplock breaks for EA opens Ze Tan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260715074908.641940-9-tanze@kylinos.cn \
--to=tanze@kylinos.cn \
--cc=chenxiaosong@chenxiaosong.com \
--cc=linkinjeon@kernel.org \
--cc=linux-cifs@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pc@manguebit.org \
--cc=samba-technical@lists.samba.org \
--cc=senozhatsky@chromium.org \
--cc=sfrench@samba.org \
--cc=sprasad@microsoft.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox