[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Diverse Double-Compiling, --with-c-toolchain and trusting trust
From: |
zimoun |
Subject: |
Diverse Double-Compiling, --with-c-toolchain and trusting trust |
Date: |
Wed, 14 Oct 2020 13:29:47 +0200 |
Hi,
Reading the recent discussions about Reproducible Builds, see [1, 2, 3],
I was in the mood to use the recent option ’–with-c-toolchain’ to
demonstrate how Guix is cool! But I have failed because I miss some UI,
I guess.
Well, my understanding of Diverse Double-Compiling can be summarized as:
Let’s consider that you have the source code of compiler (say ’tcc’
because it compiles fast) and 2 another compilers (say ’clang’ and
’gcc’).
| step | source | compiled with | produces |
|------+--------+---------------+----------|
| #1 | tcc | clang | tcc-A |
| #2 | tcc | tcc-A | tcc-B |
| #3 | tcc | gcc | tcc-C |
Nothing ensures that tcc-{A,B,C} are bit-to-bit identical –– even they
should have different binary code –– but they are functionally
equivalent, or something is already wrong.
The next steps is to recompile:
| step | source | compiled with | produces |
|------+--------+---------------+----------|
| #4 | tcc | tcc-B | tcc-1 |
| #5 | tcc | tcc-C | tcc-2 |
And now, if everything is ok, then ’tcc-1’ and ’tcc-2’ must be
bit-identical. Otherwise, the binaries ’clang’ *or* ’gcc’ are
compromised. Assuming that the source code of ’tcc’ is audited and not
compromised. ;-)
If the source of the compilers used at step #1 and #2 are available,
then the same procedure can be applied to detect an attack.
Well, the idea is to implement the procedure with Guix: step #1,
guix build tcc --with-c-toolchain=tcc=clang-toolchain
but then I do not know how to use the output to complete the step #2.
Is it possible to do it at the CLI level? Or do I have to write some
Scheme?
Thank you in advance for any tips.
All the best,
simon
1:
<https://lists.reproducible-builds.org/pipermail/rb-general/2020-October/002056.html>
2:
<https://reproducible-builds.org/news/2019/12/21/reproducible-bootstrap-of-mes-c-compiler/>
3: <https://dwheeler.com/trusting-trust/#real-world>
- Diverse Double-Compiling, --with-c-toolchain and trusting trust,
zimoun <=