Conversation

The Linux kernel chooses to use a superset of standard C. It doesn't ignore the rules that it isn't disabling via those switches but rather is actively tested with ASan and UBSan, with people working to address the cases that are not permitted, usually by fixing the kernel bugs.
2
1
The defined behavior can be trapping, which makes more sense in 2019 with software safety / security / robustness as such important issues. Hardware can and is being designed to make it efficient to catch these issues too. It can also just permit safety without using 'undefined'.
2
1
This Tweet was deleted by the Tweet author. Learn more
It does exist. Existing hardware has lots of safety features in hardware that are being actively used to catch these kinds of issues. More of those features are shipping over time. Intel CET and ARM MTE (which is like the existing SPARC ADI) are major examples of new features.
1
1
There is nothing about Intel CET that requires UB from the language; as I said, the compiler/spec don't have to reveal how function calls work. In my C spec, a load/store would be said to either load/store or trap, depending on how the runtime/CPU did things. So ARM MTE is OK.
1
So, it's okay to trap when indexing from one object to another and then dereferencing, or when constructing a non-derived pointer to an object in any other way and dereferencing it? That's what memory tagging will cause, since it aims to have the tags not match in those cases.
2
For example, the baseline for malloc is to set random tags for each allocation, along with adjusting them to avoid matching values for adjacent allocations. The compiler can do the same for stack frames (or even variables). Only properly derived pointers will actually work.
1
I'm not contradicting myself. I'm not fine with "invalid" loads/stores trapping if "invalid" is defined by the spec in terms of objects. But the spec can say that trapping is a possibility. Then an environment can make some loads trap. That happens to neatly describe reality.
1
MTE is an implementation of the rules about only being able to use pointers to access and object that they're derived from. That's pretty much exactly what it implements. Every pointer must have a tag matching the memory being accessed. Derived pointers will have a matching tag.
1
Show replies