Skip to contentSkip to conversation

ksmbd: do not log a stale security descriptor as an error

PATCH Applied Ian Bridges 2 participants 2 messages Nov 17 – Nov 18

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ksmbd: do not log a stale security descriptor as an error

ksmbd stores a hash of the file's owner, group, mode and POSIX ACLs with each security descriptor. ksmbd_vfs_get_sd_xattr() recomputes the hash when it loads the descriptor. If the two differ, the descriptor is stale and ksmbd treats it as absent. That is expected after a chmod, chown or setfacl on the server, but the function logs "hash value diff" with pr_err() every time.

Opens, security queries, hide-unreadable listings and inheritance can all load stored descriptors. Repeated opens of a file with a stale descriptor can therefore fill the kernel log.

Report a stale descriptor with ksmbd_debug() instead, and include the file name in the message.

---

Tested on ksmbd-for-next c1a783037082 with KASAN. Opening a file whose stored descriptor is stale no longer logs an error. With SMB debugging on, each open logs the new debug line. smbtorture results match the base.

This patch was developed with LLM assistance.

 fs/smb/server/vfs.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
fs/smb/server/vfs.c +2 -1
index 1114f2503ea7..83b0bf783886 100644
@@ -1829,7 +1829,8 @@ int ksmbd_vfs_get_sd_xattr(struct ksmbd_conn *conn,
 	sha256(acl_ndr.data, acl_ndr.offset, cmp_hash);
 
 	if (memcmp(cmp_hash, acl.posix_acl_hash, XATTR_SD_HASH_SIZE)) {
-		pr_err("hash value diff\n");
+		ksmbd_debug(SMB, "stored SD of %pd is stale, not used\n",
+			    dentry);
 		rc = -EINVAL;
 		goto out_free;
 	}
Signature · 1 line
2.47.3
maintainer Applied
#1 lore raw
Quoted 8 lines · Ian Bridges

ksmbd stores a hash of the file's owner, group, mode and POSIX ACLs with each security descriptor. ksmbd_vfs_get_sd_xattr() recomputes the hash when it loads the descriptor. If the two differ, the descriptor is stale and ksmbd treats it as absent. That is expected after a chmod, chown or setfacl on the server, but the function logs "hash value diff" with pr_err() every time.

Quoted 8 lines

Opens, security queries, hide-unreadable listings and inheritance can all load stored descriptors. Repeated opens of a file with a stale descriptor can therefore fill the kernel log.

Report a stale descriptor with ksmbd_debug() instead, and include the file name in the message.

Applied it to #ksmbd-for-next.
Thanks!