Re: [PATCH 2/2] crypto: caam - fix DMA mapping of stack memory

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

 



On 1/25/2019 3:48 PM, Herbert Xu wrote:
> On Fri, Jan 25, 2019 at 12:43:21PM +0000, Horia Geanta wrote:
>>
>> Herbert, is there something we could do to avoid this?
> 
> Async crypto requests cannot be allocated off the stack.  So
> whoever is doing this needs to stop.
> 
IIUC, the crypto request is allocated in ima_calc_file_hash_atfm() using
ahash_request_alloc(), so this seems to be fine.

However, further below the req->result pointer is set to a location on stack:
out2:
	if (!rc) {
		ahash_request_set_crypt(req, NULL, hash->digest, 0);

More exactly, the call sequence is:
ima_collect_measurement() -> ima_calc_file_hash() -> ima_calc_file_ahash() ->
ima_calc_file_hash_atfm()
and "hash" is allocated on stack in ima_collect_measurement().

Thus, it seems the problem lies in the fact that ahash_request structure defines
the digest buffer as "u8 *result" - thus the memory area might not be DMAable.

Thanks,
Horia




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

  Powered by Linux