lkml.org 
[lkml]   [2023]   [Mar]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] crypto: caam/jr - fix algorithms exit/cleanup
On Tue, Mar 14, 2023 at 11:37:33PM +0530, meenakshi.aggarwal@nxp.com wrote:
> From: Horia GeantA <horia.geanta@nxp.com>
>
> Current implementations is not being able to gracefully unregister
> crypto algorithms from crypto API while there are users / allocated
> tfms (cra_refcnt > 1).
>
> When unloading the caam_jr module, the .remove callback for the last JR
> device exits with -EBUSY and doesn't perform the clean-up
> (crypto algorithms unregistering etc.).
>
> One side effect of this is leading to an oops, which occurs due to a
> corruption in the linked list of "misc devices"
> (drivers/char/misc.c - misc_list)
>
> Signed-off-by: Horia GeantA <horia.geanta@nxp.com>
> ---
> drivers/crypto/caam/jr.c | 39 +++++++++++++++++++++++++++++++++------
> 1 file changed, 33 insertions(+), 6 deletions(-)

Sorry, I don't think this is the right way to go.

We need to disassociate the registration of the Crypto algorithms
(soft) from the presence of the hardware (hard).

Sure, you can certainly refuse to register any algorithms until
the first piece of hardware shows up. But once you are registered,
you must not unregister yourself from the Crypto API until the module
actually goes away (when built-in that means never).

The complexity then goes into making sure that your driver fails
gracefully when the device goes away in the *middle* of a crypto
computation.

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

\
 
 \ /
  Last update: 2023-03-27 01:00    [W:0.025 / U:0.772 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site