Re: [PATCH v4 00/13] libcrypto: Provide more __cleanup functions for zeroizing data

From: Eric Biggers

Date: Tue Sep 22 2026 - 23:20:33 EST


On Wed, Sep 16, 2026 at 11:50:02AM +0200, Thomas Huth wrote:
> Code that uses crypto-related structures (containing keys or context data)
> should zeroize their local structures on the stack after use to avoid
> leaking this sensitive material via the stack when the function returns.
> Using the __cleanup() marker is a very elegant way to assert that the
> data is zeroized without having to painfully verify that each early return
> in a function might miss it.
>
> Thus this series introduces zeroization functions for many crypto-related
> structures that can be used with __cleanup(). The series focuses on the
> introduction of the functions - most call sights will be adjusted to use
> these new functions in separate patch series later (since each subsystem
> needs separate review from the corresponding maintainer).
>
> Note there is one minor ugliness in the patch "Compile purgatory with
> -D__NO_FORTIFY": Since sha2.h is also used in the x86 purgatory code,
> and that code ships with its own implementation of string functions, we
> have to compile the x86 purgatory with -D__NO_FORTIFY now to be able
> to include <linux/string.h> in sha2.h.
>

Applied to https://git.kernel.org/pub/scm/linux/kernel/git/ebiggers/linux.git/log/?h=libcrypto-next

- Eric