[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <Z0RTgsb5Va9psaIs@gondor.apana.org.au>
Date: Mon, 25 Nov 2024 18:37:54 +0800
From: Herbert Xu <herbert@...dor.apana.org.au>
To: Lukas Wunner <lukas@...ner.de>
Cc: Ard Biesheuvel <ardb@...nel.org>, Zorro Lang <zlang@...hat.com>,
linux-crypto@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [Bug report] kernel BUG at include/linux/scatterlist.h
On Mon, Nov 25, 2024 at 11:29:30AM +0100, Lukas Wunner wrote:
>
> crypto_akcipher_sync_encrypt() kmalloc's a buffer and copies from
> the kernel's .rodata section to that buffer. That's why it doesn't
> throw the false-positive BUG_ON() on arm64: virt_addr_valid() is
> happy if the virtual address is in the linear map.
That's the whole point, only kmalloced addresses are allowed for
SG lists. You cannot place an arbitrary virtual address into an
SG list, it's just broken.
> I deliberately avoided the crypto_akcipher_sync_encrypt() API
> in rsassa-pkcs1.c because the extra buffer allocation plus copying
> data around impacts performance for no benefit.
This is temporary. The idea is to convert the akcipher software
implementations over to use virtual addresses directly so that no
unnecessary copy occurs. Have a look at what I did with ahash:
https://lore.kernel.org/linux-crypto/bffef4bab1bf250bd64a3d02de53eb1fd047a96e.1730021644.git.herbert@gondor.apana.org.au/
This is what I'd like to do with akcipher as well.
Longer term there is potentially another unnecessary copy if you
go from a kmalloced virtual address to an akcipher hardware driver,
but we could eliminate that by adding a flag to indicate that the
virtual address is safe for use within an SG list.
> So if you absolutely positively want to use crypto_akcipher_sync_encrypt()
> in rsassa-pkcs1.c, I can change that. But it will come at a performance
> cost without apparent benefit. Are you sure (y/n)?
Yes.
Thanks,
--
Email: Herbert Xu <herbert@...dor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
Powered by blists - more mailing lists