*Re: [PATCH v4 11/14] treewide: Prepare to remove VLA usage for AHASH_REQUEST_ON_STACK
2018-07-11 20:36 ` [PATCH v4 11/14] treewide: Prepare to remove VLA usage for AHASH_REQUEST_ON_STACK Kees Cook
@ 2018-07-12 16:02 ` Arnd Bergmann
2018-07-12 20:17 ` Kees Cook
2018-07-13 0:40 ` Herbert Xu0 siblings, 2 replies; 53+ messages in thread
From: Arnd Bergmann @ 2018-07-12 16:02 UTC (permalink / raw)
To: Kees Cook
Cc: Herbert Xu, Gustavo A. R. Silva, Eric Biggers, Alasdair Kergon,
Giovanni Cabiddu, Lars Persson, Mike Snitzer, Rabin Vincent,
Tim Chen, David S. Miller, Masahiro Yamada,
open list:HARDWARE RANDOM NUMBER GENERATOR CORE, qat-linux,
dm-devel, Linux Kernel Mailing List
On Wed, Jul 11, 2018 at 10:36 PM, Kees Cook <keescook@chromium.org> wrote:
> Several uses of AHASH_REQUEST_ON_STACK() will trigger FRAME_WARN warnings
> (when less than 2048) once the VLA is no longer hidden from the check:
>
> drivers/block/drbd/drbd_worker.c:325:1: warning: the frame size of 1112 bytes is larger than 1024 bytes [-Wframe-larger-than=]
> drivers/block/drbd/drbd_worker.c:352:1: warning: the frame size of 1120 bytes is larger than 1024 bytes [-Wframe-larger-than=]
> crypto/ccm.c:235:1: warning: the frame size of 1184 bytes is larger than 1024 bytes [-Wframe-larger-than=]
> drivers/md/dm-crypt.c:353:1: warning: the frame size of 1096 bytes is larger than 1024 bytes [-Wframe-larger-than=]
> drivers/net/ppp/ppp_mppe.c:158:1: warning: the frame size of 1168 bytes is larger than 1024 bytes [-Wframe-larger-than=]
> net/wireless/lib80211_crypt_tkip.c:537:1: warning: the frame size of 1136 bytes is larger than 1024 bytes [-Wframe-larger-than=]
> drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_tkip.c:528:1: warning: the frame size of 1136 bytes is larger than 1024 bytes [-Wframe-larger-than=]
> drivers/staging/rtl8192e/rtllib_crypt_tkip.c:531:1: warning: the frame size of 1136 bytes is larger than 1024 bytes [-Wframe-larger-than=]
>
> This bumps the affected objects by 20% to silence the warnings while still
> providing coverage is anything grows even more.
>
> Signed-off-by: Kees Cook <keescook@chromium.org>
I think this is a dangerous precedent, I wouldn't really want any of
those functions to
ever take more than 1024 bytes, even that is really too much, but we
can't easily
lower the global limit.
You are patching all users of AHASH_REQUEST_ON_STACK with the exception of
arch/x86/power/hibernate_64.c here (which is always used on 64-bit and has
a larger limit already), which in turn suggests that the AHASH_REQUEST_ON_STACK
macro using bytes is just fundamentally broken by requiring that much space
(808 bytes for the context, plus 8 pointers for struct ahash_request, plus
CRYPTO_MINALIGN_ATTR).
How did you come up with that 808 byte number? I see a total of 39 callers
of crypto_ahash_set_reqsize(), did you check all of those individually?
If 808 bytes is the worst case, what are the next 5 ones? If there are only
a few of them that are badly written, maybe we can fix the drivers instead
and lower that number to something more reasonable.
Looking through some of the drivers, I found this interesting one:
#define SHA_BUFFER_LEN (PAGE_SIZE / 16)
struct atmel_sha_reqctx {
...
u8 buffer[SHA_BUFFER_LEN + SHA512_BLOCK_SIZE] __aligned(sizeof(u32));
};
which would result in overrunning the kernel stack immediately if ever
used with 64k PAGE_SIZE (we fortunately don't support that driver on
any architectures with 64k pages yet).
The other ones I looked at seem to all be well under 400 bytes (which is
still a lot to put on the stack, but probably ok).
Arnd
^permalinkrawreply [flat|nested] 53+ messages in thread

*Re: [PATCH v4 11/14] treewide: Prepare to remove VLA usage for AHASH_REQUEST_ON_STACK
2018-07-12 16:02 ` Arnd Bergmann@ 2018-07-12 20:17 ` Kees Cook
2018-07-12 21:38 ` Arnd Bergmann
2018-07-13 0:40 ` Herbert Xu1 sibling, 1 reply; 53+ messages in thread
From: Kees Cook @ 2018-07-12 20:17 UTC (permalink / raw)
To: Arnd Bergmann
Cc: Herbert Xu, Gustavo A. R. Silva, Eric Biggers, Alasdair Kergon,
Giovanni Cabiddu, Lars Persson, Mike Snitzer, Rabin Vincent,
Tim Chen, David S. Miller, Masahiro Yamada,
open list:HARDWARE RANDOM NUMBER GENERATOR CORE, qat-linux,
dm-devel, Linux Kernel Mailing List
On Thu, Jul 12, 2018 at 9:02 AM, Arnd Bergmann <arnd@arndb.de> wrote:
> On Wed, Jul 11, 2018 at 10:36 PM, Kees Cook <keescook@chromium.org> wrote:
>> Several uses of AHASH_REQUEST_ON_STACK() will trigger FRAME_WARN warnings
>> (when less than 2048) once the VLA is no longer hidden from the check:
>>
>> drivers/block/drbd/drbd_worker.c:325:1: warning: the frame size of 1112 bytes is larger than 1024 bytes [-Wframe-larger-than=]
>> drivers/block/drbd/drbd_worker.c:352:1: warning: the frame size of 1120 bytes is larger than 1024 bytes [-Wframe-larger-than=]
>> crypto/ccm.c:235:1: warning: the frame size of 1184 bytes is larger than 1024 bytes [-Wframe-larger-than=]
>> drivers/md/dm-crypt.c:353:1: warning: the frame size of 1096 bytes is larger than 1024 bytes [-Wframe-larger-than=]
>> drivers/net/ppp/ppp_mppe.c:158:1: warning: the frame size of 1168 bytes is larger than 1024 bytes [-Wframe-larger-than=]
>> net/wireless/lib80211_crypt_tkip.c:537:1: warning: the frame size of 1136 bytes is larger than 1024 bytes [-Wframe-larger-than=]
>> drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_tkip.c:528:1: warning: the frame size of 1136 bytes is larger than 1024 bytes [-Wframe-larger-than=]
>> drivers/staging/rtl8192e/rtllib_crypt_tkip.c:531:1: warning: the frame size of 1136 bytes is larger than 1024 bytes [-Wframe-larger-than=]
>>
>> This bumps the affected objects by 20% to silence the warnings while still
>> providing coverage is anything grows even more.
>>
>> Signed-off-by: Kees Cook <keescook@chromium.org>
>
> I think this is a dangerous precedent, I wouldn't really want any of
> those functions to
> ever take more than 1024 bytes, even that is really too much, but we
> can't easily
> lower the global limit.
The issue is that these are _already_ able to use this much stack
because of the VLA. It was just hidden from the FRAME_WARN checks.
> You are patching all users of AHASH_REQUEST_ON_STACK with the exception of
> arch/x86/power/hibernate_64.c here (which is always used on 64-bit and has
> a larger limit already), which in turn suggests that the AHASH_REQUEST_ON_STACK
> macro using bytes is just fundamentally broken by requiring that much space
> (808 bytes for the context, plus 8 pointers for struct ahash_request, plus
> CRYPTO_MINALIGN_ATTR).
Yes -- it's huge. That's always been true, unfortunately.
> How did you come up with that 808 byte number? I see a total of 39 callers
> of crypto_ahash_set_reqsize(), did you check all of those individually?
> If 808 bytes is the worst case, what are the next 5 ones? If there are only
> a few of them that are badly written, maybe we can fix the drivers instead
> and lower that number to something more reasonable.
That was discussed a bit (maybe not enough?) in the next patch:
https://patchwork.kernel.org/patch/10520407/
I used tcrypt (which examines all sane combinations) and sha512
produces the 808 number. I had done an earlier manual evaluation of
all crypto_ahash_set_reqsize() callers but Herbert and Eric pointed
out issues with my methodology (namely that things can be recursively
stacked (I had calculated too low) but some things will never be
stacked together (so some pathological conditions will never happen)).
So I moved to the tcrypt instrumentation approach, which tests
real-world combinations.
For example, reaching this 808 size is trivially easy to do right now
by just asking for dm-crypt to use a cipher of
capi:cbc(aes)-essiv:sha512.
> Looking through some of the drivers, I found this interesting one:
>
> #define SHA_BUFFER_LEN (PAGE_SIZE / 16)
> struct atmel_sha_reqctx {
> ...
> u8 buffer[SHA_BUFFER_LEN + SHA512_BLOCK_SIZE] __aligned(sizeof(u32));
> };
>
> which would result in overrunning the kernel stack immediately if ever
> used with 64k PAGE_SIZE (we fortunately don't support that driver on
> any architectures with 64k pages yet).
Right -- the large page size isn't reachable there. But we don't
overrun the kernel stack because of the check I added in
crypto_ahash_set_reqsize() in the above mentioned patch.
> The other ones I looked at seem to all be well under 400 bytes (which is
> still a lot to put on the stack, but probably ok).
I wish sha512 was "rare", but it's not. :(
So: mainly the crypto VLA removal is about exposing all these giant
stack usages. We can work to fix them, but I want to get these fixed
so we can add -Wvla to the kernel to avoid more being added (we've had
at least 2 added during this linux-next cycle already).
IMO, we're much better off with this stack usage _actually_ being
checked (even with a 20% bump) than staying entirely hidden (as it's
been).
-Kees
--
Kees Cook
Pixel Security
^permalinkrawreply [flat|nested] 53+ messages in thread

*Re: [PATCH v4 11/14] treewide: Prepare to remove VLA usage for AHASH_REQUEST_ON_STACK
2018-07-12 20:17 ` Kees Cook@ 2018-07-12 21:38 ` Arnd Bergmann0 siblings, 0 replies; 53+ messages in thread
From: Arnd Bergmann @ 2018-07-12 21:38 UTC (permalink / raw)
To: Kees Cook
Cc: Herbert Xu, Gustavo A. R. Silva, Eric Biggers, Alasdair Kergon,
Giovanni Cabiddu, Lars Persson, Mike Snitzer, Rabin Vincent,
Tim Chen, David S. Miller, Masahiro Yamada,
open list:HARDWARE RANDOM NUMBER GENERATOR CORE, qat-linux,
dm-devel, Linux Kernel Mailing List
On Thu, Jul 12, 2018 at 10:17 PM, Kees Cook <keescook@chromium.org> wrote:
> On Thu, Jul 12, 2018 at 9:02 AM, Arnd Bergmann <arnd@arndb.de> wrote:
>> On Wed, Jul 11, 2018 at 10:36 PM, Kees Cook <keescook@chromium.org> wrote:
>>> Several uses of AHASH_REQUEST_ON_STACK() will trigger FRAME_WARN warnings
>>> (when less than 2048) once the VLA is no longer hidden from the check:
>>>
>>> drivers/block/drbd/drbd_worker.c:325:1: warning: the frame size of 1112 bytes is larger than 1024 bytes [-Wframe-larger-than=]
>>> drivers/block/drbd/drbd_worker.c:352:1: warning: the frame size of 1120 bytes is larger than 1024 bytes [-Wframe-larger-than=]
>>> crypto/ccm.c:235:1: warning: the frame size of 1184 bytes is larger than 1024 bytes [-Wframe-larger-than=]
>>> drivers/md/dm-crypt.c:353:1: warning: the frame size of 1096 bytes is larger than 1024 bytes [-Wframe-larger-than=]
>>> drivers/net/ppp/ppp_mppe.c:158:1: warning: the frame size of 1168 bytes is larger than 1024 bytes [-Wframe-larger-than=]
>>> net/wireless/lib80211_crypt_tkip.c:537:1: warning: the frame size of 1136 bytes is larger than 1024 bytes [-Wframe-larger-than=]
>>> drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_tkip.c:528:1: warning: the frame size of 1136 bytes is larger than 1024 bytes [-Wframe-larger-than=]
>>> drivers/staging/rtl8192e/rtllib_crypt_tkip.c:531:1: warning: the frame size of 1136 bytes is larger than 1024 bytes [-Wframe-larger-than=]
>>>
>>> This bumps the affected objects by 20% to silence the warnings while still
>>> providing coverage is anything grows even more.
>>>
>>> Signed-off-by: Kees Cook <keescook@chromium.org>
>>
>> I think this is a dangerous precedent, I wouldn't really want any of
>> those functions to
>> ever take more than 1024 bytes, even that is really too much, but we
>> can't easily
>> lower the global limit.
>
> The issue is that these are _already_ able to use this much stack
> because of the VLA. It was just hidden from the FRAME_WARN checks.
Yes, of course.
>> You are patching all users of AHASH_REQUEST_ON_STACK with the exception of
>> arch/x86/power/hibernate_64.c here (which is always used on 64-bit and has
>> a larger limit already), which in turn suggests that the AHASH_REQUEST_ON_STACK
>> macro using bytes is just fundamentally broken by requiring that much space
>> (808 bytes for the context, plus 8 pointers for struct ahash_request, plus
>> CRYPTO_MINALIGN_ATTR).
>
> Yes -- it's huge. That's always been true, unfortunately.
>
>> How did you come up with that 808 byte number? I see a total of 39 callers
>> of crypto_ahash_set_reqsize(), did you check all of those individually?
>> If 808 bytes is the worst case, what are the next 5 ones? If there are only
>> a few of them that are badly written, maybe we can fix the drivers instead
>> and lower that number to something more reasonable.
>
> That was discussed a bit (maybe not enough?) in the next patch:
> https://patchwork.kernel.org/patch/10520407/
>
> I used tcrypt (which examines all sane combinations) and sha512
> produces the 808 number. I had done an earlier manual evaluation of
> all crypto_ahash_set_reqsize() callers but Herbert and Eric pointed
> out issues with my methodology (namely that things can be recursively
> stacked (I had calculated too low) but some things will never be
> stacked together (so some pathological conditions will never happen)).
> So I moved to the tcrypt instrumentation approach, which tests
> real-world combinations.
>
> For example, reaching this 808 size is trivially easy to do right now
> by just asking for dm-crypt to use a cipher of
> capi:cbc(aes)-essiv:sha512.
Ok, but is there anything that can be done to the sha512
implementation to lower that number? E.g. if a significant chunk
of struct sha512_hash_ctx is only used to hold temporary data,
could it be replaced with e.g. a percpu buffer?
>> The other ones I looked at seem to all be well under 400 bytes (which is
>> still a lot to put on the stack, but probably ok).
>
> I wish sha512 was "rare", but it's not. :(
Looking at the callers of crypto_ahash_set_reqsize(), it appears
that the only instance that is so bad is specifically
arch/x86/crypto/sha512-mb/sha512_mb.c, which is architecture
specific, and only one of multiple implementations of sha512.
Am I misreading that code, or does that mean that we could get
away with using the 808 byte limit only on x86 when
CONFIG_CRYPTO_SHA512_MB is enabled, but using a smaller
limit everywhere where else?
> So: mainly the crypto VLA removal is about exposing all these giant
> stack usages. We can work to fix them, but I want to get these fixed
> so we can add -Wvla to the kernel to avoid more being added (we've had
> at least 2 added during this linux-next cycle already).
>
> IMO, we're much better off with this stack usage _actually_ being
> checked (even with a 20% bump) than staying entirely hidden (as it's
> been).
Yes, definitely. You may recall that I spent several months tracking
down all drivers that grew to insane stack usage when CONFIG_KASAN
was enabled, so we could again turn on the existing stack check
in an allmodconfig build in order to find the normal regressions, so
I'm definitely all for improving both the actual usage and the kind
of diagnostic we have available.
I mainly want to ensure that we have tried anything within reason
to reduce the stack usage of the AHASH_REQUEST_ON_STACK()
users before we resort to changing the warning limit. I'm not
convinced that everything has been tried if we have 808 byte
structures.
Arnd
^permalinkrawreply [flat|nested] 53+ messages in thread

*Re: [PATCH v4 11/14] treewide: Prepare to remove VLA usage for AHASH_REQUEST_ON_STACK
2018-07-13 5:20 ` Herbert Xu@ 2018-07-13 6:00 ` Kees Cook
2018-07-13 10:14 ` Arnd Bergmann0 siblings, 1 reply; 53+ messages in thread
From: Kees Cook @ 2018-07-13 6:00 UTC (permalink / raw)
To: Herbert Xu
Cc: Arnd Bergmann, Gustavo A. R. Silva, Eric Biggers,
Alasdair Kergon, Giovanni Cabiddu, Lars Persson, Mike Snitzer,
Rabin Vincent, Tim Chen, David S. Miller, Masahiro Yamada,
open list:HARDWARE RANDOM NUMBER GENERATOR CORE, qat-linux,
dm-devel, Linux Kernel Mailing List
On Thu, Jul 12, 2018 at 10:20 PM, Herbert Xu
<herbert@gondor.apana.org.au> wrote:
> On Thu, Jul 12, 2018 at 10:17:29PM -0700, Kees Cook wrote:
>>
>> Then why does the instrumented tcrypt output show the huge size? Is
>> tcrypt doing something incorrectly?
>
> tcrypt doesn't even use AHASH_REQUEST_ON_STACK so I don't understand
> your point.
It's using crypto_ahash_set_reqsize(), which is what
AHASH_REQUEST_ON_STACK() reads back via crypto_ahash_reqsize() (i.e.
tfm->reqsize). It sounds like you're saying that there are cases where
an ahash is constructed (and will call crypto_ahash_set_reqsize()) but
where it cannot be used with AHASH_REQUEST_ON_STACK()? What actually
enforces this, since there will be a difference between
crypto_ahash_set_reqsize() (as seen with sha512-mb) and the actually
allowed stack usage. (i.e. where should I perform a check against the
new fixed value?)
>> What is the correct value to use for AHASH_REQUEST_ON_STACK?
>
> As I said to arrive at a fixed value you should examine all sync
> ahash algorithms (e.g., all shash ones plus ahash ones marked as
> sync if there are any).
The "value" for the ahash I understand: it has a request size
(tfm->reqsize, as set by crypto_ahash_set_reqsize()) what should be
used to measure the shash value? (And how does this relate to the
value returned by crypto_ahash_reqsize()?) The closest clue I can find
is this:
crypto_init_shash_ops_async() does:
crt->reqsize = sizeof(struct shash_desc) + crypto_shash_descsize(shash);
and that gets called from crypto_ahash_init_tfm(), so if it starts
with the above reqsize and adds to it with a call to
crypto_ahash_set_reqsize() later, we'll have that maximum?
So, do I want to calculate this answer as:
sizeof(struct shash_desc) + max(shash descsize) + max(ahash-sync reqsize) ?
16 + 360 + 0
It's 0 above because if I look at all the callers of
crypto_ahash_set_reqsize() that do wrapping, all are ASYNC.
So, should this really just be 376? Where is best to validate this
size, as it seems checking in crypto_ahash_set_reqsize() is
inappropriate?
-Kees
--
Kees Cook
Pixel Security
^permalinkrawreply [flat|nested] 53+ messages in thread

*Re: [PATCH v4 11/14] treewide: Prepare to remove VLA usage for AHASH_REQUEST_ON_STACK
2018-07-13 6:00 ` Kees Cook@ 2018-07-13 10:14 ` Arnd Bergmann
2018-07-15 4:28 ` Kees Cook0 siblings, 1 reply; 53+ messages in thread
From: Arnd Bergmann @ 2018-07-13 10:14 UTC (permalink / raw)
To: Kees Cook
Cc: Herbert Xu, Gustavo A. R. Silva, Eric Biggers, Alasdair Kergon,
Giovanni Cabiddu, Lars Persson, Mike Snitzer, Rabin Vincent,
Tim Chen, David S. Miller, Masahiro Yamada,
open list:HARDWARE RANDOM NUMBER GENERATOR CORE, qat-linux,
dm-devel, Linux Kernel Mailing List
On Fri, Jul 13, 2018 at 8:00 AM, Kees Cook <keescook@chromium.org> wrote:
> On Thu, Jul 12, 2018 at 10:20 PM, Herbert Xu
> <herbert@gondor.apana.org.au> wrote:
>> On Thu, Jul 12, 2018 at 10:17:29PM -0700, Kees Cook wrote:
>>> What is the correct value to use for AHASH_REQUEST_ON_STACK?
>>
>> As I said to arrive at a fixed value you should examine all sync
>> ahash algorithms (e.g., all shash ones plus ahash ones marked as
>> sync if there are any).
>
> The "value" for the ahash I understand: it has a request size
> (tfm->reqsize, as set by crypto_ahash_set_reqsize()) what should be
> used to measure the shash value? (And how does this relate to the
> value returned by crypto_ahash_reqsize()?) The closest clue I can find
> is this:
>
> crypto_init_shash_ops_async() does:
> crt->reqsize = sizeof(struct shash_desc) + crypto_shash_descsize(shash);
>
> and that gets called from crypto_ahash_init_tfm(), so if it starts
> with the above reqsize and adds to it with a call to
> crypto_ahash_set_reqsize() later, we'll have that maximum?
>
> So, do I want to calculate this answer as:
>
> sizeof(struct shash_desc) + max(shash descsize) + max(ahash-sync reqsize) ?
> 16 + 360 + 0
I arrived at the same number, looking at all the sizes in shash,
The largest I found are sha3_state (360 bytes) and s390_sha_ctx
(336 bytes), everything else is way smaller.
> It's 0 above because if I look at all the callers of
> crypto_ahash_set_reqsize() that do wrapping, all are ASYNC.
>
> So, should this really just be 376? Where is best to validate this
> size, as it seems checking in crypto_ahash_set_reqsize() is
> inappropriate?
How about crypto_init_shash_ops_async()?
Arnd
^permalinkrawreply [flat|nested] 53+ messages in thread

*Re: [PATCH v4 11/14] treewide: Prepare to remove VLA usage for AHASH_REQUEST_ON_STACK
2018-07-15 4:28 ` Kees Cook@ 2018-07-17 20:59 ` Arnd Bergmann
2018-07-18 14:50 ` Ard Biesheuvel0 siblings, 1 reply; 53+ messages in thread
From: Arnd Bergmann @ 2018-07-17 20:59 UTC (permalink / raw)
To: Kees Cook
Cc: Herbert Xu, Gustavo A. R. Silva, Eric Biggers, Alasdair Kergon,
Giovanni Cabiddu, Lars Persson, Mike Snitzer, Rabin Vincent,
Tim Chen, David S. Miller, Masahiro Yamada,
open list:HARDWARE RANDOM NUMBER GENERATOR CORE, qat-linux,
dm-devel, Linux Kernel Mailing List, Ard Biesheuvel
On Sun, Jul 15, 2018 at 6:28 AM, Kees Cook <keescook@chromium.org> wrote:
>
> After my ahash to shash conversions, only ccm is left as an ahash
> user, since it actually uses sg. But with the hard-coded value reduced
> to 376, this doesn't trip the frame warnings any more. :)
>
> I'll send an updated series soon.
Maybe we should get rid of that one as well then and remove
AHASH_REQUEST_ON_STACK()?
I see that Ard (now on Cc) added this usage only recently. Looking
at the code some more, I also find that the descsize is probably
much smaller than 376 for all possible cases of "cbcmac(*)",
either alg->cra_blocksize plus a few bytes or sizeof(mac_desc_ctx)
(i.e. 20) for arch/arm64/crypto/aes-glue.c.
Walking the sglist here means open-coding a shash_ahash_update()
implementation in crypto_ccm_auth(), that that doesn't seem to
add much complexity over what it already has to do to chain
the sglist today.
Arnd
^permalinkrawreply [flat|nested] 53+ messages in thread

*Re: [PATCH v4 11/14] treewide: Prepare to remove VLA usage for AHASH_REQUEST_ON_STACK
2018-07-17 20:59 ` Arnd Bergmann@ 2018-07-18 14:50 ` Ard Biesheuvel
2018-07-18 15:19 ` Ard Biesheuvel0 siblings, 1 reply; 53+ messages in thread
From: Ard Biesheuvel @ 2018-07-18 14:50 UTC (permalink / raw)
To: Arnd Bergmann
Cc: Kees Cook, Herbert Xu, Gustavo A. R. Silva, Eric Biggers,
Alasdair Kergon, Giovanni Cabiddu, Lars Persson, Mike Snitzer,
Rabin Vincent, Tim Chen, David S. Miller, Masahiro Yamada,
open list:HARDWARE RANDOM NUMBER GENERATOR CORE, qat-linux,
dm-devel, Linux Kernel Mailing List
On 18 July 2018 at 05:59, Arnd Bergmann <arnd@arndb.de> wrote:
> On Sun, Jul 15, 2018 at 6:28 AM, Kees Cook <keescook@chromium.org> wrote:
>>
>> After my ahash to shash conversions, only ccm is left as an ahash
>> user, since it actually uses sg. But with the hard-coded value reduced
>> to 376, this doesn't trip the frame warnings any more. :)
>>
>> I'll send an updated series soon.
>
> Maybe we should get rid of that one as well then and remove
> AHASH_REQUEST_ON_STACK()?
>
> I see that Ard (now on Cc) added this usage only recently. Looking
> at the code some more, I also find that the descsize is probably
> much smaller than 376 for all possible cases of "cbcmac(*)",
> either alg->cra_blocksize plus a few bytes or sizeof(mac_desc_ctx)
> (i.e. 20) for arch/arm64/crypto/aes-glue.c.
>
> Walking the sglist here means open-coding a shash_ahash_update()
> implementation in crypto_ccm_auth(), that that doesn't seem to
> add much complexity over what it already has to do to chain
> the sglist today.
>
It would be better to add a variably sized ahash request member to
struct crypto_ccm_req_priv_ctx, the only problem is that the last
member of that struct (skreq) is variably sized already, so it would
involve having a struct ahash_request pointer pointing into the same
struct, after the skreq member.
^permalinkrawreply [flat|nested] 53+ messages in thread