Skip to content

release/19.x: [lld][WebAssembly] Fix use of uninitialized stack data with --wasm64 (#107780) #119723

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

Merged
merged 1 commit into from
Dec 17, 2024

Conversation

llvmbot
Copy link
Member

@llvmbot llvmbot commented Dec 12, 2024

Backport 5c8fd1e

Requested by: @nikic

@llvmbot llvmbot added this to the LLVM 19.X Release milestone Dec 12, 2024
@llvmbot
Copy link
Member Author

llvmbot commented Dec 12, 2024

@dschuff What do you think about merging this PR to the release branch?

@llvmbot
Copy link
Member Author

llvmbot commented Dec 12, 2024

@llvm/pr-subscribers-lld

Author: None (llvmbot)

Changes

Backport 5c8fd1e

Requested by: @nikic


Full diff: https://github.com/llvm/llvm-project/pull/119723.diff

1 Files Affected:

  • (modified) lld/wasm/SyntheticSections.cpp (+1-2)
diff --git a/lld/wasm/SyntheticSections.cpp b/lld/wasm/SyntheticSections.cpp
index f02f55519a2512..72d08b849d8e86 100644
--- a/lld/wasm/SyntheticSections.cpp
+++ b/lld/wasm/SyntheticSections.cpp
@@ -587,8 +587,7 @@ void ElemSection::writeBody() {
     initExpr.Inst.Value.Global = WasmSym::tableBase->getGlobalIndex();
   } else {
     bool is64 = config->is64.value_or(false);
-    initExpr.Inst.Opcode = is64 ? WASM_OPCODE_I64_CONST : WASM_OPCODE_I32_CONST;
-    initExpr.Inst.Value.Int32 = config->tableBase;
+    initExpr = intConst(config->tableBase, is64);
   }
   writeInitExpr(os, initExpr);
 

@llvmbot
Copy link
Member Author

llvmbot commented Dec 12, 2024

@llvm/pr-subscribers-lld-wasm

Author: None (llvmbot)

Changes

Backport 5c8fd1e

Requested by: @nikic


Full diff: https://github.com/llvm/llvm-project/pull/119723.diff

1 Files Affected:

  • (modified) lld/wasm/SyntheticSections.cpp (+1-2)
diff --git a/lld/wasm/SyntheticSections.cpp b/lld/wasm/SyntheticSections.cpp
index f02f55519a2512..72d08b849d8e86 100644
--- a/lld/wasm/SyntheticSections.cpp
+++ b/lld/wasm/SyntheticSections.cpp
@@ -587,8 +587,7 @@ void ElemSection::writeBody() {
     initExpr.Inst.Value.Global = WasmSym::tableBase->getGlobalIndex();
   } else {
     bool is64 = config->is64.value_or(false);
-    initExpr.Inst.Opcode = is64 ? WASM_OPCODE_I64_CONST : WASM_OPCODE_I32_CONST;
-    initExpr.Inst.Value.Int32 = config->tableBase;
+    initExpr = intConst(config->tableBase, is64);
   }
   writeInitExpr(os, initExpr);
 

@adambratschikaye
Copy link

@dschuff @nikic : Is there something that needs to be done to bump the LLVM version?

@nikic
Copy link
Contributor

nikic commented Dec 16, 2024

@dschuff For backport PRs, please rebase instead of merge. They do not use squash merge.

@lwshang
Copy link

lwshang commented Dec 17, 2024

Merging is blocked
The base branch does not allow updates.

Can this PR be merged?
Will this backport be able to catch the v19.1.6 train tomorrow (if it happens)?

@dianqk
Copy link
Member

dianqk commented Dec 17, 2024

Merging is blocked
The base branch does not allow updates.

Can this PR be merged? Will this backport be able to catch the v19.1.6 train tomorrow (if it happens)?

Yes. I don't see any concerns not merging. Note that merging of the release branch is handled by the release manager, which is different from the main branch.

…lvm#107780)

In the case of `--wasm64` we were setting the type of the init expression
to be 64-bit but were only setting the low 32-bits of the value (by
assigning to Int32).

Fixes: emscripten-core/emscripten#22538
(cherry picked from commit 5c8fd1e)
@tru tru merged commit d2953ab into llvm:release/19.x Dec 17, 2024
7 of 9 checks passed
Copy link

@nikic (or anyone else). If you would like to add a note about this fix in the release notes (completely optional). Please reply to this comment with a one or two sentence description of the fix. When you are done, please add the release:note label to this PR.

@tru tru deleted the issue119717 branch December 17, 2024 09:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

Successfully merging this pull request may close these issues.

8 participants