-
Notifications
You must be signed in to change notification settings - Fork 3k
Fixed possible double deletion of SecurityManager database object #12145
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
Conversation
@AGlass0fMilk, thank you for your changes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thank you for the fix
if(_db != NULL) { | ||
delete _db; | ||
_db = NULL; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is redundant, the fix above is enough
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please replace tabs with spaces.
The second change is redundant, the fix in reset is enough to guard against double deletion.
@AGlass0fMilk could you please address @paul-szczepanek-arm last comments ? |
Once done, let us know to restart tests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As requested above by @paul-szczepanek-arm , marking this as request changes.
@paul-szczepanek-arm @0xc0170 Implemented requested changes. Please review. |
Lets continue there. I'll close this one. |
Summary of changes
Fixing possible scenario where dynamically-allocated SecurityManager database object could be deleted multiple times, possibly causing stack corruption and subsequent hard faults.
Related to issue #11768 and MR #11831
Calling
SecurityManager::reset
now checks to see if the database object has already been deleted before attempting to delete it.Subsequently, when reinitialized, the call to
SecurityManager::init_database
also tries to delete the database object without checking if it's NULL.I'm not sure why deleting the database object in reset and then reinitializing it allows the file to be flushed to non-volatile storage (see #11768 ), while deleting it in the
init_database
call and then reinitializing it does not appear to flush the database to disk first...However, this patch fixes both issues for me.
I think we need need to refactor the SecurityManager to address this issue from an architectural standpoint very soon.
Impact of changes
Migration actions required
Documentation
Related to issue #11768 and MR #11831
Pull request type
Test results
Reviewers
@paul-szczepanek-arm