lkml.org 
[lkml]   [2013]   [Apr]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v2 1/4] Wrap crc_t10dif function all to use crypto transform framework
On Fri, Apr 26, 2013 at 09:44:17AM -0700, Tim Chen wrote:
>
> + old_tfm = crct10dif_tfm;
> + crc_t10dif_newalg = true;
> + /* make sure new alg flag is turned on before starting to switch tfm */
> + mb();
> +
> + new_tfm = crypto_alloc_shash("crct10dif", 0, 0);
> + if (IS_ERR(new_tfm))
> + goto done;
> +
> + if (old_tfm)
> + if (crypto_tfm_alg_priority(&old_tfm->base) >=
> + crypto_tfm_alg_priority(&new_tfm->base)) {
> + crypto_free_shash(new_tfm);
> + goto done;
> + }
> + crct10dif_tfm = new_tfm;
> + /* make sure update to tfm pointer is completed */
> + mb();
> + crypto_free_shash(old_tfm);

This is not safe at all. You'd need to use something like RCU.

However, I think this is an overkill. Initialising it once should
be enough. If someone really wanted to change things at run-time,
they could always build this as a module and unload/reload it.

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: 2013-04-28 02:41    [W:0.063 / U:8.088 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site