Skip to content

test server: take care of siginterrupt() deprecation - #6529

Closed
monnerat wants to merge 1 commit into
curl:masterfrom
monnerat:deprecations
Closed

monnerat wants to merge 1 commit into
curl:masterfrom
monnerat:deprecations

Conversation

@monnerat

Copy link
Copy Markdown
Contributor

openssl >= 1.1.0 deprecates *_client_method() functions other than TLS_client_method(). Take care of it with conditionals.

Test server uses deprecated siginterrupt() after signal(). Depending on availability, merge both using sigaction().

@jay

jay commented Jan 26, 2021

Copy link
Copy Markdown
Member

I'd split this into 2 commits Ah, I see you did that already...

@bagder

bagder commented Jan 27, 2021

Copy link
Copy Markdown
Member

Those FreeBSD test failures look like they're not just regular flakiness...

@monnerat

monnerat commented Jan 27, 2021

Copy link
Copy Markdown
Contributor Author

Those FreeBSD test failures look like they're not just regular flakiness...

Yes, I agree and have looked at them carefully. However I don't see how they can be related to this PR: the failing tests deal with direct ftps and we have a proxy input and an http2 server logs. Unless I misunderstand something, it's like the test environment sets the target port for client where the wrong server listens.

The failing tests are all tests using ftps server and performing a data transfer.

In any case, I will change a commit a little bit, so consider this PR on hold. Thanks.

@monnerat
monnerat force-pushed the deprecations branch 2 times, most recently from 6f7272d to 7b4833d Compare January 28, 2021 02:45
Comment thread lib/vtls/openssl.c Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure about this? I don't see it documented that way, I checked https://www.openssl.org/docs/man1.0.2/man3/SSL_CTX_clear_options.html

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, it seems like an unrelated change. It is not here to "suppress deprecation warnings" surely?

What's the reason for adding this function call? Everything that changes the setup of OpenSSL creates a risk and we need to be careful.

@monnerat monnerat Jan 28, 2021

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure about this?

@jay : On the page you linked:

SSL_CTX_set_options() adds the options set via bitmask in options to ctx. Options already set before are not cleared!

and

SSL_OP_NO_SSLv2
Do not use the SSLv2 protocol. As of OpenSSL 1.0.2g the SSL_OP_NO_SSLv2 option is set by default.

@bagder :

Also, it seems like an unrelated change. It is not here to "suppress deprecation warnings" surely?

It is related because when conditionals enable TLS_client_method(), there's a risk that the target protocol version is disabled by default. The documentation does not specify if setting the min/max version in the context overrides the options or not.

OpenSSL changed the handling of protocol selection many times in the several last versions: they deprecated *_client_method(), set SSL_OP_NO_SSLv2 by default, then defined the later as 0. I think clearing the protocol options that are under our control is the simplest way of dealing with the problem for all versions up to now.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BTW: there's nothing in our test environment that allows to verify the proper TLS protocol and cipher selection. I checked the code to see if this can be implemented easily: this answer is no :-( Server side uses stunnel and no backend-independent API allows it on the client side.

@monnerat

monnerat commented Jan 28, 2021

Copy link
Copy Markdown
Contributor Author

The freebsd test failures have disappeared miraculously.
Current Travis CI job has not yet started. Stuck?
Else I do not plan any other modification to this PR, therefore I release the "hold".

@monnerat
monnerat force-pushed the deprecations branch 2 times, most recently from 7aa5e13 to 2f8a947 Compare February 5, 2021 00:08
@monnerat
monnerat force-pushed the deprecations branch 2 times, most recently from 01edbce to d8120c5 Compare February 16, 2021 10:38
@monnerat

Copy link
Copy Markdown
Contributor Author

Drpped openssl commit as target code has disappeared.

@bagder bagder changed the title Resolve deprecations test server: take care of siginterrupt() deprecation Apr 22, 2021
@bagder

bagder commented Apr 22, 2021

Copy link
Copy Markdown
Member

thanks!

@bagder bagder closed this in 3fb6e5a Apr 22, 2021
@monnerat
monnerat deleted the deprecations branch April 22, 2021 07:24
vszakats added a commit that referenced this pull request Aug 4, 2026
…rn codepath

Historically servers used the deprecated `siginterrupt()` function to
configure restart behavior on specific signals. It accepts a flag, where
1 means to remove the `SA_RESTART` option, and 0 means to enable it.

In year 2021 3fb6e5a introduced the
modern alternative to the codebase, replacing `siginterrupt()` with
`sigaction()`. After this patch, supporting, modern, systems reacted on
the same flag, but, by accident, set the `SA_RESTART` bit when flag is
1, and did not set it when 0. This reversed the previous behavior, and
the one still used on the `siginterrupt()` legacy codepath.

Fix it by revesring the `SA_RESTART` logic for the `sigaction()`
codepath, syncing it with the pre-existing behavior.

I find it odd this did not cause any perceivable issue for 5 years, even
though it's the active one in most Unix envs.

Spotted by GitHub Code Quality, though suggesting to fix
`siginterrupt()` calls. But looking into the history, those were correct
all along.

Refs:
https://pubs.opengroup.org/onlinepubs/9699919799/functions/siginterrupt.html
https://pubs.opengroup.org/onlinepubs/9699919799/functions/sigaction.html
https://www.man7.org/linux/man-pages/man3/siginterrupt.3.html
https://www.man7.org/linux/man-pages/man2/sigaction.2.html

Follow-up to 3fb6e5a #6529

Closes #22037
vszakats added a commit that referenced this pull request Aug 5, 2026
Before this patch modern systems used `sigaction()` and `SA_RESTART` to
install signal handlers, but the signal handler function itself still
made a call to the legacy `signal()` function to re-register itself
before returning.

Re-registering the handler is not necessary with `sigaction()`. It's
also undesired to use the legacy API when the modern one is available.

Fix by guarding off this call in builds that support the modern API.

Follow-up to 3fb6e5a #6529
Follow-up to 18cbb4d

Closes #22497
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

3 participants