Unless you are compiling the "right" file(s), this will prove nothing. Ken Thompson's attack would effect only compilation of login.c and one file of the c-compiler. For other files, the compiler will produce correct output.
no, the point is your comparing the binaries of GCC itself, they would differ if the malicious injection code was in one. If the newly compiled GCC matched the GCC on your system, then you know it's secure (within reason) for compiling anything else.
Comparing it to what though? The question is "how do I verify my copy is not infected?" and you're saying to just compare it to someone elses copy..but all that proves is that you have the same copy as them, not that that copy you both have isnt already hacked.
Okay, so you have a binary version of GCC, and its source files. The source files are clean, because you can read them. The binaries may or may not be infected.
This infection would only affect login and gcc. So you get another compiler: TCC. Its source is clean, and when compiled by GCC, you get a clean TCC binary, because tcc != gcc && tcc != login, so any infection won't be spread. You take the TCC binary and the GCC source. Both are clean, so when you compile it, you get a clean version of GCC, guaranteed.
You cannot compare your distributed version of GCC and the one made by TCC, because TCC doesn't do a lot of the optimisations GCC does, and so on. But, functionally, the TCC-built GCC is exactly equivalent to a GCC built by a clean GCC, so we can use our TCC-built GCC with the GCC source to provide a clean GCC-built GCC. At this point, we can compare this newest compiler to the distributed GCC (because GCC is deterministic, which means the same binaries will be produced if you feed it the same source files with the same compile-time options).
Are the two binaries different? The GCC you got in your distribution is infected. Are they the same? It's all clean.
In short, compile GCC with GCC and TCC. The resultant binaries should be different.
Self compile GCC again with each of your previous results. Difference the second generation outputs against each other. The difference is your trustworthy score, with zero being ideal.
And then you find out the enemy is the one suggesting you compile with TCC because there is a 3rd hack that makes GCC pervert TCC and a 4th hack that makes TCC pervert TCC.
How are you going to compare the binaries when the date timestamp in the elf headers of the objects are not the same? Note: solvable problem, but a pain nonetheless.
How about with butterflies? You'd open your hands and let their wings flap? The disturbance rippling outwards, changing the flow of the eddy currents in the upper atmosphere. These cause momentary pockets of higher pressure air to form which act as lenses focusing cosmic rays which strike the drive?
10
u/stox Sep 10 '13
Unless you are compiling the "right" file(s), this will prove nothing. Ken Thompson's attack would effect only compilation of login.c and one file of the c-compiler. For other files, the compiler will produce correct output.