Re: [PATCH v3] crypto: rsassa-pkcs1 - Align DMA buffer to CRYPTO_DMA_ALIGN

Lukas Wunner <[email protected]> Wed, 29 Jul 2026 22:29:08 +0200
Newsgroups org.kernel.vger.linux-crypto,org.kernel.vger.linux-kernel
Message-ID <[email protected]>
On Wed, Jul 29, 2026 at 10:41:56AM +1000, Changwei Zou wrote:
> out_buf is used as a DMA buffer for the RSA verification operation.
> If out_buf is not aligned to CRYPTO_DMA_ALIGN, cacheline sharing
> problems (data corruption) would occur on CPUs with DMA-incoherent caches,
> leading to -EKEYREJECTED.
> 
> Fix by aligning out_buf to CRYPTO_DMA_ALIGN using PTR_ALIGN(), and
> allocating CRYPTO_DMA_ALIGN - 1 extra bytes in the child_req allocation
> to accommodate the alignment padding as child_reqsize is a variable.

sashiko believes that rsassa_pkcs1_sign() suffers from the same issue
as the _verify() code path:

https://sashiko.dev/#/patchset/20260729004156.11925-1-changwei.zou%40canonical.com

That doesn't seem to be the case right now because the only callers
in the tree (test_sig_one() and keyctl_pkey_e_d_s()) use kmalloc()
or kzalloc() for the destination buffer, which should fulfil the
alignment requirements of the caam hardware.

Thanks,

Lukas