4 ms·
The post mentions only the C standard; I wonder what POSIX says about it. And there are also the platform ABIs, which specify how a pointer is passed between f
by cesarb 10y ago
The post mentions only the C standard; I wonder what POSIX says about it.
And there are also the platform ABIs, which specify how a pointer is passed between functions. If you're in a platform in which the ABI doesn't allow arbitrarily setting unused bits, even a "security-conscious implementation" will have to leave them alone, since a pointer can be passed to a function written in a different language. This also means that the "map the same object at multiple virtual addresses" trick, in which the implementation flips bits within the pointer knowing there is always a valid alias mapping to it, is broken: suppose two pointers to within the same object are passed (perhaps at separate times) to code written in another language. From the point of view of the other language, they might not be pointing to the same object, even if they should (for instance an array and an element within it, the function might want to compute the offset).
I also wonder how well does the "map the same object at multiple virtual addresses" trick work in architectures with VIVT caches, where both the index and the tag are virtual addresses. In these architectures, if you write through one mapping and want to access the same memory through another mapping, you have to flush the cache, otherwise you will have hard-to-debug problems if both mappings are in the cache at the same time.
- gpderetta 10y ago"I also wonder how well does the "map the same object at multiple virtual addresses" trick work in architectures with VIVT caches" Not well at all, unless the OS goes out of the way to do cache coloring. There is a reason that VIVT are today considered suboptimal.