<div dir="ltr">When KTLS is enabled, multiple client's handshake will lead to unexpected eof while reading and data corrupt(possible memory leak).<br><br>Tested OpenSSL version: master, 3.0.0-alpha1<br>Kernel version: 5.4.43-1-MANJARO<br>Reproduce step(using docker):<br><br><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px">sudo modprobe tls<br>git clone <a href="https://github.com/openssl/openssl.git" target="_blank">https://github.com/openssl/openssl.git</a><br>sudo docker run -it -v $(pwd)/openssl:/openssl archlinux<br><br># [In docker]<br>pacman -Sy make gcc vim<br>cd openssl<br>./config enable-ktls<br>make build_sw -j4<br>pacman -Rdd openssl<br>make install_sw<br><br>cd /<br>vim server.cpp<br># <a href="https://paste.ubuntu.com/p/fyhr6dDR7G/" target="_blank">https://paste.ubuntu.com/p/fyhr6dDR7G/</a><br>vim client.cpp<br># <a href="https://paste.ubuntu.com/p/P2DjwWhTkf/" target="_blank">https://paste.ubuntu.com/p/P2DjwWhTkf/</a><br>vim server.pem<br># <a href="https://paste.ubuntu.com/p/QttnVGsVSm/" target="_blank">https://paste.ubuntu.com/p/QttnVGsVSm/</a><br>vim serverkey.pem<br># <a href="https://paste.ubuntu.com/p/g6QR84wSfw/" target="_blank">https://paste.ubuntu.com/p/g6QR84wSfw/</a><br><br>g++ -c -o client.o client.cpp<br>g++ -o client client.o -lssl -lcrypto<br>g++ -c -o server.o server.cpp<br>g++ -o server server.o -lssl -lcrypto<br>export LD_LIBRARY_PATH=/usr/local/lib<br>./server &<br>./client</blockquote><br>You will see like this<div><br><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px">FP<br> Vtest test<br>test<br>test<br>Mljtest test<br>test<br>test<br>test<br>test<br>test<br>test<br>Error creating SSL connection.  err=ffffffff<br>error:14000126:SSL routines::unexpected eof while reading<br><br></blockquote><div>When OpenSSL is compiled without ktls, the client will print test infinitely, but when enable ktls, some data are corrupted and sometimes result in unexpected eof while reading.<br><br>Even when you remove SSL_write(ssl, reply, strlen(reply)); in server and RecvPacket(); in client, it will also result in unexpected eof while reading so I think there is something wrong with handshake procedure when ktls is enabled, maybe memory leak or UAF.</div></div></div>