mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
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>
Subject: [PATCH] ksmbd: rate limit the log for a failed security descriptor store
Date: Wed, 18 Nov 2026 09:58:18 -0600	[thread overview]
Message-ID: <20261118155818.70792-1-icb@fastmail.org> (raw)

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


                 reply	other threads:[~2026-11-18 15:58 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=20261118155818.70792-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=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®