Hacker News new | ask | show | jobs
by afdbcreid 49 days ago
Can you roundtrip a pointer as `MaybeUninit<usize>`? This is implied by this statement (and other rules of the language). And people rely on it.

You can make CHERI a non-conforming target. In fact we already have some (did you know x86-32 is a non-conforming target?). This is one of the leading options. The question is whether we don't give up too much existing code by that. No existing target is that incompatible.

1 comments

> Can you roundtrip a pointer as `MaybeUninit<usize>`?

AIUI Strict Provenance rules imply that you can't expect any such tricks to work unless the target promised they would work.

You say "People rely on it" and I must ask: How many people and how sure are you that they actually can't live with Strict Provenance ?

That's not true. Strict provenance says that you can not roundtrip a pointer via `usize` (with transmutes and not casts). You can via `MaybeUninit<usize>`. One of the fundamental properties of the language that is even specified explicitly (https://doc.rust-lang.org/stable/std/mem/union.MaybeUninit.h...) is that `MaybeUninit` preserves the exact Abstract Machine bytes, including provenance.
This manifestly can't work. Even if you can language lawyer your way to asserting that the words say this must work, it can't actually work in practice so the words are just wrong and I think other language lawyers will say that you must have understood the words wrong because "I'm correct, Up is actually Down" isn't helping anybody.