On 2025-08-25 16:23, Mikulas Patocka wrote:
Hi
I'd like to ask about this condition in crypto_ahash_digest:
if (ahash_req_on_stack(req) && ahash_is_async(tfm))
return -EAGAIN;
Can it be removed? Or, is there some reason why you can't have
asynchronous requests on the stack (such as inability of doing DMA to
virtually mapped stack)?
Or, should I just clear the flag CRYPTO_TFM_REQ_ON_STACK in my code?
I'm modifying dm-integrity to use asynchronous API so that Harald
Freudenberger can use it on mainframes (the reason is that his
implementation only provides asynchronous API) and I would prefer to
place
ahash requests on the stack (and wait for them before the function
exits).
The commit 04bfa4c7d5119ca38f8133bfdae7957a60c8b221 says that we should
clone the request with HASH_REQUEST_CLONE, but that is not usable in
dm-integrity, because dm-integrity must work even when the system is
out
of memory.
Mikulas
The problem with this 'on the stack' is also with the buffer addresses.
The asynch implementations get scatterlists. By playing around there,
I found out that the addresses in scatterlists are checked:
scatterlist.h:
static inline void sg_set_buf(struct scatterlist *sg, const void *buf,
unsigned int buflen)
{
#ifdef CONFIG_DEBUG_SG
BUG_ON(!virt_addr_valid(buf));
#endif
sg_set_page(sg, virt_to_page(buf), buflen, offset_in_page(buf));
}
and virt_addr_valid(x) fails on stack addresses (!). I talked with the
s390 subsystem maintainer and he confirms this. So stack addresses can't
be used for scatterlists even when there is no DMA involved.
Harald Freudenberger