forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#132234 - RalfJung:miri-sync, r=RalfJung
Miri subtree update r? `@ghost`
- Loading branch information
Showing
37 changed files
with
612 additions
and
299 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
17a19e684cdf3ca088af8b4da6a6209d128913f4 | ||
814df6e50eaf89b90793e7d9618bb60f1f18377a |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
pub mod foreign_items; | ||
pub mod thread; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
use rustc_span::Symbol; | ||
use rustc_target::abi::Size; | ||
use rustc_target::spec::abi::Abi; | ||
|
||
use crate::helpers::check_min_arg_count; | ||
use crate::shims::unix::thread::EvalContextExt as _; | ||
use crate::*; | ||
|
||
const TASK_COMM_LEN: usize = 16; | ||
|
||
pub fn prctl<'tcx>( | ||
this: &mut MiriInterpCx<'tcx>, | ||
link_name: Symbol, | ||
abi: Abi, | ||
args: &[OpTy<'tcx>], | ||
dest: &MPlaceTy<'tcx>, | ||
) -> InterpResult<'tcx> { | ||
// We do not use `check_shim` here because `prctl` is variadic. The argument | ||
// count is checked bellow. | ||
this.check_abi_and_shim_symbol_clash(abi, Abi::C { unwind: false }, link_name)?; | ||
|
||
// FIXME: Use constants once https://github.com/rust-lang/libc/pull/3941 backported to the 0.2 branch. | ||
let pr_set_name = 15; | ||
let pr_get_name = 16; | ||
|
||
let [op] = check_min_arg_count("prctl", args)?; | ||
let res = match this.read_scalar(op)?.to_i32()? { | ||
op if op == pr_set_name => { | ||
let [_, name] = check_min_arg_count("prctl(PR_SET_NAME, ...)", args)?; | ||
let name = this.read_scalar(name)?; | ||
let thread = this.pthread_self()?; | ||
// The Linux kernel silently truncates long names. | ||
// https://www.man7.org/linux/man-pages/man2/PR_SET_NAME.2const.html | ||
let res = | ||
this.pthread_setname_np(thread, name, TASK_COMM_LEN, /* truncate */ true)?; | ||
assert!(res); | ||
Scalar::from_u32(0) | ||
} | ||
op if op == pr_get_name => { | ||
let [_, name] = check_min_arg_count("prctl(PR_GET_NAME, ...)", args)?; | ||
let name = this.read_scalar(name)?; | ||
let thread = this.pthread_self()?; | ||
let len = Scalar::from_target_usize(TASK_COMM_LEN as u64, this); | ||
this.check_ptr_access( | ||
name.to_pointer(this)?, | ||
Size::from_bytes(TASK_COMM_LEN), | ||
CheckInAllocMsg::MemoryAccessTest, | ||
)?; | ||
let res = this.pthread_getname_np(thread, name, len, /* truncate*/ false)?; | ||
assert!(res); | ||
Scalar::from_u32(0) | ||
} | ||
op => throw_unsup_format!("Miri does not support `prctl` syscall with op={}", op), | ||
}; | ||
this.write_scalar(res, dest)?; | ||
interp_ok(()) | ||
} |
Oops, something went wrong.