net/mbedtls_net_connect: Preventing double close problem#9711
net/mbedtls_net_connect: Preventing double close problem#9711davidhorstmann-arm merged 2 commits intoMbed-TLS:developmentfrom
Conversation
There was a problem hiding this comment.
Change looks good to me, thanks!
Would you be able to add a ChangeLog entry and raise backport PRs against the mbedtls-3.6 and mbedtls-2.28 branches?
For ChangeLog guidance, see the ChangeLog readme. This would count in the Bugfix category.
e549a49 to
eb77422
Compare
Thanks for your reply! Changelog has been added, and backport PRs has been submitted with #9714 and #9715. Thanks again. |
eb77422 to
2fdbe0a
Compare
In the test examples and real usage scenarios, 'mbedtls_net_free' is called after 'mbedtls_net_connect' fails, which will cause the problem of double close the same fd. It is possible to close this closed fd which has been applied by other link. Signed-off-by: makejian <makejian@xiaomi.com>
2fdbe0a to
9606d56
Compare
davidhorstmann-arm
left a comment
There was a problem hiding this comment.
LGTM, thanks!
davidhorstmann-arm
left a comment
There was a problem hiding this comment.
The CI is failing on the other PRs as the ChangeLog needs a newline at the end. Otherwise looks good to me.
Signed-off-by: David Horstmann <david.horstmann@arm.com>
davidhorstmann-arm
left a comment
There was a problem hiding this comment.
LGTM, approving even though this technically includes my own change as the change is a line-ending only.
Thanks, i will fix that in backport PRs. |
In the test examples and real usage scenarios, 'mbedtls_net_free' is called after 'mbedtls_net_connect' fails, which will cause the problem of double close the same fd. It is possible to close this closed fd which has been applied by other link.
Description
hi all. We found that in the scenario of sudden network disconnection, ‘mbedtls_net_connect’ will close fd after the connection fails, and then call ‘mbedtls_net_free’ to close it again. There is a risk of double close here. At first, we suspected that it was used incorrectly, but after referring to the implementation and case in the programs directory, we did not find that it was a usage error. Therefore, we suggest to mark fd as unavailable after closing it to prevent fd from being used by other programs during the interval between 'mbedtls_net_connect' and 'mbedtls_net_free'.
PR checklist
Please remove the segment/s on either side of the | symbol as appropriate, and add any relevant link/s to the end of the line.
If the provided content is part of the present PR remove the # symbol.
Resolves #9710
Notes for the submitter
Please refer to the contributing guidelines, especially the
checklist for PR contributors.
Help make review efficient: