* Re: Regression bisected to "crypto: af_alg: Convert af_alg_sendpage() to use MSG_SPLICE_PAGES"
[not found] ` <1357760.1688460637@warthog.procyon.org.uk>
@ 2023-07-04 9:04 ` Herbert Xu
2023-07-04 9:41 ` David Howells
1 sibling, 0 replies; 3+ messages in thread
From: Herbert Xu @ 2023-07-04 9:04 UTC (permalink / raw)
To: David Howells
Cc: Ondrej Mosnacek, Linux Crypto Mailing List, Paolo Abeni, netdev,
Linux Kernel Mailing List, regressions
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@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: Regression bisected to "crypto: af_alg: Convert af_alg_sendpage() to use MSG_SPLICE_PAGES"
[not found] ` <1357760.1688460637@warthog.procyon.org.uk>
2023-07-04 9:04 ` Regression bisected to "crypto: af_alg: Convert af_alg_sendpage() to use MSG_SPLICE_PAGES" Herbert Xu
@ 2023-07-04 9:41 ` David Howells
2023-07-04 10:10 ` Herbert Xu
1 sibling, 1 reply; 3+ messages in thread
From: David Howells @ 2023-07-04 9:41 UTC (permalink / raw)
To: Herbert Xu
Cc: dhowells, Ondrej Mosnacek, Linux Crypto Mailing List,
Paolo Abeni, netdev, Linux Kernel Mailing List, regressions
Herbert Xu <herbert@gondor.apana.org.au> wrote:
> 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.
Er, no. It can literally remove the page from the process's VM and paste it
somewhere else - though in this case, that shouldn't happen. However, the
buffer passed to SPLICE_F_GIFT should also be page-aligned, which it might not
be because they used calloc().
There's no reason to use SPLICE_F_GIFT here. vmsplice() still attaches the
> There is no reason why this should crash.
Agreed. I'm still looking at it. Interestingly, the output comes out the
same, no matter whether vmsplice(), vmsplice() + SPLICE_F_GIFT or writev(), so
it looks like the buffers get to
> If we can't fix this the patches should be reverted.
I didn't change vmsplice() or the way pages are stored in the pipe.
And, note, there are also a bunch of GUP changes that could have an effect.
David
^ permalink raw reply [flat|nested] 3+ messages in thread