* [PATCH] ksmbd: fail SET_INFO when the security descriptor cannot be stored
@ 2026-11-18 15:55 Ian Bridges
0 siblings, 0 replies; only message in thread
From: Ian Bridges @ 2026-11-18 15:55 UTC (permalink / raw)
To: linkinjeon
Cc: senozhatsky, tom, chenxiaosong, linux-cifs, linux-kernel,
Ian Bridges, stable
set_info_sec() removes the stored security descriptor and then stores
the new one with ksmbd_vfs_set_sd_xattr(), but it ignores the result of
the store. When the store fails, SET_INFO still reports success. The
old descriptor is gone and the new one is missing, so access falls back
to the POSIX permissions. Deny ACEs the client just set do not apply.
A client can make the store fail at will. It only has to send a
descriptor larger than the xattr space the filesystem has for the file.
On the ext4 filesystem with 4 KiB blocks used in testing, a DACL of 86
ACEs was already too large, and the store failed with -ENOSPC.
Return the store's error from SET_INFO, so the client gets
STATUS_DISK_FULL in that case. Keep returning success when the
filesystem does not support the xattr. Keep it for a CREATE with a
security descriptor context too, because the file already exists at
that point.
Fixes: e2f34481b24d ("cifsd: add server-side procedures for SMB3")
Cc: stable@vger.kernel.org
Signed-off-by: Ian Bridges <icb@fastmail.org>
---
This is a narrow fix. It only stops SET_INFO from reporting success
when the store fails. It does not make the request atomic. By the time
the store fails, the owner, group, mode and POSIX ACLs are already
changed and the old descriptor is gone. Restoring them would mean
saving the old state and writing it back on every failure path, and
those writes can fail as well. That is a much larger change than this
fix, so it is left for later.
Tested on ksmbd-for-next 267029b35ad1 with KASAN. A SET_INFO whose
DACL does not fit in the xattr space now fails with STATUS_DISK_FULL.
A store that fails for lack of memory also fails the SET_INFO. A small
SET_INFO stores the same descriptor as before. On a filesystem without
xattr support, SET_INFO and a CREATE with a security descriptor context
still succeed. A CREATE whose descriptor context cannot be stored still
succeeds and creates the file. smbtorture results match the base.
This patch was developed with LLM assistance.
fs/smb/server/smbacl.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/fs/smb/server/smbacl.c b/fs/smb/server/smbacl.c
index a87c22fa9a6e..3770dda2b3ed 100644
--- a/fs/smb/server/smbacl.c
+++ b/fs/smb/server/smbacl.c
@@ -1984,7 +1984,14 @@ int set_info_sec(struct ksmbd_conn *conn, struct ksmbd_tree_connect *tcon,
if (test_share_config_flag(tcon->share_conf, KSMBD_SHARE_FLAG_ACL_XATTR)) {
/* Update WinACL in xattr */
ksmbd_vfs_remove_sd_xattrs(idmap, path);
- ksmbd_vfs_set_sd_xattr(conn, idmap, path, pntsd, ntsd_len);
+ rc = ksmbd_vfs_set_sd_xattr(conn, idmap, path, pntsd, ntsd_len);
+ /*
+ * The CREATE context (type_check) stays best effort because
+ * the file exists already. A filesystem without the xattr is
+ * not an error either.
+ */
+ if (type_check || rc == -EOPNOTSUPP)
+ rc = 0;
}
out:
--
2.47.3
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-11-18 15:55 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-18 15:55 [PATCH] ksmbd: fail SET_INFO when the security descriptor cannot be stored Ian Bridges
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®