[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <ZJEvaGyiRj509XY8@gondor.apana.org.au>
Date: Tue, 20 Jun 2023 12:47:36 +0800
From: Herbert Xu <herbert@...dor.apana.org.au>
To: David Howells <dhowells@...hat.com>
Cc: netdev@...r.kernel.org,
syzbot+13a08c0bf4d212766c3c@...kaller.appspotmail.com,
syzbot+14234ccf6d0ef629ec1a@...kaller.appspotmail.com,
syzbot+4e2e47f32607d0f72d43@...kaller.appspotmail.com,
syzbot+472626bb5e7c59fb768f@...kaller.appspotmail.com,
"David S. Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>,
Paolo Abeni <pabeni@...hat.com>, Jens Axboe <axboe@...nel.dk>,
Matthew Wilcox <willy@...radead.org>,
linux-crypto@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH net-next] crypto: af_alg/hash: Fix recvmsg() after
sendmsg(MSG_MORE)
On Mon, Jun 19, 2023 at 05:47:26PM +0100, David Howells wrote:
>
> The free here:
>
> if (!continuing) {
> if ((msg->msg_flags & MSG_MORE))
> hash_free_result(sk, ctx);
>
> only happens in the following case:
>
> send(hashfd, "", 0, 0);
> send(hashfd, "", 0, MSG_MORE); <--- by this
Yes and that's what I'm complaining about.
> and the patch changes how this case works if no data is given. In Linus's
> tree, it will create a result, init the crypto and finalise it in
> hash_sendmsg(); with this patch that case is then handled by hash_recvmsg().
> If you consider the following sequence:
>
> send(hashfd, "", 0, 0);
> send(hashfd, "", 0, 0);
> send(hashfd, "", 0, 0);
> send(hashfd, "", 0, 0);
>
> Upstream, the first one will create a result and then each of them will init
> and finalise a hash, whereas with my patch, the first one will release any
> outstanding result and then none of them will do any crypto ops.
This is correct. If MSG_MORE is not set, then the hash will be
finalised. In which case if there is already a result allocated
then we should reuse it and not free it.
If MSG_MORE is set, then we can delay the allocation of the result,
in which case it makes sense to free any previous results since
the next request may not come for a very long time (or perhaps even
never).
Cheers,
--
Email: Herbert Xu <herbert@...dor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
Powered by blists - more mailing lists