Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

s_server: Do not use SSL_sendfile when KTLS is not being used #17788

Closed
wants to merge 3 commits into from

Conversation

hlandau
Copy link
Member

@hlandau hlandau commented Mar 1, 2022

Fix a bug in openssl s_server -WWW where it would attempt to invoke SSL_sendfile if -ktls -sendfile was passed on the command line, even if KTLS has not actually been enabled, for example because it is not supported by the host. Since SSL_sendfile is only supported when KTLS is actually being used, this resulted in a failure to serve requests.

Fixes #17503.

Taking advice on how to test this, as most usage of s_server in the test suite seems to be incidental via TLSProxy rather than testing of s_server itself.

Fix a bug in `openssl s_server -WWW` where it would attempt to invoke
`SSL_sendfile` if `-ktls -sendfile` was passed on the command line, even
if KTLS has not actually been enabled, for example because it is not
supported by the host. Since `SSL_sendfile` is only supported when KTLS
is actually being used, this resulted in a failure to serve requests.

Fixes openssl#17503.
@hlandau hlandau added branch: master Merge to master branch approval: review pending This pull request needs review by a committer approval: otc review pending This pull request needs review by an OTC member triaged: bug The issue/pr is/fixes a bug labels Mar 1, 2022
@hlandau hlandau requested review from t8m and mattcaswell March 1, 2022 16:51
Copy link
Member

@mattcaswell mattcaswell left a comment

Choose a reason for hiding this comment

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

Taking advice on how to test this, as most usage of s_server in the test suite seems to be incidental via TLSProxy rather than testing of s_server itself.

Yeah. We've actually been quite poor about testing for the apps. The TLSProxy tests are really about testing the library and only incidentally use s_server (and in fact I would like to rewrite them at some point to not have that dependency). We recently agreed to a new testing policy (https://github.com/openssl/technical-policies/blob/master/policies/testing.md) which mandates that we should add tests when fixing bugs in the applications - so we really do need to figure out a test for this.

We are probably going to need a new test recipe that basically starts "s_server" using sendfile and confirms that "s_client" can connect to it. This seems quite hard...but a nettle we are going to need to grasp sometime soon.

There is a "get out clause" in the test policy which says we don't have to write tests "where writing the test would result in disproportionately more effort than writing the code being tested"

apps/s_server.c Outdated Show resolved Hide resolved
@hlandau
Copy link
Member Author

hlandau commented Mar 2, 2022

The testing issue relates to #17267.

@hlandau
Copy link
Member Author

hlandau commented Mar 2, 2022

Updated to add a warning when sendfile was requested but a request was served without it.

@t8m
Copy link
Member

t8m commented Mar 2, 2022

There is a "get out clause" in the test policy which says we don't have to write tests "where writing the test would result in disproportionately more effort than writing the code being tested"

IMO this is well within this clause. Writing a completely new test recipe that would not be trivial for this few line fix would be disproportionately more effort. However! We should at least create an issue to add tests for s_server/s_client apps.

apps/s_server.c Show resolved Hide resolved
apps/s_server.c Outdated Show resolved Hide resolved
@hlandau
Copy link
Member Author

hlandau commented Mar 2, 2022

Updated.

@t8m t8m removed the approval: otc review pending This pull request needs review by an OTC member label Mar 2, 2022
@mattcaswell mattcaswell added the branch: 3.0 Merge to openssl-3.0 branch label Mar 2, 2022
Copy link
Member

@mattcaswell mattcaswell left a comment

Choose a reason for hiding this comment

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

@t8m - I added the 3.0 branch tag for this since this is a bug fix. Do you agree with the backport?

@mattcaswell mattcaswell added approval: done This pull request has the required number of approvals and removed approval: review pending This pull request needs review by a committer labels Mar 2, 2022
@t8m
Copy link
Member

t8m commented Mar 2, 2022

Yes, OK for 3.0 as well.

@openssl-machine
Copy link
Collaborator

24 hours has passed since 'approval: done' was set, but as this PR has been updated in that time the label 'approval: ready to merge' is not being automatically set. Please review the updates and set the label manually.

@mattcaswell mattcaswell added approval: ready to merge The 24 hour grace period has passed, ready to merge and removed approval: done This pull request has the required number of approvals labels Mar 3, 2022
@hlandau hlandau self-assigned this Mar 3, 2022
@mattcaswell
Copy link
Member

Pushed to master and 3.0

@mattcaswell mattcaswell closed this Mar 3, 2022
openssl-machine pushed a commit that referenced this pull request Mar 3, 2022
Fix a bug in `openssl s_server -WWW` where it would attempt to invoke
`SSL_sendfile` if `-ktls -sendfile` was passed on the command line, even
if KTLS has not actually been enabled, for example because it is not
supported by the host. Since `SSL_sendfile` is only supported when KTLS
is actually being used, this resulted in a failure to serve requests.

Fixes #17503.

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from #17788)

(cherry picked from commit aea68b0)
openssl-machine pushed a commit that referenced this pull request Mar 3, 2022
Fix a bug in `openssl s_server -WWW` where it would attempt to invoke
`SSL_sendfile` if `-ktls -sendfile` was passed on the command line, even
if KTLS has not actually been enabled, for example because it is not
supported by the host. Since `SSL_sendfile` is only supported when KTLS
is actually being used, this resulted in a failure to serve requests.

Fixes #17503.

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from #17788)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approval: ready to merge The 24 hour grace period has passed, ready to merge branch: master Merge to master branch branch: 3.0 Merge to openssl-3.0 branch triaged: bug The issue/pr is/fixes a bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Disable -sendfile if ktls is not being used in runtime
4 participants