Thread (25 messages) 25 messages, 4 authors, 2023-09-14

Re: [PATCH net 5/5] tls: don't decrypt the next record if it's of a different type

flat view

From: Herbert Xu <herbert@gondor.apana.org.au>
Date: 2023-09-12 04:38:46

On Fri, Sep 08, 2023 at 05:38:49PM +0200, Sabrina Dubroca wrote:
tls_decrypt_done only runs the completion when decrypt_pending drops
to 0, so this should be covered.
That doesn't look very safe.  What if the first decrypt completes
before the second decrypt even starts? Wouldn't that cause two
complete calls on ctx->async_wait?
I wonder if this situation could happen:

tls_sw_recvmsg
  process first record
    decrypt_pending = 1
                                  CB runs
                                  decrypt_pending = 0
                                  complete(&ctx->async_wait.completion);

  process second record
    decrypt_pending = 1
  tls_sw_recvmsg reaches "recv_end"
    decrypt_pending != 0
    crypto_wait_req sees the first completion of ctx->async_wait and proceeds

                                  CB runs
                                  decrypt_pending = 0
                                  complete(&ctx->async_wait.completion);
Yes that's exactly what I was thinking of.

I think this whole thing needs some rethinking and rewriting.

Thanks,
-- 
Email: Herbert Xu [off-list ref]
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help