7 ms·
Vulnerabilities Induced by Migrating to 64-Bit Platforms [pdf]
- marcoperaza 10y agoActual title: Twice the Bits, Twice the Trouble Better title: Double the Bits, Double the Trouble Might seem stupid, but something like that can play a big role in memorability. I don't think we'd all remember "Smashing the Stack for Fun and Profit" by name if it didn't have such a delicious title.
- ludamad 10y agoWhy do you think that's a better title?
- shioyama 10y agoI guess because "double" rhymes with "trouble" maybe?
- marcoperaza 10y ago"Double [the] trouble" is a somewhat common idiomatic phrase. It rhymes "double" with "trouble", and the word "double" has a pleasant ring to it in its own right.
- Razengan 10y agoYes, it has a nice woody quality, "twice" is too tinny.
- VodkaHaze 10y agoBecause that's what team rocket would chant if they upgraded their servers
- JBiserkov 10y agoI agree. One possible reason against it though is that 'double' by itself is also used as a type denoting 'double precision floating point number'
- gruez 10y ago>I don't think we'd all remember "Smashing the Stack for Fun and Profit" by name if it didn't have such a delicious title. Am I the only person here that doesn't like "for fun and profit" titles?
- marcoperaza 10y agoWas it overused at that point? My understanding is that people started abusing it after Smashing the Stack... "Smashing the Stack" is also the best part.
- poshli 10y agonot as bad as ".... considered harmful"
- vardump 10y agoI thought these issues are obvious by now. Some typical points to consider: 1) Never store a length as an int, unsigned, long, etc. Use size_t (or ssize_t) instead. 2) Never store a pointer as an int, unsigned, long, etc. Use uintptr_t (or intptr_t). ptrdiff_t is the type to use for pointer differencing. 3) When comparing or casting to a signed type, watch out for sign extension. For example (short) -1 (0xffff) becomes 2^32-1 (0xffffffff) when casted to uint32_t. Remember char is usually a signed type. 4) Some legacy library functions return int, which is a signed 32-bit value in Windows and Linux (remember point 3). Watch out for these cases. For example don't use ftell and check s[n]printf return value.
- tormeh 10y agoDoes Rust fix this, or is this mess still necessary?
- Coding_Cat 10y agoI don't now if it fixes it per se, but it does make it harder to mess up. For example, it does not automatically convert between sizes (usize) and unsigned integers (u64).
- jibsen 10y agoIt's worth noting that ssize_t is a POSIX type, and is only guaranteed to have the range [-1, SSIZE_MAX] (basically a size type with one error value) [1]. If you need negative sizes, then ptrdiff_t is perhaps better. [1]: http://pubs.opengroup.org/onlinepubs/009696699/basedefs/sys/types.h.html http://pubs.opengroup.org/onlinepubs/009696699/basedefs/sys/...
- vardump 10y agoThanks for the correction! > only guaranteed to have the range [-1, SSIZE_MAX] Oh, that's a weird type. I wonder if any compiler implementation encodes it with -1 bias, so that all bits 0 means "-1". It could cause a disaster if/when ssize_t is encoded as anything else but standard twos complement signed number...
- userbinator 10y ago32-bit is relatively nice because ints, longs, and pointers are all the same size; that was also one of the main motivators in the 16-to-32 transition era, since the relative size of an int and a pointer did not change. The same thing didn't happen with the x86 transition to 64-bit, because it would effectively double the memory usage of every program even if it never needed such widths. The "bitness" of a platform has always seemed to be a bit of a vague term to me; sometimes it refers to data width, sometimes it refers to address width, and sometimes a combination of both and neither. If we refer to data width, then the 8087 was already "80-bit" (FP) or "64-bit" (integers) and the latest CPUs with AVX512 are "512-bit". If we refer to address width, then the 8086/8088 are "20-bit" machines, the 80286 "24-bit", and P6 "36-bit". I think a lot of this confusion and the vulnerabilities thus introduced are precisely because the relative sizes of the different types have changed, and exactly how they changed is not consistent across platforms nor clearly known to most programmers.
- vardump 10y ago> If we refer to address width, then the 8086/8088 are "20-bit" machines, the 80286 "24-bit", and P6 "36-bit". Also MOS 6502/6510 would have been "16-bit" by that standard. Some ARMv7 designs would be "40-bit" (like Cortex A7 and A15, probably others too). Or alternatively "128-bit", if considering NEON SIMD width! You could have also said they're 16/32/64/128-bit, because some designs had 16/32/64/128 bits wide memory bus. Yet all ARMv7 designs were considered 32-bit.
- hga 10y agoAnd the 68000 a 24-bit CPU, and boy did that cause trouble when Apple et. al. moved to later versions where those top 8 address bits were significant, especially since the 68000 was introduced when DRAM was really dear, e.g. the barely usable first Macintosh had only 128KiB, i.e. a program had essentially less address space to use than a split I&D PDP-11, which gave you 64KiB of each, with 8KiB of data space reserved for the stack. Less, because it's macroarchitecture is 32 bit, "wasting" bit and bytes here and there if your DRAM is that constrained.
- gok 10y ago
- 0xcde4c3db 10y agoI've read that catching stuff like this is a major reason that OpenBSD maintains (e.g.) SPARC64 support. Due to differences in MMU architectures, addressing modes, alignment requirements, etc., this kind of problem will often end up throwing an exception rather than silently doing almost-the-right-thing-usually.
- aomix 10y agoYep, here's a brief overview of that from 2007 https://youtu.be/NJ9Jml0GBPk?t=1937 https://youtu.be/NJ9Jml0GBPk?t=1937 . SPARC64 is a favorite of this developer because it's some Alice in Wonderland stuff where up is down and left is right compared to other architectures. So it exposes a number of bugs that others don't. Bugs exposed by moving to different architectures are fascinating. They always originate from assumptions that just happen to work on the architecture they were designed on. But when you go to a different arch they go from being sort of harmlessly incorrect to crash and burn type of incorrect. Or, infinitely worse, a sort of works but not in the way you expect it situation.