mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] ksmbd: rate limit the log for a failed security descriptor store
@ 2026-11-18 15:58 Ian Bridges
  0 siblings, 0 replies; only message in thread
From: Ian Bridges @ 2026-11-18 15:58 UTC (permalink / raw)
  To: linkinjeon
  Cc: senozhatsky, tom, chenxiaosong, linux-cifs, linux-kernel, Ian Bridges

ksmbd_vfs_set_sd_xattr() logs every failed store with pr_err(), with no
rate limit and without the file name. 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. Each
SET_INFO or CREATE that carries such a DACL then writes an error line
to the kernel log.

When smb2_open() stores the default security descriptor of a new file,
it logs the same failure a second time.

Log the failure with pr_warn_ratelimited() and include the file name.
Drop the second message in smb2_open().

Signed-off-by: Ian Bridges <icb@fastmail.org>
---

smb2_open() also logged two early returns of ksmbd_vfs_set_sd_xattr()
that the new message does not cover. One is a length shorter than the
descriptor header. That cannot happen here, because smb2_open() builds
the descriptor itself. The other is a failed copy of the descriptor,
which this path no longer logs. Callers do not usually log allocation
failures, so the patch adds no message for it.

Tested on ksmbd-for-next 267029b35ad1 with KASAN. A run of forty
SET_INFOs whose DACL does not fit now logs the first ten failures and
reports the rest as suppressed. Each line names the file. smb2_open()
no longer logs the failure a second time. smbtorture results match the
base.

This patch was developed with LLM assistance.

 fs/smb/server/smb2pdu.c | 10 ++--------
 fs/smb/server/vfs.c     |  3 ++-
 2 files changed, 4 insertions(+), 9 deletions(-)

diff --git a/fs/smb/server/smb2pdu.c b/fs/smb/server/smb2pdu.c
index 29750970f8da..987049a52e54 100644
--- a/fs/smb/server/smb2pdu.c
+++ b/fs/smb/server/smb2pdu.c
@@ -5271,15 +5271,9 @@ int smb2_open(struct ksmbd_work *work)
 						goto err_out;
 					}
 
-					rc = ksmbd_vfs_set_sd_xattr(conn,
-								    idmap,
-								    &path,
-								    pntsd,
-								    pntsd_size);
+					ksmbd_vfs_set_sd_xattr(conn, idmap, &path,
+							       pntsd, pntsd_size);
 					kvfree(pntsd);
-					if (rc)
-						pr_err("failed to store ntacl in xattr : %d\n",
-						       rc);
 				}
 			}
 		}
diff --git a/fs/smb/server/vfs.c b/fs/smb/server/vfs.c
index 83b0bf783886..39bbe6aad629 100644
--- a/fs/smb/server/vfs.c
+++ b/fs/smb/server/vfs.c
@@ -1767,7 +1767,8 @@ int ksmbd_vfs_set_sd_xattr(struct ksmbd_conn *conn,
 				XATTR_NAME_SD, sd_ndr.data,
 				sd_ndr.offset, 0, true);
 	if (rc < 0)
-		pr_err("Failed to store XATTR ntacl :%d\n", rc);
+		pr_warn_ratelimited("failed to store the security descriptor of %pd: %d\n",
+				    dentry, rc);
 
 out:
 	kfree(sd_ndr.data);
-- 
2.47.3


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2026-11-18 15:58 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:58 [PATCH] ksmbd: rate limit the log for a failed security descriptor store 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®