[PATCH v2] crypto: sa2ul - Fix stack overflow in sa_prepare_iopads
Eric Biggers
ebiggers at kernel.org
Tue Sep 22 22:16:33 PDT 2026
On Tue, Sep 22, 2026 at 06:33:51PM +0530, Siddharth Vadapalli wrote:
> On 9/16/26 2:30 PM, Herbert Xu wrote:
> > On Mon, Aug 31, 2026 at 11:21:38AM +0530, Siddharth Vadapalli wrote:
> > >
> > > Since crypto_shash_export() writes 105 bytes into this 104-byte union, it
> > > overflows by one byte into the adjacent stack frame.
> >
> > This should be converted to crypto_shash_export_core which exports
> > just the hash state without the partial block buffer.
> > > Changes since v1:
> > > - Propagated error from sa_prepare_iopads throughout the call chain.
> > > - Added missing check for authentication key size being within limits.
> > > Above changes are based on Sashiko review of the v1 patch at:
> > > https://sashiko.dev/#/patchset/20260819142357.3950463-1-s-vadapalli%40ti.com
> >
> > Looks like Sashiko is still not happy:
> >
> > https://sashiko.dev/#/patchset/20260831055141.1632832-1-s-vadapalli%40ti.com
> >
> > Let's split this up. Just do a one-liner to switch shash_export
> > to shash_export_core, that should fix the stack overrun. Then
> > fix the long key issue in a separate patch.
> >
> > I think you should support long keys properly by hashing them as
> > crypto/hmac.c does.
>
> Thank you for reviewing the patch and providing your valuable feedback.
>
> I will split the patch as you have suggested with the one-line fix patch
> posted first followed by an independent patch posted later for handling long
> keys.
https://lore.kernel.org/linux-crypto/20260923051116.92741-1-ebiggers@kernel.org
fixes both bugs properly by using the crypto library instead. There's
really no need to even consider workarounds using crypto_shash here.
- Eric
More information about the linux-arm-kernel
mailing list