Skip to content

Commit

Permalink
Auto merge of #3966 - RalfJung:dont-trust-the-user, r=RalfJung
Browse files Browse the repository at this point in the history
Do not store synchronization primitive IDs in adressable memory

We shouldn't store this in a place where the program can mess with it.

Fixes #1649

Blocked by rust-lang/rust#131593
  • Loading branch information
bors committed Oct 14, 2024
2 parents e2c21d4 + 323ab1c commit 1362c5f
Show file tree
Hide file tree
Showing 15 changed files with 383 additions and 495 deletions.
17 changes: 0 additions & 17 deletions src/concurrency/init_once.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use std::collections::VecDeque;

use rustc_index::Idx;

use super::sync::EvalContextExtPriv as _;
use super::vector_clock::VClock;
use crate::*;

Expand All @@ -27,22 +26,6 @@ pub(super) struct InitOnce {

impl<'tcx> EvalContextExt<'tcx> for crate::MiriInterpCx<'tcx> {}
pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
fn init_once_get_or_create_id(
&mut self,
lock: &MPlaceTy<'tcx>,
offset: u64,
) -> InterpResult<'tcx, InitOnceId> {
let this = self.eval_context_mut();
this.get_or_create_id(
lock,
offset,
|ecx| &mut ecx.machine.sync.init_onces,
|_| interp_ok(Default::default()),
)?
.ok_or_else(|| err_ub_format!("init_once has invalid ID"))
.into()
}

#[inline]
fn init_once_status(&mut self, id: InitOnceId) -> InitOnceStatus {
let this = self.eval_context_ref();
Expand Down
Loading

0 comments on commit 1362c5f

Please sign in to comment.