[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAKv+Gu-VZTnPGB8YN__vWySceDHEtcBZmgjbEWRzy2HL_eGM2g@mail.gmail.com>
Date: Tue, 8 Oct 2013 15:16:48 +0200
From: Ard Biesheuvel <ard.biesheuvel@...aro.org>
To: David Laight <David.Laight@...lab.com>
Cc: Johannes Berg <johannes@...solutions.net>,
linux-wireless@...r.kernel.org, netdev@...r.kernel.org,
Patch Tracking <patches@...aro.org>,
John Linville <linville@...driver.com>
Subject: Re: [PATCH] mac80211: port CCMP to cryptoapi's CCM driver
On 8 October 2013 15:01, David Laight <David.Laight@...lab.com> wrote:
>> Hmm, thanks I guess. I'll need to review this in more detail, but I have
>> a question first:
>>
>> > + /* allocate the variable sized aead_request on the stack */
>> > + int l = DIV_ROUND_UP(crypto_aead_reqsize(tfm),
>> > + sizeof(struct aead_request));
>> > + struct aead_request req[1 + l];
>>
>> This looks a bit odd, why round up first and then add one? Why even
>> bother using a struct array rather than some local struct like
>
> Is it even a good idea to be allocating variable sized items
> on the kernel stack?
>
> There has to be enough stack available for the maximum number
> of entries - so there is little point in dynamically sizing it.
>
The result of crypto_aead_reqsize() has nothing to do with the input
or output data, it is a property of the particular implementation of
ccm(aes) that is being used. In the generic case (ccm.c),
it always returns the size of this struct
struct crypto_ccm_req_priv_ctx {
u8 odata[16];
u8 idata[16];
u8 auth_tag[16];
u32 ilen;
u32 flags;
struct scatterlist src[2];
struct scatterlist dst[2];
struct ablkcipher_request abreq;
};
while the particular implementation that I am working on for ARM64
always has size 0. Note that this is data that would otherwise be
allocated on the stack, but in the case of aead, which supports an
asynchronous interface (which this code does not use btw), the data is
attached to the end of the aead_request struct instead.
The alternative is to allocate it dynamically using GFP_ATOMIC and
free it at the end of the function, but in this particular case I
don't think that makes much sense tbh
--
Ard.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists