Arch Linux

Please read this before reporting a bug:
https://wiki.archlinux.org/title/Bug_reporting_guidelines

Do NOT report bugs when a package is just outdated, or it is in the AUR. Use the 'flag out of date' link on the package page, or the Mailing List.

REPEAT: Do NOT report bugs for outdated packages!
Tasklist

FS#78879 - opensmtpd crashes when establishing ssl connection

Attached to Project: Arch Linux
Opened by grmat (grmat) - Saturday, 24 June 2023, 12:44 GMT
Last edited by T.J. Townsend (blakkheim) - Saturday, 24 June 2023, 20:36 GMT
Task Type Bug Report
Category Packages: Extra
Status Closed
Assigned To T.J. Townsend (blakkheim)
Architecture x86_64
Severity Medium
Priority High
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

Description:

After updating to opensmtpd 7.3.0p0-1, smtpd keeps crashing when trying to connect to via TLS. For both, incoming and outgoing mail.


Steps to reproduce:
- install smtpd, libressl
- run server with sample conf, containing:

# SMTPS (465)
listen on x.x.x.x smtps pki [domain]
# SMTP+STARTTLS (25)
listen on x.x.x.x tls-require pki [domain]
# submission (587)
listen on x.x.x.x port submission tls-require pki [domain] auth filter rspamd


- try to receive or send mails
- try establishing only a ssl connection with openssl:
`openssl s_client -quiet -starttls smtp -crlf -connect [domain]:25`



For me, it doesn't crash, when building against openssl instead of libressl (in PKGBUILD:)

- --with-cflags='-I/usr/include/libressl -L/usr/lib/libressl -Wl,-rpath=/usr/lib/libressl'
+ --with-cflags='-I/usr/include/libssl -L/usr/lib/libssl -Wl,-rpath=/usr/lib/libssl'


Sorry, I have no stack trace.

Why is it built against libressl in the first place?
This task depends upon

Closed by  T.J. Townsend (blakkheim)
Saturday, 24 June 2023, 20:36 GMT
Reason for closing:  Fixed
Comment by Lukas Fleischer (lfleischer) - Saturday, 24 June 2023, 16:14 GMT
I can reproduce the crash.

LibreSSL seems to be recommended as per https://github.com/OpenSMTPD/OpenSMTPD/releases/tag/7.3.0p0.

The release notes also state that "LibreTLS 3.7.0 has a known regression with OpenSSL 3+, so please use the bundled one using the --with-bundled-libtls configure flag until it is updated." Should that flag be added?
Comment by T.J. Townsend (blakkheim) - Saturday, 24 June 2023, 16:17 GMT
> Why is it built against libressl in the first place?

OpenSMTPD is developed by OpenBSD, which is where LibreSSL comes from. The release notes say the following:

"This release builds with LibreSSL, or OpenSSL > 1.1.1 optionally with
LibreTLS.

LibreTLS 3.7.0 has a known regression with OpenSSL 3+, so please use
the bundled one using the --with-bundled-libtls configure flag until
it is updated.

It's preferable to depend on LibreSSL as OpenSMTPD is written and tested
with that dependency. OpenSSL library is considered as a best effort
target TLS library and provided as a commodity, LibreSSL has become our
target TLS library."

I'll be glad to try temporarily building with OpenSSL and the bundled libtls for a short-term fix. Could you please report this upstream with a stack trace?
Comment by Lukas Fleischer (lfleischer) - Saturday, 24 June 2023, 16:25 GMT
T.J., has 7.3.0p0-1 been built with --with-bundled-libtls as recommended in the notes you quoted?
Comment by T.J. Townsend (blakkheim) - Saturday, 24 June 2023, 16:33 GMT
It's my understanding that there are two choices for building OpenSMTPD:

- OpenSSL + LibreTLS
- LibreSSL

The release notes lead me to believe that "--with-bundled-libtls" is only for building with OpenSSL (which we're not doing currently) and is only a temporary workaround for a bug in LibreTLS. Despite the name, LibreTLS not related to LibreSSL.

To work around the apparent LibreSSL bug described in this report, we could switch to a combination of OpenSSL + LibreTLS as in the diff attached. If OP is fine with that and can report the actual bug upstream, that's what I'd like to do for the moment.
Comment by Lukas Fleischer (lfleischer) - Saturday, 24 June 2023, 16:34 GMT
Got it, thanks for the explanation -- I missed the subtle (but important) difference between LibreSSL and LibreTLS.

+1 to the approach you proposed. Thank you!
Comment by T.J. Townsend (blakkheim) - Saturday, 24 June 2023, 16:54 GMT
It's in extra-testing now. grmat please give it a try if you would.
Comment by grmat (grmat) - Saturday, 24 June 2023, 20:33 GMT
Thanks for the quick response.

> OpenSSL library is considered as a best effort target TLS library and provided as a commodity

That's the reason why I thought might be fair to ship along with libssl. But I'm not into that, so forget about it.



> It's in extra-testing now. grmat please give it a try if you would.

LGTM.
Comment by T.J. Townsend (blakkheim) - Saturday, 24 June 2023, 20:36 GMT
Moving to the main repos now. A more detailed bug report upstream would be much appreciated.

Loading...