Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatic Rustup #3326

Merged
merged 21 commits into from
Feb 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
309f458
Auto merge of #121579 - RalfJung:miri, r=RalfJung
bors Feb 25, 2024
edaa46e
Auto merge of #121581 - lnicola:sync-from-ra, r=lnicola
bors Feb 25, 2024
18893c9
Auto merge of #118724 - onur-ozkan:refactor-x-install, r=Mark-Simulacrum
bors Feb 25, 2024
3c12154
Add ProcessPrng shim to Miri
ChrisDenton Feb 20, 2024
889c79a
Auto merge of #121337 - ChrisDenton:ProcessPrng, r=Mark-Simulacrum
bors Feb 25, 2024
d965821
Rollup merge of #119590 - ChrisDenton:cfg-target-abi, r=Nilstrieb
matthiaskrgr Feb 25, 2024
c834bf7
Rollup merge of #120805 - RalfJung:const-pat-partial-eq, r=oli-obk
matthiaskrgr Feb 25, 2024
3628d91
Rollup merge of #121060 - clubby789:bool-newtypes, r=cjgillot
matthiaskrgr Feb 25, 2024
b386e5f
Rollup merge of #121284 - notriddle:notriddle/issue-106421, r=Mark-Si…
matthiaskrgr Feb 25, 2024
a215d06
Rollup merge of #121324 - Nadrieril:unspecialize, r=cjgillot
matthiaskrgr Feb 25, 2024
3ed8911
Rollup merge of #121409 - compiler-errors:atb-cycle, r=cjgillot
matthiaskrgr Feb 25, 2024
830cebe
Rollup merge of #121513 - nshyrei:fix_tests_module, r=cuviper
matthiaskrgr Feb 25, 2024
b1c3cda
Rollup merge of #121570 - Nilstrieb:!copy, r=clubby789
matthiaskrgr Feb 25, 2024
dc71a9e
Auto merge of #121591 - matthiaskrgr:rollup-8wfhh3v, r=matthiaskrgr
bors Feb 25, 2024
607fb72
Auto merge of #120393 - Urgau:rfc3373-non-local-defs, r=WaffleLapkin
bors Feb 25, 2024
6516e34
Auto merge of #121182 - majaha:mingw_ci_new, r=Mark-Simulacrum
bors Feb 25, 2024
3359a18
Auto merge of #121461 - reitermarkus:generic-nonzero-tests, r=dtolnay
bors Feb 26, 2024
f043de8
Preparing for merge from rustc
Feb 26, 2024
54e1e6c
Merge from rustc
Feb 26, 2024
9ab3b8f
fix clippy
RalfJung Feb 26, 2024
aeab7ae
add direct test for new ProcessPrng shim
RalfJung Feb 26, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion rust-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
a2f3c0cf880ad819c4eab2b320525b6a31ac6513
0250ef2571185b05701ed9d74fc904c17508a397
8 changes: 8 additions & 0 deletions src/shims/windows/foreign_items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,14 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
this.gen_random(ptr, len.into())?;
this.write_scalar(Scalar::from_bool(true), dest)?;
}
"ProcessPrng" => {
let [ptr, len] =
this.check_shim(abi, Abi::System { unwind: false }, link_name, args)?;
let ptr = this.read_pointer(ptr)?;
let len = this.read_target_usize(len)?;
this.gen_random(ptr, len)?;
this.write_scalar(Scalar::from_i32(1), dest)?;
}
"BCryptGenRandom" => {
let [algorithm, ptr, len, flags] =
this.check_shim(abi, Abi::System { unwind: false }, link_name, args)?;
Expand Down
17 changes: 17 additions & 0 deletions tests/pass/shims/windows-rand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use core::ptr::null_mut;
// Windows API definitions.
type NTSTATUS = i32;
type BOOLEAN = u8;
type BOOL = i32; // yes, seriously, BOOL and BOOLEAN are very different...
const BCRYPT_USE_SYSTEM_PREFERRED_RNG: u32 = 0x00000002;
const BCRYPT_RNG_ALG_HANDLE: *mut c_void = 0x81 as *mut c_void;
#[link(name = "bcrypt")]
Expand All @@ -22,6 +23,16 @@ extern "system" {
#[link_name = "SystemFunction036"]
fn RtlGenRandom(RandomBuffer: *mut u8, RandomBufferLength: u32) -> BOOLEAN;
}
#[cfg(target_arch = "x86")]
#[link(name = "bcryptprimitives", kind = "raw-dylib", import_name_type = "undecorated")]
extern "system" {
pub fn ProcessPrng(pbdata: *mut u8, cbdata: usize) -> BOOL;
}
#[cfg(not(target_arch = "x86"))]
#[link(name = "bcryptprimitives", kind = "raw-dylib")]
extern "system" {
pub fn ProcessPrng(pbdata: *mut u8, cbdata: usize) -> BOOL;
}

fn main() {
let mut key = [0u8; 24];
Expand All @@ -38,4 +49,10 @@ fn main() {
let ret = unsafe { RtlGenRandom(key.as_mut_ptr(), len) };
// RtlGenRandom returns a BOOLEAN where 0 indicates an error
assert_ne!(ret, 0);

let len = key.len();
let ret = unsafe { ProcessPrng(key.as_mut_ptr(), len) };
// ProcessPrng is documented as always returning `TRUE`.
// https://learn.microsoft.com/en-us/windows/win32/seccng/processprng#return-value
assert_eq!(ret, 1);
}
Loading