Re: [PATCH] crypto/hisilicon: Add null judgment to the callback interface

From: Herbert Xu
Date: Thu Nov 10 2022 - 03:53:50 EST


On Thu, Nov 10, 2022 at 12:11:15PM +0800, liulongfang wrote:
>
> When using crypto's skcipher series interfaces for encryption and decryption
> services, User can use synchronous mode(by adjusting some skcipher interfaces,
> here is to remove skcipher_request_set_callback()) or asynchronous mode,
> but when using synchronous mode and the current asynchronous mode is loaded
> it will cause a calltrace.
>
> The current problem is that the interface of skcipher does not restrict users
> to call functions in this way for encryption services.
>
> If the current driver doesn't handle this, there is a possibility that some users
> deliberately create this kind of problem to cause the kernel to crash.

It sounds like your code is misusing the skcipher API. By default
skcipher is always async. You must always set a callback.

The only way to legally use skcipher without setting a callback
is by allocating it with crypto_alloc_sync_skcipher. In which case
unless your driver incorrectly declares itself as sync instead of
async, then it will never be used by such a user.

Cheers,
--
Email: Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt