Re: Regression bisected to "crypto: af_alg: Convert af_alg_sendpage() to use MSG_SPLICE_PAGES"

From: Herbert Xu
Date: Tue Jul 04 2023 - 05:04:40 EST


On Tue, Jul 04, 2023 at 09:50:37AM +0100, David Howells wrote:
> One problem with libkcapi is that it's abusing vmsplice(). It must not use
> vmsplice(SPLICE_F_GIFT) on a buffer that's in the heap. To quote the manual
> page:
>
> The user pages are a gift to the kernel. The application may
> not modify this memory ever, otherwise the page cache and on-
> disk data may differ. Gifting pages to the kernel means that a
> subsequent splice(2) SPLICE_F_MOVE can successfully move the
> pages; if this flag is not specified, then a subsequent
> splice(2) SPLICE_F_MOVE must copy the pages. Data must also be
> properly page aligned, both in memory and length.
>
> Basically, this can destroy the integrity of the process's heap as the
> allocator may have metadata there that then gets excised.

All it's saying is that if you modify the data after sending it off
via splice then the data that will be on the wire is undefined.

There is no reason why this should crash.

> If I remove the flag, it still crashes, so that's not the only problem.

If we can't fix this the patches should be reverted.

Thanks,
--
Email: Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt