From: David Howells <dhowells@redhat.com>
To: Herbert Xu <herbert@gondor.apana.org.au>
Cc: dhowells@redhat.com, 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: Mon, 19 Jun 2023 17:47:26 +0100 [thread overview]
Message-ID: <1132301.1687193246@warthog.procyon.org.uk> (raw)
In-Reply-To: <ZIw8y2w+A+t5u+IJ@gondor.apana.org.au>
Herbert Xu <herbert@gondor.apana.org.au> wrote:
> Anyway, why did you remove the condition on hash_free_result?
> We free the result if it's not needed, not to clear the previous
> hash. So by doing it uncondtionally you will simply end up
> freeing and reallocating the result for no good reason.
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
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.
However, as, with my patch hash_sendmsg() no longer calculated a result, it
has to clear the result pointer because the logic inside hash_recvmsg() relies
on the result pointer to indicate that there is a result.
Instead, hash_recvmsg() concocts the result - something it has to be able to
do anyway in case someone calls recvmsg() without first supplying data.
David
next prev parent reply other threads:[~2023-06-19 16: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 [this message]
2023-06-20 4:47 ` Herbert Xu
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=1132301.1687193246@warthog.procyon.org.uk \
--to=dhowells@redhat.com \
--cc=axboe@kernel.dk \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=herbert@gondor.apana.org.au \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.