Re: [PATCH v2 0/5] smb: server: Clear sensitive data before freeing it

From: Namjae Jeon

Date: Wed Aug 12 2026 - 09:03:36 EST


On Wed, Aug 12, 2026 at 12:46 AM Thomas Huth <thuth@xxxxxxxxxx> wrote:
>
> Sensitive data like keys that are stored in stack-local arrays could be
> leaked via the stack to the calling functions, or via the heap when using
> only normal kfree() functions.
>
> It's good security practice to clear sensitive data on the stack first
> with memzero_explicit() before leaving the context, and to use
> kfree_sensitive() for data that is returned to the heap.
>
> Disclaimer: The spots that need clearing have been identified with AI,
> but the patches have been created manually (for double-checking whether
> the findings really make sense). Anyway, I'm not very familiar with the
> smb code, so please review carefully. Thanks!
>
> v2:
> - Calculate proper size for the kvfree_sensitive() in the first patch
> - Add "kfree_sensitive(target)" hunk to the connection.c patch
> - Add patch to clear Preauth_HashValue in smb2pdu.c
Applied them to #ksmbd-for-next-next.
Thanks!