You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
nvx-rs: give user IDs and file modes distinct types in the Linux platform primitives #643
store_dir_problem in nvx-rs/src/host/platform/linux.rs takes (uid: u32, mode: u32, euid: u32). Two of the three are user IDs of the same type, so a caller that swaps the owner and the current user, or passes a mode as a user ID, still compiles, and the privacy check then compares the wrong values. Wrap user IDs and modes in distinct types so the compiler rejects such mistakes.
Proposal
Use distinct types for a user ID and a file mode in the Linux platform primitives that check ownership and permissions. nix, already a dependency of the host feature, provides nix::unistd::Uid and nix::sys::stat::Mode; a small newtype of the crate's own is fine too.
Convert at the boundary where std::os::unix::fs::MetadataExt returns raw integers, and keep raw integers out of the signatures of the checks.
Keep the messages, which print user IDs in decimal and modes in octal, unchanged.
Apply the same types to other places in platform/linux.rs that pass user IDs or modes as bare integers.
Acceptance criteria
Passing a mode where a user ID is expected, or the reverse, fails to compile.
The unit tests of store_dir_problem and the store's privacy tests pass unchanged in what they assert.
No behavior changes.
Validation
On Linux, cargo clippy with --all-targets --all-features -- -D warnings and cargo test --all-features for nvx-rs/Cargo.toml. CI runs the rest of check-nvx-rs. The change needs no hypervisor.
Activity
nvx-rs: give user IDs and file modes distinct types in Linux checks