Skip to content

Commit 63fb30e

Browse files
authored
Merge pull request from GHSA-ff4p-7xrq-q5r8
* x64: Remove incorrect `amode_add` lowering rules This commit removes two incorrect rules as part of the x64 backend's computation of addressing modes. These two rules folded a zero-extended 32-bit computation into the address mode operand, but this isn't correct as the 32-bit computation should be truncated to 32-bits but when folded into the address mode computation it happens with 64-bit operands, meaning truncation doesn't happen. * Add release notes
1 parent 5dc2bbc commit 63fb30e

File tree

3 files changed

+52
-20
lines changed

3 files changed

+52
-20
lines changed

RELEASES.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,20 @@ Unreleased.
2020

2121
--------------------------------------------------------------------------------
2222

23+
## 6.0.1
24+
25+
Released 2023-03-08.
26+
27+
### Fixed
28+
29+
* Guest-controlled out-of-bounds read/write on x86\_64
30+
[GHSA-ff4p-7xrq-q5r8](https://github.com/bytecodealliance/wasmtime/security/advisories/GHSA-ff4p-7xrq-q5r8)
31+
32+
* Miscompilation of `i8x16.select` with the same inputs on x86\_64
33+
[GHSA-xm67-587q-r2vw](https://github.com/bytecodealliance/wasmtime/security/advisories/GHSA-xm67-587q-r2vw)
34+
35+
--------------------------------------------------------------------------------
36+
2337
## 6.0.0
2438

2539
Released 2023-02-20
@@ -74,6 +88,20 @@ Released 2023-02-20
7488

7589
--------------------------------------------------------------------------------
7690

91+
## 5.0.1
92+
93+
Released 2023-03-08.
94+
95+
### Fixed
96+
97+
* Guest-controlled out-of-bounds read/write on x86\_64
98+
[GHSA-ff4p-7xrq-q5r8](https://github.com/bytecodealliance/wasmtime/security/advisories/GHSA-ff4p-7xrq-q5r8)
99+
100+
* Miscompilation of `i8x16.select` with the same inputs on x86\_64
101+
[GHSA-xm67-587q-r2vw](https://github.com/bytecodealliance/wasmtime/security/advisories/GHSA-xm67-587q-r2vw)
102+
103+
--------------------------------------------------------------------------------
104+
77105
## 5.0.0
78106

79107
Released 2023-01-20
@@ -123,6 +151,20 @@ Released 2023-01-20
123151

124152
--------------------------------------------------------------------------------
125153

154+
## 4.0.1
155+
156+
Released 2023-03-08.
157+
158+
### Fixed
159+
160+
* Guest-controlled out-of-bounds read/write on x86\_64
161+
[GHSA-ff4p-7xrq-q5r8](https://github.com/bytecodealliance/wasmtime/security/advisories/GHSA-ff4p-7xrq-q5r8)
162+
163+
* Miscompilation of `i8x16.select` with the same inputs on x86\_64
164+
[GHSA-xm67-587q-r2vw](https://github.com/bytecodealliance/wasmtime/security/advisories/GHSA-xm67-587q-r2vw)
165+
166+
--------------------------------------------------------------------------------
167+
126168
## 4.0.0
127169

128170
Released 2022-12-20

cranelift/codegen/src/isa/x64/inst.isle

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1063,20 +1063,6 @@
10631063
(rule 2 (amode_add (Amode.ImmReg off (valid_reg base) flags) (ishl index (iconst (uimm8 shift))))
10641064
(if (u32_lteq (u8_as_u32 shift) 3))
10651065
(Amode.ImmRegRegShift off base index shift flags))
1066-
(rule 2 (amode_add (Amode.ImmReg off (valid_reg base) flags) (uextend (ishl index (iconst (uimm8 shift)))))
1067-
(if (u32_lteq (u8_as_u32 shift) 3))
1068-
(Amode.ImmRegRegShift off base (extend_to_gpr index $I64 (ExtendKind.Zero)) shift flags))
1069-
1070-
;; Same, but with a uextend of a shift of a 32-bit add. This is valid
1071-
;; because we know our lowering of a narrower-than-64-bit `iadd` will
1072-
;; always write the full register width, so we can effectively ignore
1073-
;; the `uextend` and look through it to the `ishl`.
1074-
;;
1075-
;; Priority 3 to avoid conflict with the previous rule.
1076-
(rule 3 (amode_add (Amode.ImmReg off (valid_reg base) flags)
1077-
(uextend (ishl index @ (iadd _ _) (iconst (uimm8 shift)))))
1078-
(if (u32_lteq (u8_as_u32 shift) 3))
1079-
(Amode.ImmRegRegShift off base index shift flags))
10801066

10811067
;; -- Case 4 (absorbing constant offsets).
10821068
;;

cranelift/filetests/filetests/isa/x64/amode-opt.clif

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -209,8 +209,9 @@ block0(v0: i64, v1: i32):
209209
; pushq %rbp
210210
; movq %rsp, %rbp
211211
; block0:
212-
; movl %esi, %ecx
213-
; movq -1(%rdi,%rcx,8), %rax
212+
; movq %rsi, %rdx
213+
; shll $3, %edx, %edx
214+
; movq -1(%rdi,%rdx,1), %rax
214215
; movq %rbp, %rsp
215216
; popq %rbp
216217
; ret
@@ -220,8 +221,9 @@ block0(v0: i64, v1: i32):
220221
; pushq %rbp
221222
; movq %rsp, %rbp
222223
; block1: ; offset 0x4
223-
; movl %esi, %ecx
224-
; movq -1(%rdi, %rcx, 8), %rax ; trap: heap_oob
224+
; movq %rsi, %rdx
225+
; shll $3, %edx
226+
; movq -1(%rdi, %rdx), %rax ; trap: heap_oob
225227
; movq %rbp, %rsp
226228
; popq %rbp
227229
; retq
@@ -244,7 +246,8 @@ block0(v0: i64, v1: i32, v2: i32):
244246
; block0:
245247
; movq %rsi, %r8
246248
; addl %r8d, %edx, %r8d
247-
; movq -1(%rdi,%r8,4), %rax
249+
; shll $2, %r8d, %r8d
250+
; movq -1(%rdi,%r8,1), %rax
248251
; movq %rbp, %rsp
249252
; popq %rbp
250253
; ret
@@ -256,7 +259,8 @@ block0(v0: i64, v1: i32, v2: i32):
256259
; block1: ; offset 0x4
257260
; movq %rsi, %r8
258261
; addl %edx, %r8d
259-
; movq -1(%rdi, %r8, 4), %rax ; trap: heap_oob
262+
; shll $2, %r8d
263+
; movq -1(%rdi, %r8), %rax ; trap: heap_oob
260264
; movq %rbp, %rsp
261265
; popq %rbp
262266
; retq

0 commit comments

Comments
 (0)