From: Herbert Xu <herbert@gondor.apana.org.au>
To: David Howells <dhowells@redhat.com>
Cc: netdev@vger.kernel.org,
syzbot+13a08c0bf4d212766c3c@syzkaller.appspotmail.com,
syzbot+14234ccf6d0ef629ec1a@syzkaller.appspotmail.com,
syzbot+4e2e47f32607d0f72d43@syzkaller.appspotmail.com,
syzbot+472626bb5e7c59fb768f@syzkaller.appspotmail.com,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Jens Axboe <axboe@kernel.dk>,
Matthew Wilcox <willy@infradead.org>,
linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next] crypto: af_alg/hash: Fix recvmsg() after sendmsg(MSG_MORE)
Date: Tue, 20 Jun 2023 12:47:36 +0800 [thread overview]
Message-ID: <ZJEvaGyiRj509XY8@gondor.apana.org.au> (raw)
In-Reply-To: <1132301.1687193246@warthog.procyon.org.uk>
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@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
prev parent reply other threads:[~2023-06-20 4:48 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-14 23:27 [PATCH net-next] crypto: af_alg/hash: Fix recvmsg() after sendmsg(MSG_MORE) David Howells
2023-06-15 9:28 ` Herbert Xu
2023-06-15 11:28 ` David Howells
2023-06-16 10:27 ` Herbert Xu
2023-06-16 10:37 ` David Howells
2023-06-16 10:43 ` Herbert Xu
2023-06-16 11:11 ` David Howells
2023-06-19 16:47 ` David Howells
2023-06-20 4:47 ` Herbert Xu [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZJEvaGyiRj509XY8@gondor.apana.org.au \
--to=herbert@gondor.apana.org.au \
--cc=axboe@kernel.dk \
--cc=davem@davemloft.net \
--cc=dhowells@redhat.com \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=syzbot+13a08c0bf4d212766c3c@syzkaller.appspotmail.com \
--cc=syzbot+14234ccf6d0ef629ec1a@syzkaller.appspotmail.com \
--cc=syzbot+472626bb5e7c59fb768f@syzkaller.appspotmail.com \
--cc=syzbot+4e2e47f32607d0f72d43@syzkaller.appspotmail.com \
--cc=willy@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox