Skip to content

Commit

Permalink
Rollup merge of rust-lang#97761 - RalfJung:vtable-validation, r=cjgillot
Browse files Browse the repository at this point in the history
validating the vtable can lead to Stacked Borrows errors

Fixes rust-lang/miri#2123
  • Loading branch information
Dylan-DPC authored Jun 11, 2022
2 parents 7092d42 + 67ec969 commit d6e2d6d
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions compiler/rustc_const_eval/src/interpret/validity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,10 @@ impl<'rt, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> ValidityVisitor<'rt, 'mir, '
{ "invalid drop function pointer in vtable (not pointing to a function)" },
err_ub!(InvalidVtableDropFn(..)) =>
{ "invalid drop function pointer in vtable (function has incompatible signature)" },
// Stacked Borrows errors can happen here, see https://github.com/rust-lang/miri/issues/2123.
// (We assume there are no other MachineStop errors possible here.)
InterpError::MachineStop(_) =>
{ "vtable pointer does not have permission to read drop function pointer" },
);
try_validation!(
self.ecx.read_size_and_align_from_vtable(vtable),
Expand All @@ -347,6 +351,10 @@ impl<'rt, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> ValidityVisitor<'rt, 'mir, '
err_ub!(InvalidVtableAlignment(msg)) =>
{ "invalid vtable: alignment {}", msg },
err_unsup!(ReadPointerAsBytes) => { "invalid size or align in vtable" },
// Stacked Borrows errors can happen here, see https://github.com/rust-lang/miri/issues/2123.
// (We assume there are no other MachineStop errors possible here.)
InterpError::MachineStop(_) =>
{ "vtable pointer does not have permission to read size and alignment" },
);
// FIXME: More checks for the vtable.
}
Expand Down

0 comments on commit d6e2d6d

Please sign in to comment.