-
-
Notifications
You must be signed in to change notification settings - Fork 14.9k
[strict provenance] Fix System APIs That Are Liars #95496
Copy link
Copy link
Open
Labels
A-strict-provenanceArea: Strict provenance for raw pointersArea: Strict provenance for raw pointersO-unixOperating system: Unix-likeOperating system: Unix-likeT-libsRelevant to the library team, which will review and decide on the PR/issue.Relevant to the library team, which will review and decide on the PR/issue.
Metadata
Metadata
Assignees
Labels
A-strict-provenanceArea: Strict provenance for raw pointersArea: Strict provenance for raw pointersO-unixOperating system: Unix-likeOperating system: Unix-likeT-libsRelevant to the library team, which will review and decide on the PR/issue.Relevant to the library team, which will review and decide on the PR/issue.
Type
Fields
Give feedbackNo fields configured for issues without a type.
View all comments
This issue is part of the Strict Provenance Experiment - #95228
Some system APIs (and C FFI in general) like to lie about whether things are pointers, and this makes strict-provenance very sad.
prctl for PR_SET_NAME (says a pointer is unsigned long):
rust/library/std/src/sys/unix/thread.rs
Lines 120 to 127 in 44628f7
clone3(?) (says a pointer is u64):
rust/library/std/src/sys/unix/process/process_unix.rs
Lines 185 to 198 in 44628f7
sigaction (defines sighandler_t (a callback) to be size_t):
rust/library/std/src/sys/unix/stack_overflow.rs
Line 130 in 44628f7
The "level 1" fix for this is to just change our extern decls so that all of these APIs/types actually say "this is a pointer". In general it's ok for integers to pretend to be pointers "for fun", and if anything is ever
int | ptrthe valid union of these types isptr.The "level 2" fix for this is to instead come up with some general mechanism for dealing with these kinds that folks can use in the larger ecosystem, like a "this is lies" annotation or uptr. This kind of thing is especially nasty for people who are "bindgen true believers" and don't want to ever hand-edit generated bindings (so, not us).