Wi-Fi software security bug could leave Android, Windows, Linux open to attack (Ars Technica)
Wi-Fi software security bug could leave Android, Windows, Linux open to attack (Ars Technica)
Posted Apr 24, 2015 19:28 UTC (Fri) by wahern (subscriber, #37304)In reply to: Wi-Fi software security bug could leave Android, Windows, Linux open to attack (Ars Technica) by Karellen
Parent article: Wi-Fi software security bug could leave Android, Windows, Linux open to attack (Ars Technica)
Both clang and GCC have AddressSanitizier.
TCC has (or had) a very sophisticated bounds checking mode which is much more strict than AddressSanitizer. See http://bellard.org/tcc/tcc-doc.html#SEC21.
For example, TCC bounds checks not only pointer dereferences, but pointer derivation. The following program succeeds with AddressSanitizer, but will abort at run-time with TCC
int main(void) {
char buf[] = "0123456789", *p;
p = &buf[sizeof buf];
while (--p >= buf)
putchar(*p);
putchar('\n');
return 0;
}
because the final --p evaluation derives an undefined pointer value--one element before the beginning of buf, whereas in C p can only point to an element within buf, or one past buf, regardless of whether you ever dereference it.
Unfortunately, the -b option appears to have been removed from the current release of TCC. It's not recognized with the version packaged for Ubuntu. You may need to download Fabrice Bellard's original code to see it in action. it might be worthwhile to resurrect it. Probably it was too much trouble to maintain when they added 64-bit support.
AFAIU, IBM mainframes use fat pointers, which encode type and capability information enforceable by the hardware. So C pointers are 128-bit, even when the hardware ISA is 32-bit or 64-bit. It's been this way since the 1970s, I think.
Apple's latest compilers for Objective-C and Swift use fat pointers to implement automated reference counting. They use the spare bits in the x86-64 and ARM64 pointer representation--the bottom bit(s), and top 16 bits of 64-bit pointers.
It would be cool if GCC or clang had built-ins to declare when and where to use fat pointers using type attributes. Then code could, at least on some architectures and for small'ish objects, have automated, fast bounds checking across different compilation units, without the burden of managing additional data structures to store and retrieve this information.
