[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20130428001122.GA6973@gondor.apana.org.au>
Date: Sun, 28 Apr 2013 08:11:22 +0800
From: Herbert Xu <herbert@...dor.apana.org.au>
To: Tim Chen <tim.c.chen@...ux.intel.com>
Cc: "H. Peter Anvin" <hpa@...or.com>,
"David S. Miller" <davem@...emloft.net>,
"Martin K. Petersen" <martin.petersen@...cle.com>,
James Bottomley <James.Bottomley@...senPartnership.com>,
Matthew Wilcox <willy@...ux.intel.com>,
Jim Kukunas <james.t.kukunas@...ux.intel.com>,
Keith Busch <keith.busch@...el.com>,
Erdinc Ozturk <erdinc.ozturk@...el.com>,
Vinodh Gopal <vinodh.gopal@...el.com>,
James Guilford <james.guilford@...el.com>,
Wajdi Feghali <wajdi.k.feghali@...el.com>,
Jussi Kivilinna <jussi.kivilinna@....fi>,
linux-kernel <linux-kernel@...r.kernel.org>,
linux-crypto@...r.kernel.org, linux-scsi@...r.kernel.org
Subject: Re: [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@...dor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists