-
-
Notifications
You must be signed in to change notification settings - Fork 662
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: use correct index as shadowstack slot key (#2719) #2720
Conversation
I wish I knew what this was doing so I could review this properly. @dcodeIO is the most familiar with the shadowstack pass. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did some basic logging and it seems like you fixed something, although one function (I can only identify it by the location in binaryen.js's memory, 5587016
) seems to reuse an index/slot/whatever it is.
old:
currentFunction 5587016 numLocals 1 callSlotOffset 0 numSlots 0 i 0; total = 1
currentFunction 5587016 numLocals 1 callSlotOffset 0 numSlots 0 i 0; total = 1
currentFunction 5620480 numLocals 2 callSlotOffset 0 numSlots 0 i 0; total = 2
currentFunction 5621664 numLocals 3 callSlotOffset 0 numSlots 0 i 0; total = 3
currentFunction 5621664 numLocals 3 callSlotOffset 1 numSlots 0 i 0; total = 4
currentFunction 5621976 numLocals 0 callSlotOffset 0 numSlots 0 i 1; total = 1
currentFunction 5621976 numLocals 0 callSlotOffset 1 numSlots 0 i 0; total = 1
new:
currentFunction 5587016 numLocals 1 callSlotOffset 0 numSlots 0 i 0; total = 1
currentFunction 5587016 numLocals 1 callSlotOffset 0 numSlots 0 i 0; total = 1
currentFunction 5620480 numLocals 2 callSlotOffset 0 numSlots 0 i 0; total = 2
currentFunction 5621664 numLocals 3 callSlotOffset 0 numSlots 0 i 0; total = 3
currentFunction 5621664 numLocals 3 callSlotOffset 1 numSlots 0 i 0; total = 4
currentFunction 5621976 numLocals 0 callSlotOffset 0 numSlots 0 i 1; total = 0
currentFunction 5621976 numLocals 0 callSlotOffset 1 numSlots 0 i 0; total = 1
I'm a little confused by the diff, as it also touches |
Wouldn't CI have caught those in the previous PR, or on the main branch itself after it was merged? I'd guess some other parts of the diff triggered some heuristic to uninline |
@HerrCai0907 Hmm, try to sync with "main" and force to reinstall deps |
Okay, I think I understand a bit of what's going on. Maybe. I hope so. I've seen the change to If you run
@HerrCai0907 must have been using |
The diff in AssemblyScript#2720 showed that the fixtures for the bindings/raw and bindings/esm tests are out of date. The reason why this is so and why CI didn't complain is the same: these tests are almost always skipped. It also seems like the list of features in ASC_FEATURES is out of date as well, since it doesn't include simd and relaxed-simd. This patch ensures the entire compiler test suite is now run with all features enabled, as I don't think it's reasonable to expect everyone to keep CI in the back of their minds while writing a new test.
The diff in AssemblyScript#2720 showed that the fixtures for the bindings/raw and bindings/esm tests are out of date. The reason why this is so and why CI didn't complain is the same: these tests are almost always skipped. It also seems like the list of features in ASC_FEATURES is out of date as well, since it doesn't include simd and relaxed-simd. This patch ensures the entire compiler test suite is now run with all features enabled, as I don't think it's reasonable to expect everyone to keep CI in the back of their minds while writing a new test.
The diff in AssemblyScript#2720 showed that the fixtures for the bindings/raw and bindings/esm tests are out of date. The reason why this is so and why CI didn't complain is the same: these tests are almost always skipped. It also seems like the list of features in ASC_FEATURES is out of date as well, since it doesn't include simd and relaxed-simd. This patch ensures the entire compiler test suite is now run with all features enabled, as I don't think it's reasonable to expect everyone to keep CI in the back of their minds while writing a new test.
The reason why change in tests/compiler/math.release.wat which isn't part of the diff here is in last change in main branch, I also re-create all testcase. And the behavior of wasm egine in nodejs is a little bit different between x86 and arm64(maybe, I am not sure, but when I replace my laptop from x86 linux to aarch64 mac) |
I will revert other change and waiting for @CountBleck fix. |
I'm currently on an x86 Macbook running Node v20.0.0. |
@HerrCai0907 You should probably rebase onto/merge from |
@dcodeIO Could this PR merge? |
Thanks! |
Fixes #2719.
numLocals + this.callSlotOffset + operandIndex
will cause crash in nested call.In arguments of
f1
, key of the second argument (the firstnew T()
) is 0(callSlotOffset) + 1(operandIndex). And the key of the argument of f2 (the secondnew T()
) is 1(callSlotOffset) + 0(operandIndex). It means there use the same slot in shadow stack.So if gc happened in f2, the first
new T()
will be cleaned but it should be alive.This PR change
numLocals + this.callSlotOffset + operandIndex
tonumLocals + this.callSlotOffset + numSlots
, to avoid the same key in nested call.