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

ima-emulator: Implement graceful shutdown #525

Merged
merged 1 commit into from
Feb 20, 2023

Conversation

ansasaki
Copy link
Contributor

This adds signal-hook as a dependency for the IMA emulator. The strategy is similar to what is done on the keylime agent: a dedicated thread is spawned to stop the main task on Ctrl + C (SIGINT).

@ansasaki ansasaki force-pushed the emulator_threads branch 2 times, most recently from 70b1a72 to 29dc015 Compare February 20, 2023 10:27
@ansasaki
Copy link
Contributor Author

/packit retest-failed

// FIXME: We could poll IMA_ML as in the python implementation, though
// the file is not pollable:
// https://github.com/torvalds/linux/blob/master/security/integrity/ima/ima_fs.c#L267
// Better idea might be to check the "runtime_measurements_count" file.
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe this can be used? https://crates.io/crates/signal-hook

If I read the code it is not using an active loop like in this solution, and the example seems really similar to the current approach.

Copy link
Contributor Author

@ansasaki ansasaki Feb 20, 2023

Choose a reason for hiding this comment

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

I can try, but I'm afraid it will fall into the case mentioned in the comment:

        // Do some time-limited stuff here
        // (if this could block forever, then there's no guarantee the signal will have any
        // effect).

Edit: I mean, we loop forever in the main thread

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well, apparently it works! I'll push the (much simpler) changes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you for the suggestion!

Copy link
Contributor

@aplanas aplanas Feb 20, 2023

Choose a reason for hiding this comment

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

IIRC in POSIX a signal is not a thread, is a callback that needs to be re-registered.

This adds signal-hook as a dependency for the IMA emulator.
The main thread is stopped on Ctrl + C (SIGINT).

Signed-off-by: Anderson Toshiyuki Sasaki <[email protected]>
@ansasaki
Copy link
Contributor Author

/packit retest-failed

@ansasaki
Copy link
Contributor Author

The issues on Fedora Rawhide can be related with a regression:
tpm2-software/tpm2-tools#3210

The other issue is again the conflict between i686 and x86_64 packages that for some reason are installed together.

@ansasaki ansasaki merged commit 8438bc0 into keylime:master Feb 20, 2023
@ansasaki ansasaki deleted the emulator_threads branch February 20, 2023 16:19
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.

5 participants