anatol / booster

Fast and secure initramfs generator
MIT License
504 stars 44 forks source link

Implement events synchronization mechanism (pubsub?) #100

Open anatol opened 3 years ago

anatol commented 3 years ago

Booster has a few points that depend on results of other operations, e.g.

Currently booster uses either hacky delays or single-thread processing to make sure the events are ordered.

Replace it with better synchronization mechanism. It will help to avoid race conditions in the code.

One option is to use events pub-sub. Operations can be launched with multiple goroutines. If a thread needs a subsystem ready (e.g. network is initialized; a new Yubikey appeared; ...) then it subscribes to a specific pub-sub channel and waits for event.

Axelen123 commented 1 year ago

I think I could rework the code I PR'd to fix the TPM race condition into something that could be used for the other things listed too. Just need to find some time for it.

Each of these need to wait for some condition that may or may not ever be satisfied, just like unlocking the TPM. A simple channel might work for this.