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

Prevent accessing of global c++ objects once they are deleted #742

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

Emantor
Copy link

@Emantor Emantor commented Mar 13, 2024

Fixes (Maybe) #729.
Reset objects_deleted after reset is called.

jwsbck added a commit to jwsbck/meta-trustx that referenced this pull request Aug 8, 2024
Softhsm2 seems to be rarely maintained these days and has a bug that
leads to segfaults when running through Openssl library destructors. Add
the Patch from [1] until this is fixed upstream.

[1] softhsm/SoftHSMv2#742

Signed-off-by: Johannes Wiesboeck <johannes.wiesboeck@aisec.fraunhofer.de>
quitschbo pushed a commit to gyroidos/meta-gyroidos that referenced this pull request Aug 8, 2024
Softhsm2 seems to be rarely maintained these days and has a bug that
leads to segfaults when running through Openssl library destructors. Add
the Patch from [1] until this is fixed upstream.

[1] softhsm/SoftHSMv2#742

Signed-off-by: Johannes Wiesboeck <johannes.wiesboeck@aisec.fraunhofer.de>
jwsbck added a commit to jwsbck/meta-trustx that referenced this pull request Aug 8, 2024
Softhsm2 seems to be rarely maintained these days and has a bug that
leads to segfaults when running through Openssl library destructors. Add
the Patch from [1] until this is fixed upstream.

[1] softhsm/SoftHSMv2#742

Signed-off-by: Johannes Wiesboeck <johannes.wiesboeck@aisec.fraunhofer.de>
jwsbck added a commit to jwsbck/meta-trustx that referenced this pull request Aug 8, 2024
Softhsm2 seems to be rarely maintained these days and has a bug that
leads to segfaults when running through Openssl library destructors. Set
the SRC_URI to the current development version as the last "release" is
from 2020. Add the Patch from [1] until this is fixed upstream.

[1] softhsm/SoftHSMv2#742

Signed-off-by: Johannes Wiesboeck <johannes.wiesboeck@aisec.fraunhofer.de>
@kraj
Copy link

kraj commented Sep 27, 2024

hmm reading through #729 it seems to be a fix for openSSL's behavior where its using atexit, I wonder if openSSL exit sequence should not call atexit and let the system cleanup happen via system runtime. atexit seems to be tied to implementation and for c++ it may run concurrently alongside destructors [1], in C it maybe called concurrently with other functions too.

[1] https://en.cppreference.com/w/cpp/utility/program/atexit

@jschlyter jschlyter marked this pull request as draft November 29, 2024 16:27
@jschlyter
Copy link
Contributor

Please rebase on develop and mark as ready when ready.

@Emantor Emantor marked this pull request as ready for review January 10, 2025 17:38
@Emantor Emantor requested a review from a team as a code owner January 10, 2025 17:38
@MorningLightMountain713

I look forward to this getting merged. Here is a before and after of this patch applied:

Screenshot 2025-01-14 at 1 13 12 PM

@jschlyter jschlyter requested a review from bjosv January 14, 2025 15:29
Fixes (Maybe) softhsm#729.
Reset objects_deleted after reset is called.
Copy link
Contributor

@bjosv bjosv left a comment

Choose a reason for hiding this comment

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

Not sure if there is a better way but I guess this work unless we look into some refactoring.
Maybe add a comment with the reason for using a objects_deleted.

@petrovr
Copy link

petrovr commented Feb 8, 2025

One flag isInitialised, another flags objects_deleted , tomorrow yet another flag... :( .
And all those changes because third party software "cache sessions".

@petrovr
Copy link

petrovr commented Feb 9, 2025

Almost all issues shows call-stack that starts "at exit", call softhsm ...CloseSession... and then crash i.e., bus error, or segmentation fault, or core dump.

More or less this is expected when a project uses unreliable and non-portable functionality like at-exit. In addition refuses to proposes portable solution. For instance cygwin hang is because of "at exit" functionality.

With similar defects third parties try to force project to fix external issues.

May be just to stop processing when is detected "lazy" clean-up request. I mean to check for null pointers in close session.


Off topic: Long time ago in pkix-ssh implementation allows use of identity (keys) from engine. This is an openssl loadable module and one thing is clear indirectly - in general module cannot be considered as stateless. It may open database and so close of database should be triggered as well. It may use network connections, devices , and etc.. Clean shutdown of used resources is preferred.
In consequence pkix-ssh explicitly clean(free) all used keys and unload modules in main function. Additionally, is performed clean-up of openssl.
With such model "crash" is gone.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants