Skip to content

Commit

Permalink
Merge pull request #103 from ethereum-optimism/feature/mininny/audit-14
Browse files Browse the repository at this point in the history
Check size is not greater than 8 for RV32A and RV63A
  • Loading branch information
mininny authored Jan 8, 2025
2 parents 0e65e85 + 36b7895 commit cdddf9e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion rvgo/fast/vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -877,7 +877,7 @@ func (inst *InstrumentedState) riscvStep() (outErr error) {
// 0b010 == RV32A W variants
// 0b011 == RV64A D variants
size := shl64(funct3, toU64(1))
if lt64(size, toU64(4)) != 0 {
if lt64(size, toU64(4)) != 0 || gt64(size, toU64(8)) != 0 {
revertWithCode(riscv.ErrBadAMOSize, fmt.Errorf("bad AMO size: %d", size))
}
addr := getRegister(rs1)
Expand Down
2 changes: 1 addition & 1 deletion rvgo/slow/vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -1061,7 +1061,7 @@ func Step(calldata []byte, po PreimageOracle) (stateHash common.Hash, outErr err
// 0b010 == RV32A W variants
// 0b011 == RV64A D variants
size := shl64(funct3, toU64(1))
if lt64(size, toU64(4)) != (U64{}) {
if or64(lt64(size, toU64(4)), gt64(size, toU64(8))) != (U64{}) {
revertWithCode(riscv.ErrBadAMOSize, fmt.Errorf("bad AMO size: %d", size))
}
addr := getRegister(rs1)
Expand Down

0 comments on commit cdddf9e

Please sign in to comment.