Skip to content

Commit 0ede7ff

Browse files
authored
fix: Use correct index as shadowstack slot key (#2720)
1 parent c49823e commit 0ede7ff

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+6440
-2245
lines changed

src/passes/shadowstack.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ export class ShadowStackPass extends Pass {
350350
}
351351
let currentFunction = this.currentFunction;
352352
let numLocals = _BinaryenFunctionGetNumLocals(currentFunction);
353-
let slotIndex = this.noteSlot(currentFunction, numLocals + this.callSlotOffset + i);
353+
let slotIndex = this.noteSlot(currentFunction, numLocals + this.callSlotOffset + numSlots);
354354
let temp = this.getSharedTemp(currentFunction, this.ptrType);
355355
let stmts = new Array<ExpressionRef>();
356356
// t = value

tests/compiler/bindings/esm.debug.wat

+7-7
Original file line numberDiff line numberDiff line change
@@ -4944,16 +4944,16 @@
49444944
(local $i|4 i32)
49454945
(local $5 i32)
49464946
global.get $~lib/memory/__stack_pointer
4947-
i32.const 12
4947+
i32.const 16
49484948
i32.sub
49494949
global.set $~lib/memory/__stack_pointer
49504950
call $~stack_check
49514951
global.get $~lib/memory/__stack_pointer
49524952
i64.const 0
49534953
i64.store $0
49544954
global.get $~lib/memory/__stack_pointer
4955-
i32.const 0
4956-
i32.store $0 offset=8
4955+
i64.const 0
4956+
i64.store $0 offset=8
49574957
global.get $~lib/memory/__stack_pointer
49584958
i32.const 0
49594959
local.get $a
@@ -4998,7 +4998,7 @@
49984998
local.set $5
49994999
global.get $~lib/memory/__stack_pointer
50005000
local.get $5
5001-
i32.store $0 offset=8
5001+
i32.store $0 offset=12
50025002
local.get $5
50035003
local.get $i
50045004
call $~lib/array/Array<~lib/string/String>#__get
@@ -5038,7 +5038,7 @@
50385038
local.set $5
50395039
global.get $~lib/memory/__stack_pointer
50405040
local.get $5
5041-
i32.store $0 offset=8
5041+
i32.store $0 offset=12
50425042
local.get $5
50435043
call $~lib/array/Array<~lib/string/String>#get:length
50445044
local.get $i|4
@@ -5047,7 +5047,7 @@
50475047
local.set $5
50485048
global.get $~lib/memory/__stack_pointer
50495049
local.get $5
5050-
i32.store $0 offset=8
5050+
i32.store $0 offset=12
50515051
local.get $5
50525052
local.get $i|4
50535053
call $~lib/array/Array<~lib/string/String>#__get
@@ -5067,7 +5067,7 @@
50675067
local.get $c
50685068
local.set $5
50695069
global.get $~lib/memory/__stack_pointer
5070-
i32.const 12
5070+
i32.const 16
50715071
i32.add
50725072
global.set $~lib/memory/__stack_pointer
50735073
local.get $5

tests/compiler/bindings/esm.release.wat

+7-7
Original file line numberDiff line numberDiff line change
@@ -3459,7 +3459,7 @@
34593459
(local $7 i32)
34603460
(local $8 i32)
34613461
global.get $~lib/memory/__stack_pointer
3462-
i32.const 12
3462+
i32.const 16
34633463
i32.sub
34643464
global.set $~lib/memory/__stack_pointer
34653465
block $folding-inner0
@@ -3472,8 +3472,8 @@
34723472
i64.const 0
34733473
i64.store $0
34743474
local.get $3
3475-
i32.const 0
3476-
i32.store $0 offset=8
3475+
i64.const 0
3476+
i64.store $0 offset=8
34773477
local.get $3
34783478
local.get $0
34793479
i32.store $0
@@ -3616,7 +3616,7 @@
36163616
i32.store $0
36173617
local.get $3
36183618
local.get $0
3619-
i32.store $0 offset=8
3619+
i32.store $0 offset=12
36203620
local.get $0
36213621
local.get $2
36223622
call $~lib/array/Array<~lib/string/String>#__get
@@ -3652,15 +3652,15 @@
36523652
i32.store $0
36533653
local.get $3
36543654
local.get $0
3655-
i32.store $0 offset=8
3655+
i32.store $0 offset=12
36563656
local.get $0
36573657
call $~lib/array/Array<i32>#get:length
36583658
local.get $2
36593659
i32.add
36603660
local.set $3
36613661
global.get $~lib/memory/__stack_pointer
36623662
local.get $1
3663-
i32.store $0 offset=8
3663+
i32.store $0 offset=12
36643664
local.get $1
36653665
local.get $2
36663666
call $~lib/array/Array<~lib/string/String>#__get
@@ -3680,7 +3680,7 @@
36803680
end
36813681
end
36823682
global.get $~lib/memory/__stack_pointer
3683-
i32.const 12
3683+
i32.const 16
36843684
i32.add
36853685
global.set $~lib/memory/__stack_pointer
36863686
local.get $5

tests/compiler/bindings/raw.debug.wat

+7-7
Original file line numberDiff line numberDiff line change
@@ -4947,16 +4947,16 @@
49474947
(local $i|4 i32)
49484948
(local $5 i32)
49494949
global.get $~lib/memory/__stack_pointer
4950-
i32.const 12
4950+
i32.const 16
49514951
i32.sub
49524952
global.set $~lib/memory/__stack_pointer
49534953
call $~stack_check
49544954
global.get $~lib/memory/__stack_pointer
49554955
i64.const 0
49564956
i64.store $0
49574957
global.get $~lib/memory/__stack_pointer
4958-
i32.const 0
4959-
i32.store $0 offset=8
4958+
i64.const 0
4959+
i64.store $0 offset=8
49604960
global.get $~lib/memory/__stack_pointer
49614961
i32.const 0
49624962
local.get $a
@@ -5001,7 +5001,7 @@
50015001
local.set $5
50025002
global.get $~lib/memory/__stack_pointer
50035003
local.get $5
5004-
i32.store $0 offset=8
5004+
i32.store $0 offset=12
50055005
local.get $5
50065006
local.get $i
50075007
call $~lib/array/Array<~lib/string/String>#__get
@@ -5041,7 +5041,7 @@
50415041
local.set $5
50425042
global.get $~lib/memory/__stack_pointer
50435043
local.get $5
5044-
i32.store $0 offset=8
5044+
i32.store $0 offset=12
50455045
local.get $5
50465046
call $~lib/array/Array<~lib/string/String>#get:length
50475047
local.get $i|4
@@ -5050,7 +5050,7 @@
50505050
local.set $5
50515051
global.get $~lib/memory/__stack_pointer
50525052
local.get $5
5053-
i32.store $0 offset=8
5053+
i32.store $0 offset=12
50545054
local.get $5
50555055
local.get $i|4
50565056
call $~lib/array/Array<~lib/string/String>#__get
@@ -5070,7 +5070,7 @@
50705070
local.get $c
50715071
local.set $5
50725072
global.get $~lib/memory/__stack_pointer
5073-
i32.const 12
5073+
i32.const 16
50745074
i32.add
50755075
global.set $~lib/memory/__stack_pointer
50765076
local.get $5

tests/compiler/bindings/raw.release.wat

+7-7
Original file line numberDiff line numberDiff line change
@@ -3459,7 +3459,7 @@
34593459
(local $7 i32)
34603460
(local $8 i32)
34613461
global.get $~lib/memory/__stack_pointer
3462-
i32.const 12
3462+
i32.const 16
34633463
i32.sub
34643464
global.set $~lib/memory/__stack_pointer
34653465
block $folding-inner0
@@ -3472,8 +3472,8 @@
34723472
i64.const 0
34733473
i64.store $0
34743474
local.get $3
3475-
i32.const 0
3476-
i32.store $0 offset=8
3475+
i64.const 0
3476+
i64.store $0 offset=8
34773477
local.get $3
34783478
local.get $0
34793479
i32.store $0
@@ -3616,7 +3616,7 @@
36163616
i32.store $0
36173617
local.get $3
36183618
local.get $0
3619-
i32.store $0 offset=8
3619+
i32.store $0 offset=12
36203620
local.get $0
36213621
local.get $2
36223622
call $~lib/array/Array<~lib/string/String>#__get
@@ -3652,15 +3652,15 @@
36523652
i32.store $0
36533653
local.get $3
36543654
local.get $0
3655-
i32.store $0 offset=8
3655+
i32.store $0 offset=12
36563656
local.get $0
36573657
call $~lib/array/Array<i32>#get:length
36583658
local.get $2
36593659
i32.add
36603660
local.set $3
36613661
global.get $~lib/memory/__stack_pointer
36623662
local.get $1
3663-
i32.store $0 offset=8
3663+
i32.store $0 offset=12
36643664
local.get $1
36653665
local.get $2
36663666
call $~lib/array/Array<~lib/string/String>#__get
@@ -3680,7 +3680,7 @@
36803680
end
36813681
end
36823682
global.get $~lib/memory/__stack_pointer
3683-
i32.const 12
3683+
i32.const 16
36843684
i32.add
36853685
global.set $~lib/memory/__stack_pointer
36863686
local.get $5

tests/compiler/duplicate-fields.debug.wat

+1-1
Original file line numberDiff line numberDiff line change
@@ -2957,7 +2957,7 @@
29572957
local.set $0
29582958
global.get $~lib/memory/__stack_pointer
29592959
local.get $0
2960-
i32.store $0 offset=4
2960+
i32.store $0
29612961
local.get $0
29622962
call $duplicate-fields/B2#constructor
29632963
global.set $duplicate-fields/raz

tests/compiler/duplicate-fields.release.wat

+1-1
Original file line numberDiff line numberDiff line change
@@ -1818,7 +1818,7 @@
18181818
global.set $~lib/memory/__stack_pointer
18191819
global.get $~lib/memory/__stack_pointer
18201820
local.get $2
1821-
i32.store $0 offset=4
1821+
i32.store $0
18221822
global.get $~lib/memory/__stack_pointer
18231823
i32.const 12
18241824
i32.sub

0 commit comments

Comments
 (0)