google / safeside

Understand and mitigate software-observable side-channels
BSD 3-Clause "New" or "Revised" License
498 stars 54 forks source link

Reduce code duplication. #48

Open asteinha opened 5 years ago

asteinha commented 5 years ago

There are code sections that are repeated across all demonstrations. They should be factored out.

mmdriley commented 5 years ago

I think we have enough instances of this (e.g. signal-handling setup, cache timing measurement) to merit giving this issue priority over adding new examples.

Every instance of copied code makes our demos harder to understand and significantly increases the cost of improvements or bugfixes.

Longer-term, we should be trying to reduce each example to its "leak primitive" -- usually the way we implemented LeakByte -- and make everything else part of a framework provided by the repo. There will be different plugin points depending on whether LeakByte works by, say, speculating past a fault (Meltdown style) or accessing one thing on an architectural path and another on the microarchitectural path (Spectre style).

asteinha commented 5 years ago

I'll start with signal handlers, cache flushes and other obvious duplicates, but unifying e.g. the main function of Meltdown and main function of cross-process Spectre BTB into one framework does not look very straightforward. There are many peculiarities besides of the leak primitive.