From: Ian Bridges <icb@fastmail.org>
To: linkinjeon@kernel.org
Cc: senozhatsky@chromium.org, tom@talpey.com,
chenxiaosong@chenxiaosong.com, linux-cifs@vger.kernel.org,
linux-kernel@vger.kernel.org, Ian Bridges <icb@fastmail.org>,
stable@vger.kernel.org
Subject: [PATCH v2] ksmbd: fail SET_INFO when the security descriptor cannot be stored
Date: Thu, 19 Nov 2026 00:51:07 -0600 [thread overview]
Message-ID: <20261119065107.115679-1-icb@fastmail.org> (raw)
SET_INFO reports success even when ksmbd cannot store the new security
descriptor. The old descriptor has already been removed, so the file
falls back to POSIX permissions. Deny ACEs in the new descriptor are
lost. This can happen when the descriptor exceeds the filesystem's
xattr capacity.
Return the storage error to the client. Report -E2BIG as
STATUS_DISK_FULL, like -ENOSPC and -EFBIG, and report -ENOMEM as
STATUS_INSUFFICIENT_RESOURCES. Both errors previously fell through to
STATUS_INVALID_INFO_CLASS. These mappings apply to all SET_INFO
classes.
Preserve success for filesystems that do not support the xattr. Also
preserve the best-effort store for CREATE, where the file has already
been created.
Fixes: e2f34481b24d ("cifsd: add server-side procedures for SMB3")
Cc: stable@vger.kernel.org
Signed-off-by: Ian Bridges <icb@fastmail.org>
---
Since v1
- Handle -ENOMEM and -E2BIG as requested by Namjae Jeon. Use
STATUS_INSUFFICIENT_RESOURCES and STATUS_DISK_FULL, respectively.
A failed SET_INFO can still leave partial changes. The owner, group,
mode and POSIX ACL updates happen before the store, as does the removal
of the old descriptor. This patch reports the failure without rolling
back those changes.
Tested on ksmbd-for-next 267029b35ad1 with KASAN. A DACL too large for
the tested ext4 filesystem now produces STATUS_DISK_FULL. Injected
allocation failure produces STATUS_INSUFFICIENT_RESOURCES. A test
build that substitutes -E2BIG for the store's -ENOSPC also produces
STATUS_DISK_FULL. Small descriptors and filesystems without xattr
support behave as before. CREATE still succeeds if storing its
descriptor fails. smbtorture results match the base.
This patch was developed with LLM assistance.
v1: https://lore.kernel.org/linux-cifs/20261118155521.70611-1-icb@fastmail.org/
fs/smb/server/smb2pdu.c | 4 +++-
fs/smb/server/smbacl.c | 9 ++++++++-
2 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/fs/smb/server/smb2pdu.c b/fs/smb/server/smb2pdu.c
index 29750970f8da..3382974df8d1 100644
--- a/fs/smb/server/smb2pdu.c
+++ b/fs/smb/server/smb2pdu.c
@@ -9526,8 +9526,10 @@ int smb2_set_info(struct ksmbd_work *work)
rsp->hdr.Status = STATUS_EA_LIST_INCONSISTENT;
else if (rc == -EMSGSIZE)
rsp->hdr.Status = STATUS_INFO_LENGTH_MISMATCH;
- else if (rc == -ENOSPC || rc == -EFBIG)
+ else if (rc == -ENOSPC || rc == -EFBIG || rc == -E2BIG)
rsp->hdr.Status = STATUS_DISK_FULL;
+ else if (rc == -ENOMEM)
+ rsp->hdr.Status = STATUS_INSUFFICIENT_RESOURCES;
else if (rc == -ESHARE)
rsp->hdr.Status = STATUS_SHARING_VIOLATION;
else if (rc == -ENOENT)
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
reply other threads:[~2026-11-19 6:51 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20261119065107.115679-1-icb@fastmail.org \
--to=icb@fastmail.org \
--cc=chenxiaosong@chenxiaosong.com \
--cc=linkinjeon@kernel.org \
--cc=linux-cifs@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=senozhatsky@chromium.org \
--cc=stable@vger.kernel.org \
--cc=tom@talpey.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
all inboxes | Powered by JetHome®