Thread (53 messages) 53 messages, 5 authors, 2018-07-19

Re: [PATCH v4 11/14] treewide: Prepare to remove VLA usage for AHASH_REQUEST_ON_STACK

From: Kees Cook <hidden>
Date: 2018-07-16 03:40:04
Also in: dm-devel, lkml

On Sun, Jul 15, 2018 at 5:01 PM, Herbert Xu [off-list ref] wrote:
On Sat, Jul 14, 2018 at 07:59:09PM -0700, Kees Cook wrote:
quoted
On Sat, Jul 14, 2018 at 7:44 PM, Herbert Xu [off-list ref] wrote:
quoted
On Fri, Jul 13, 2018 at 08:07:10PM -0700, Kees Cook wrote:
quoted
On a plane today I started converting all these to shash. IIUC, it
just looks like this (apologies for whitespace damage):
Yes if it doesn't actually make use of SGs then shash would be
the way to go.  However, for SG users ahash is the best interface.
Nearly all of them artificially build an sg explicitly to use the
ahash interface. :P

So, I'll take that as a "yes, do these conversions." :) Thanks!
Yeah anything that's doing a single-element SG list should just
be converted.
There are a few that are multiple element SG list, but it's a locally
allocated array of SGs, and filled with data. All easily replaced with
just calls to ..._update() instead of sg helpers. For example
net/wireless/lib80211_crypt_tkip.c:

-       sg_init_table(sg, 2);
-       sg_set_buf(&sg[0], hdr, 16);
-       sg_set_buf(&sg[1], data, data_len);
...
-       ahash_request_set_tfm(req, tfm_michael);
-       ahash_request_set_callback(req, 0, NULL, NULL);
-       ahash_request_set_crypt(req, sg, mic, data_len + 16);
-       err = crypto_ahash_digest(req);
-       ahash_request_zero(req);
+       err = crypto_shash_init(desc);
+       if (err)
+               goto out;
+       err = crypto_shash_update(desc, hdr, 16);
+       if (err)
+               goto out;
+       err = crypto_shash_update(desc, data, data_len);
+       if (err)
+               goto out;
+       err = crypto_shash_final(desc, mic);
+
+out:
+       shash_desc_zero(desc);
        return err;

-Kees

-- 
Kees Cook
Pixel Security
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help