[PATCH 4/4] smb: server: Free sensitive connection data with kfree_sensitive()
From: Thomas Huth
Date: Mon Aug 10 2026 - 09:33:38 EST
From: Thomas Huth <thuth@xxxxxxxxxx>
struct ksmbd_conn contains an embedded struct ntlmssp_auth with the
ciphertext[] and cryptkey[] arrays, so to avoid leaking this information
via the heap, it should be freed with kfree_sensitive().
While we're at it, also use kfree_sensitive() for freeing preauth_info
in ksmbd_conn_free() to avoid that the Preauth_HashValue[] could leak
via the heap here, too.
Signed-off-by: Thomas Huth <thuth@xxxxxxxxxx>
---
fs/smb/server/connection.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/fs/smb/server/connection.c b/fs/smb/server/connection.c
index ef6f202f4024c..bcb688c9af918 100644
--- a/fs/smb/server/connection.c
+++ b/fs/smb/server/connection.c
@@ -117,7 +117,7 @@ static void __ksmbd_conn_release_work(struct work_struct *work)
ida_destroy(&conn->async_ida);
conn->transport->ops->free_transport(conn->transport);
- kfree(conn);
+ kfree_sensitive(conn);
}
/**
@@ -183,7 +183,7 @@ void ksmbd_conn_free(struct ksmbd_conn *conn)
*/
xa_destroy(&conn->sessions);
kvfree(conn->request_buf);
- kfree(conn->preauth_info);
+ kfree_sensitive(conn->preauth_info);
kfree(conn->mechToken);
ksmbd_conn_put(conn);
}
--
2.55.0