-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.
Description
This program writes to arbitrary memory, violating Rust's safety guarantees, despite using no unsafe code:
use std::fs;
use std::io;
use std::io::prelude::*;
fn main() {
let i = 0;
let j = &i as *const i32 as u64;
let mut f = fs::OpenOptions::new().write(true).open("/proc/self/mem").unwrap();
f.seek(io::SeekFrom::Start(j+16)).unwrap();
let k = [16; 16];
f.write(&k).unwrap();
}
Because the filesystem APIs cannot be made safe (blocking /proc
paths specifically will not work, because symlinks can be created to it), File::create
, File::open
, and OpenOptions::open
should be marked unsafe. I am working on an RFC for that right now.
gnzlbg, lgarczyn, zohnannor, Heliodex, cdstanford and 3 moreretep998, TimNN, 0xpr03, kevincox, Sherlock-Holo and 4 moreConnicpu, LunaBorowska, zesterer, TimDiekmann, stanislav-tkach and 71 more
Metadata
Metadata
Assignees
Labels
T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.