Re: [PATCH v2 1/4] Wrap crc_t10dif function all to use crypto transform framework

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, 2013-04-28 at 08:11 +0800, Herbert Xu wrote:
> 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.
> 

If I allocate the transform under the mod init instead, how can I make
sure that the fast version is already registered if I have it compiled
in?  It is not clear to me how that's done looking at the libcrc32c
code.  

Thanks.

Tim

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [SCSI Target Devel]     [Linux SCSI Target Infrastructure]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Samba]     [Device Mapper]
  Powered by Linux