Re: [RFC] crypto: sa2ul - sha1/sha256/sha512 support

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

 



Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx> writes:

> On Wed, Jun 05, 2024 at 06:12:22PM +0530, Kamlesh Gurudasani wrote:
>>
>> The way I understand algif_hash calls the digest function[0] if entire
>> file(file whose SHA needs to be calculated) is less than 16 *
>> PAGE_SIZE(4 kb for us) 
>
> If that is the concern we should explore increasing the limit,
> or at least making it configurable.  The limit exists in order
> to prevent user-space from exhausting kernel memory, so it is
> meant to be admin-configurable.
Increasing the limit is do able.

But even if we increase the limit to ~1Mb. Calculating the file with size
bigger than that will again fall back to init-> update -> finup.

Also, the size that can be held by one sg list [0] is 204 entries,
which can hold upto 800KB of data. I'm not sure if this is still true.
Old article. If we consider chaining we can have more data, not sure how
HW handles that.

If the file size is about 100 MB in that case it will fallback to init
-> update -> finup.

If at max I can get 800KB, then I think it would be better if we save
64kb in context and implement virtual finup in init -> update -> final.

Allocating 800kb in algif_hash module vs 64kb in sa2ul driver.

This would be generic solution and will fit all scenarios.

If we rely on digest, it will always have some limitation.
Like if user allocates only 5MB buffer and file size was 10MB and data
came in two update() instead of one digest(). (MSG_MORE flag scenario
in algif_hash)

[0]https://lwn.net/Articles/234617/

Cheers,
Kamlesh

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




[Index of Archives]     [Kernel]     [Gnu Classpath]     [Gnu Crypto]     [DM Crypt]     [Netfilter]     [Bugtraq]
  Powered by Linux