<feed xmlns='http://www.w3.org/2005/Atom'>
<title>ustream-ssl, branch master</title>
<subtitle>ustream SSL wrapper</subtitle>
<id>https://git.openwrt.org/project/ustream-ssl/atom?h=master</id>
<link rel='self' href='https://git.openwrt.org/project/ustream-ssl/atom?h=master'/>
<link rel='alternate' type='text/html' href='https://git.openwrt.org/project/ustream-ssl/'/>
<updated>2026-03-01T01:19:55Z</updated>
<entry>
<title>ustream-openssl: Fix use-after-free crash under high load and optimize BIO_METHOD lifecycle</title>
<updated>2026-03-01T01:19:55Z</updated>
<author>
<name>Hauke Mehrtens</name>
</author>
<published>2026-02-22T19:14:52Z</published>
<link rel='alternate' type='text/html' href='https://git.openwrt.org/project/ustream-ssl/commit/?id=99f1c0db5a729f615bc5114b3b52fd8ac8083f34'/>
<id>urn:sha1:99f1c0db5a729f615bc5114b3b52fd8ac8083f34</id>
<content type='text'>
This change fixes a crash that occurred when many SSL connections were freed
simultaneously (e.g., under high load in uhttpd). The original code had two
related issues:

**Issue 1: Use-After-Free in Session Cleanup**
The __ustream_ssl_session_free() function was calling BIO_get_data() AFTER
SSL_free() had already destroyed the BIO. This violated OpenSSL's resource
ownership model - once SSL_free() is called, all associated BIOs are freed
and their pointers become invalid.

**Issue 2: Lifecycle Management**
The bio_ctx and BIO_METHOD were being allocated per-connection, but freed
at the wrong time relative to BIO destruction, causing corruption or leaks.

**Solution:**
1. Move BIO context cleanup to the BIO's destroy callback (s_ustream_free)
   where it belongs - cleanup happens as part of BIO destruction, not after

2. Simplify __ustream_ssl_session_free() to only call SSL_shutdown() and
   SSL_free(), delegating all BIO cleanup to OpenSSL

3. Optimize BIO_METHOD lifecycle: create it once as a static reusable
   callback table instead of allocating a new one per connection. The
   BIO_METHOD is just read-only configuration, not stateful data.

4. Each connection still gets its own isolated bio_ctx with its own stream
   pointer, so there's no data sharing between connections.

This follows OpenSSL's documented patterns for custom BIO implementation and
eliminates memory safety issues under concurrent load.

Fixes crash under high load with backtrace:
  0x0000ffff81296d08 in BIO_get_data () from libcrypto.so.3
  __ustream_ssl_session_free () at ustream-openssl.c
  ustream_ssl_free () at ustream-ssl.c
  ustream_free () at libubox/ustream.c

This bug was fixed with help of AI after providing the stacktrace.

Fixes: https://github.com/openwrt/openwrt/issues/19349
Fixes: https://github.com/openwrt/openwrt/issues/20134
Fixes: 5896991e46a3 ("ustream-openssl: fix BIO_method memory leak")
Link: https://github.com/openwrt/ustream-ssl/pull/4
Signed-off-by: Hauke Mehrtens &lt;hauke@hauke-m.de&gt;
</content>
</entry>
<entry>
<title>CMakeLists: update cmake minimum required version to 3.10</title>
<updated>2025-10-03T21:40:50Z</updated>
<author>
<name>Christian Marangi</name>
</author>
<published>2025-10-03T21:40:50Z</published>
<link rel='alternate' type='text/html' href='https://git.openwrt.org/project/ustream-ssl/commit/?id=5a81c108d20e24724ed847cc4be033f2a74e6635'/>
<id>urn:sha1:5a81c108d20e24724ed847cc4be033f2a74e6635</id>
<content type='text'>
New cmake version 4.0 requires at least 3.5 version as the minimum
required version with it increased to 3.10 in to-be-released cmake
versions.

Set the minimum required version to 3.10 to future-proof for future
cmake version.

Suggested-by: Hannu Nyman &lt;hannu.nyman@iki.fi&gt;
Signed-off-by: Christian Marangi &lt;ansuelsmth@gmail.com&gt;
</content>
</entry>
<entry>
<title>ustream-openssl: fix compilation with OPENSSL_NO_DEPRECATED</title>
<updated>2024-07-28T08:06:21Z</updated>
<author>
<name>Andre Heider</name>
</author>
<published>2023-02-21T11:44:16Z</published>
<link rel='alternate' type='text/html' href='https://git.openwrt.org/project/ustream-ssl/commit/?id=99bd3d2b167ccdffb6de072d02c380cb37b23e33'/>
<id>urn:sha1:99bd3d2b167ccdffb6de072d02c380cb37b23e33</id>
<content type='text'>
SSL_get_peer_certificate() is deprecated, OpenSSL v3.0 added
SSL_get0_peer_certificate() and SSL_get1_peer_certificate().

Use the latter since the return value is explicitely X509_free()ed
here, see [0].

WolfSSL doesn't implement the new variants.

[0] https://www.openssl.org/docs/manmaster/man3/SSL_get_peer_certificate.html

Signed-off-by: Andre Heider &lt;a.heider@gmail.com&gt;
</content>
</entry>
<entry>
<title>ustream-ssl: add support for using a fd instead of ustream as backing</title>
<updated>2024-04-19T14:47:10Z</updated>
<author>
<name>Felix Fietkau</name>
</author>
<published>2024-04-19T14:43:35Z</published>
<link rel='alternate' type='text/html' href='https://git.openwrt.org/project/ustream-ssl/commit/?id=524a76e5af78fa577c46e0d24bdedd4254e07cd4'/>
<id>urn:sha1:524a76e5af78fa577c46e0d24bdedd4254e07cd4</id>
<content type='text'>
This improves performance by avoiding double buffering

Signed-off-by: Felix Fietkau &lt;nbd@nbd.name&gt;
</content>
</entry>
<entry>
<title>ustream-ssl: increase number of read buffers</title>
<updated>2024-04-18T12:55:20Z</updated>
<author>
<name>Felix Fietkau</name>
</author>
<published>2024-04-18T12:55:19Z</published>
<link rel='alternate' type='text/html' href='https://git.openwrt.org/project/ustream-ssl/commit/?id=3c49e70c462249c174062e8181d191c859c5e41b'/>
<id>urn:sha1:3c49e70c462249c174062e8181d191c859c5e41b</id>
<content type='text'>
Fix dealing with larger TLS transactions

Signed-off-by: Felix Fietkau &lt;nbd@nbd.name&gt;
</content>
</entry>
<entry>
<title>ustream-ssl: poll connection on incomplete reads</title>
<updated>2024-04-18T12:54:42Z</updated>
<author>
<name>Felix Fietkau</name>
</author>
<published>2024-04-18T12:54:28Z</published>
<link rel='alternate' type='text/html' href='https://git.openwrt.org/project/ustream-ssl/commit/?id=f9a28a9ce86473d934693fe59dcbe344ffbc695e'/>
<id>urn:sha1:f9a28a9ce86473d934693fe59dcbe344ffbc695e</id>
<content type='text'>
Reduces uloop roundtrips

Signed-off-by: Felix Fietkau &lt;nbd@nbd.name&gt;
</content>
</entry>
<entry>
<title>mbedtls: another cosmetic ifdef fix</title>
<updated>2024-04-18T11:17:34Z</updated>
<author>
<name>Felix Fietkau</name>
</author>
<published>2024-04-18T11:17:34Z</published>
<link rel='alternate' type='text/html' href='https://git.openwrt.org/project/ustream-ssl/commit/?id=af7c3532ad499bc97f568087a57ac0f4fe6f56e1'/>
<id>urn:sha1:af7c3532ad499bc97f568087a57ac0f4fe6f56e1</id>
<content type='text'>
Signed-off-by: Felix Fietkau &lt;nbd@nbd.name&gt;
</content>
</entry>
<entry>
<title>mbedtls: add ifdefs to fix legacy compatibility</title>
<updated>2024-04-18T11:16:45Z</updated>
<author>
<name>Felix Fietkau</name>
</author>
<published>2024-04-18T11:16:45Z</published>
<link rel='alternate' type='text/html' href='https://git.openwrt.org/project/ustream-ssl/commit/?id=ac42af7981ae0a49e745a4b0b2b0961070550ac3'/>
<id>urn:sha1:ac42af7981ae0a49e745a4b0b2b0961070550ac3</id>
<content type='text'>
Signed-off-by: Felix Fietkau &lt;nbd@nbd.name&gt;
</content>
</entry>
<entry>
<title>mbedtls: handle session tickets for TLS 1.3</title>
<updated>2024-04-18T11:10:54Z</updated>
<author>
<name>Felix Fietkau</name>
</author>
<published>2024-04-18T10:42:01Z</published>
<link rel='alternate' type='text/html' href='https://git.openwrt.org/project/ustream-ssl/commit/?id=60d8fbb5e669db4b85f0ccd9b86744a8355eb2d9'/>
<id>urn:sha1:60d8fbb5e669db4b85f0ccd9b86744a8355eb2d9</id>
<content type='text'>
Store them inside the context in order to handle reconnect

Signed-off-by: Felix Fietkau &lt;nbd@nbd.name&gt;
</content>
</entry>
<entry>
<title>mbedtls: add missing ifdef for build with disabled debug</title>
<updated>2024-04-07T16:54:04Z</updated>
<author>
<name>Felix Fietkau</name>
</author>
<published>2024-04-07T16:54:04Z</published>
<link rel='alternate' type='text/html' href='https://git.openwrt.org/project/ustream-ssl/commit/?id=d61493a4420417cbf9931ffee8c862faf04f2967'/>
<id>urn:sha1:d61493a4420417cbf9931ffee8c862faf04f2967</id>
<content type='text'>
Signed-off-by: Felix Fietkau &lt;nbd@nbd.name&gt;
</content>
</entry>
</feed>
