Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
e87f7a9
Fix Windows compile error when uvwasi is enabled (#3810)
wenyongh Sep 25, 2024
86926aa
Fix unused param warning when GC is enabled (#3814)
palchikov Sep 25, 2024
5ce6f90
Add scoreboard CI for supply-chain security (#3819)
TianlongLiang Sep 27, 2024
438b81b
Fix missing symbols when using aot mode on riscv platforms (#3812)
Kvencc Sep 28, 2024
0e05b0a
Add CODEOWNERS (#3822)
lum1n0us Sep 29, 2024
bd8c7a3
build(deps): bump github/codeql-action from 2.2.4 to 3.26.9
dependabot[bot] Sep 30, 2024
2baac8d
build(deps): bump actions/upload-artifact from 3.1.0 to 4.4.0
dependabot[bot] Sep 30, 2024
2e60f37
build(deps): bump ossf/scorecard-action from 2.3.1 to 2.4.0
dependabot[bot] Sep 30, 2024
e07ac1f
Merge pull request #3826 from bytecodealliance/dependabot/github_acti…
loganek Oct 5, 2024
5f3d36b
Merge pull request #3827 from bytecodealliance/dependabot/github_acti…
loganek Oct 5, 2024
e0027f3
Merge pull request #3828 from bytecodealliance/dependabot/github_acti…
loganek Oct 5, 2024
72872cb
Fix mac build of libc_emcc_wrapper.c (#3836)
bnason-nf Oct 5, 2024
0c4b2da
aot_comp_option.h: Add missing stdint.h header (#3834)
sjamesr Oct 7, 2024
f9153fb
build(deps): bump github/codeql-action from 3.26.9 to 3.26.11 (#3843)
dependabot[bot] Oct 8, 2024
6b4d8aa
Emit load_addr and load_size if WAMR_ENABLE_COMPILER is set (#3835)
sjamesr Oct 8, 2024
30539bf
Fix compilation error found in tflite test (#3820)
lum1n0us Oct 8, 2024
deacb7a
Fix exec_env_tls assertion in module instantiation (#3844)
wenyongh Oct 8, 2024
2b5e2d9
libc-emcc: Use alternate method to check getrandom support (#3848)
bnason-nf Oct 10, 2024
36d4380
Support table64 extension in classic-interp and AOT running modes (#3…
TianlongLiang Oct 11, 2024
b16b604
Enable libc-wasi for windows msvc build (#3852)
wenyongh Oct 14, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
uses: github/codeql-action/init@v3.26.11
with:
languages: ${{ matrix.language }}

Expand All @@ -66,7 +66,7 @@ jobs:
- run: |
./.github/scripts/codeql_buildscript.sh
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
uses: github/codeql-action/analyze@v3.26.11
with:
category: "/language:${{matrix.language}}"
upload: false
Expand Down Expand Up @@ -95,14 +95,14 @@ jobs:
output: ${{ steps.step1.outputs.sarif-output }}/cpp.sarif

- name: Upload CodeQL results to code scanning
uses: github/codeql-action/upload-sarif@v3
uses: github/codeql-action/upload-sarif@v3.26.11
with:
sarif_file: ${{ steps.step1.outputs.sarif-output }}
category: "/language:${{matrix.language}}"

- name: Upload CodeQL results as an artifact
if: success() || failure()
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@v4.4.0
with:
name: codeql-results
path: ${{ steps.step1.outputs.sarif-output }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/spec_test_on_nuttx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ jobs:

- name: upload the log
if: always()
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@v4.4.0
with:
name: spec-test-log-${{ github.run_id }}-${{ strategy.job-index }}-${{ matrix.target_config.target }}
path: log
65 changes: 65 additions & 0 deletions .github/workflows/supply_chain.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# This workflow uses actions that are not certified by GitHub. They are provided
# by a third-party and are governed by separate terms of service, privacy
# policy, and support documentation.

# Check current WASM Micro Runtime results here: https://securityscorecards.dev/viewer/?uri=github.com/bytecodealliance/wasm-micro-runtime

name: Scorecard supply-chain security
on:
# For Branch-Protection check. Only the default branch is supported. See
# https://github.com/ossf/scorecard/blob/main/docs/checks.md#branch-protection
branch_protection_rule:
# To guarantee Maintained check is occasionally updated. See
# https://github.com/ossf/scorecard/blob/main/docs/checks.md#maintained
# midnight UTC
schedule:
- cron: "0 0 * * *"
# allow to be triggered manually
workflow_dispatch:

# Declare default permissions as read only.
permissions:
contents: read

jobs:
analysis:
name: Scorecard analysis
runs-on: ubuntu-latest
if: github.repository == 'bytecodealliance/wasm-micro-runtime'
permissions:
# Needed to upload the results to code-scanning dashboard.
security-events: write
# Needed to publish results and get a badge (see publish_results below).
id-token: write

steps:
- name: "Checkout code"
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0
with:
persist-credentials: false

- name: "Run analysis"
uses: ossf/scorecard-action@62b2cac7ed8198b15735ed49ab1e5cf35480ba46 # v2.4.0
with:
results_file: results.sarif
results_format: sarif

# - Publish results to OpenSSF REST API for easy access by consumers
# - Allows the repository to include the Scorecard badge.
# - See https://github.com/ossf/scorecard-action#publishing-results.
publish_results: true

# Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF
# format to the repository Actions tab.
- name: "Upload artifact"
uses: actions/upload-artifact@3eadd8b791cabf7cd572f194da82158c24125bd8 # v3.1.0
with:
name: SARIF file
path: results.sarif
retention-days: 5

# Upload the results to GitHub's code scanning dashboard.
- name: "Upload to code-scanning"
uses: github/codeql-action/upload-sarif@56d197570aa047eae7fe04401603196e2f68521d # v2.2.4
with:
sarif_file: results.sarif
29 changes: 29 additions & 0 deletions CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# In this project, we use CODEOWNERS to identify people who are likely to know
# who should review a pull request.
#
# People listed in this file are committing to respond in a timely fashion to
# PRs in the selected areas. However, that response doesn't have to be a full
# code review; it could also take any of these forms:
#
# - "I intend to review this but I can't yet. Please leave me a message if I
# haven't responded by (a specific date in the near future)."
#
# - "I think (a specific other contributor) should review this." (Note that the
# best reviewer for a PR may not necessarily be listed in this file.)
#
# People must only be added to this file if they've agreed to provide one of
# the above responses in a reasonable amount of time for every PR to which
# they're assigned.
#
# We only ask for this commitment from people who are employed full-time to
# work on this project. We gratefully welcome reviews from other contributors,
# but we don't believe it's fair to ask volunteers to respond quickly.

# If none of the later patterns match, assign to anyone. This team is the
# parent of all the other teams and automatically includes everyone on those
# teams.
* @loganek @lum1n0us @no1wudi @wenyongh @xujuntwt95329 @yamt

# Some parts of the project require more specialized knowledge. In those areas
# we designate smaller groups who are more likely to be aware of who's working
# in specific areas.
17 changes: 16 additions & 1 deletion core/iwasm/aot/aot_loader.c
Original file line number Diff line number Diff line change
Expand Up @@ -1382,6 +1382,12 @@ load_table_list(const uint8 **p_buf, const uint8 *buf_end, AOTModule *module,
for (i = 0; i < module->table_count; i++, table++) {
read_uint8(buf, buf_end, table->table_type.elem_type);
read_uint8(buf, buf_end, table->table_type.flags);

if (!wasm_table_check_flags(table->table_type.flags, error_buf,
error_buf_size, true)) {
return false;
}

read_uint8(buf, buf_end, table->table_type.possible_grow);
#if WASM_ENABLE_GC != 0
if (wasm_is_type_multi_byte_type(table->table_type.elem_type)) {
Expand Down Expand Up @@ -2506,6 +2512,15 @@ try_merge_data_and_text(const uint8 **buf, const uint8 **buf_end,
/* merge failed but may be not critical for some targets */
return false;
}

#ifdef BH_PLATFORM_WINDOWS
if (!os_mem_commit(sections, code_size,
MMAP_PROT_READ | MMAP_PROT_WRITE | MMAP_PROT_EXEC)) {
os_munmap(sections, (uint32)total_size);
return false;
}
#endif

/* change the code part to be executable */
if (os_mprotect(sections, code_size,
MMAP_PROT_READ | MMAP_PROT_WRITE | MMAP_PROT_EXEC)
Expand All @@ -2520,7 +2535,7 @@ try_merge_data_and_text(const uint8 **buf, const uint8 **buf_end,
/* order not essential just as compiler does: .text section first */
*buf = sections;
*buf_end = sections + code_size;
bh_memcpy_s(sections, code_size, old_buf, code_size);
bh_memcpy_s(sections, (uint32)code_size, old_buf, (uint32)code_size);
os_munmap(old_buf, code_size);
sections += align_uint((uint32)code_size, page_size);

Expand Down
18 changes: 14 additions & 4 deletions core/iwasm/aot/aot_runtime.c
Original file line number Diff line number Diff line change
Expand Up @@ -737,18 +737,24 @@ tables_instantiate(AOTModuleInstance *module_inst, AOTModule *module,

#if WASM_ENABLE_REF_TYPES != 0
bh_assert(
table_seg->offset.init_expr_type == INIT_EXPR_TYPE_I32_CONST
table_seg->offset.init_expr_type
== (tbl_inst->is_table64 ? INIT_EXPR_TYPE_I64_CONST
: INIT_EXPR_TYPE_I32_CONST)
|| table_seg->offset.init_expr_type == INIT_EXPR_TYPE_GET_GLOBAL
|| table_seg->offset.init_expr_type == INIT_EXPR_TYPE_FUNCREF_CONST
|| table_seg->offset.init_expr_type
== INIT_EXPR_TYPE_REFNULL_CONST);
#else
bh_assert(table_seg->offset.init_expr_type == INIT_EXPR_TYPE_I32_CONST
bh_assert(table_seg->offset.init_expr_type
== (tbl_inst->is_table64 ? INIT_EXPR_TYPE_I64_CONST
: INIT_EXPR_TYPE_I32_CONST)
|| table_seg->offset.init_expr_type
== INIT_EXPR_TYPE_GET_GLOBAL);
#endif

/* Resolve table data base offset */
/* TODO: The table64 current implementation assumes table max size
* UINT32_MAX, so the offset conversion here is safe */
if (table_seg->offset.init_expr_type == INIT_EXPR_TYPE_GET_GLOBAL) {
global_index = table_seg->offset.u.global_index;

Expand Down Expand Up @@ -1560,8 +1566,12 @@ execute_post_instantiate_functions(AOTModuleInstance *module_inst,
if (is_sub_inst) {
bh_assert(exec_env_main);
#ifdef OS_ENABLE_HW_BOUND_CHECK
bh_assert(exec_env_tls == exec_env_main);
(void)exec_env_tls;
/* May come from pthread_create_wrapper, thread_spawn_wrapper and
wasm_cluster_spawn_exec_env. If it comes from the former two,
the exec_env_tls must be not NULL and equal to exec_env_main,
else if it comes from the last one, it may be NULL. */
if (exec_env_tls)
bh_assert(exec_env_tls == exec_env_main);
#endif
exec_env = exec_env_main;

Expand Down
13 changes: 13 additions & 0 deletions core/iwasm/aot/arch/aot_reloc_riscv.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#undef NEED_SOFT_I32_DIV
#undef NEED_SOFT_I64_MUL
#undef NEED_SOFT_I64_DIV
#undef NEED_SOFT_ATOMIC

#ifdef __riscv_flen
#if __riscv_flen == 32
Expand All @@ -48,6 +49,10 @@
#define NEED_SOFT_I64_DIV
#endif

#ifndef __riscv_atomic
#define NEED_SOFT_ATOMIC
#endif

/* clang-format off */
void __adddf3(void);
void __addsf3(void);
Expand Down Expand Up @@ -101,6 +106,9 @@ void __umoddi3(void);
void __umodsi3(void);
void __unorddf2(void);
void __unordsf2(void);
bool __atomic_compare_exchange_4(volatile void *, void *, unsigned int,
bool, int, int);
void __atomic_store_4(volatile void *, unsigned int, int);
/* clang-format on */

static SymbolMap target_sym_map[] = {
Expand All @@ -127,6 +135,7 @@ static SymbolMap target_sym_map[] = {
* to convert float and long long
*/
REG_SYM(__floatundisf),
REG_SYM(__floatdisf),
#endif
#ifdef NEED_SOFT_DP
REG_SYM(__adddf3),
Expand Down Expand Up @@ -175,6 +184,10 @@ static SymbolMap target_sym_map[] = {
REG_SYM(__moddi3),
REG_SYM(__udivdi3),
REG_SYM(__umoddi3),
#endif
#ifdef NEED_SOFT_ATOMIC
REG_SYM(__atomic_compare_exchange_4),
REG_SYM(__atomic_store_4),
#endif
/* clang-format on */
};
Expand Down
62 changes: 62 additions & 0 deletions core/iwasm/common/wasm_loader_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,37 @@ wasm_loader_set_error_buf(char *error_buf, uint32 error_buf_size,
}
}

#if WASM_ENABLE_MEMORY64 != 0
bool
check_memory64_flags_consistency(WASMModule *module, char *error_buf,
uint32 error_buf_size, bool is_aot)
{
uint32 i;
bool wasm64_flag, all_wasm64 = true, none_wasm64 = true;

for (i = 0; i < module->import_memory_count; ++i) {
wasm64_flag =
module->import_memories[i].u.memory.mem_type.flags & MEMORY64_FLAG;
all_wasm64 &= wasm64_flag;
none_wasm64 &= !wasm64_flag;
}

for (i = 0; i < module->memory_count; ++i) {
wasm64_flag = module->memories[i].flags & MEMORY64_FLAG;
all_wasm64 &= wasm64_flag;
none_wasm64 &= !wasm64_flag;
}

if (!(all_wasm64 || none_wasm64)) {
wasm_loader_set_error_buf(
error_buf, error_buf_size,
"inconsistent limits wasm64 flags for memory sections", is_aot);
return false;
}
return true;
}
#endif

bool
wasm_memory_check_flags(const uint8 mem_flag, char *error_buf,
uint32 error_buf_size, bool is_aot)
Expand Down Expand Up @@ -60,6 +91,37 @@ wasm_memory_check_flags(const uint8 mem_flag, char *error_buf,
return true;
}

bool
wasm_table_check_flags(const uint8 table_flag, char *error_buf,
uint32 error_buf_size, bool is_aot)
{
/* Check whether certain features indicated by mem_flag are enabled in
* runtime */
if (table_flag > MAX_TABLE_SIZE_FLAG) {
if (table_flag & SHARED_TABLE_FLAG) {
wasm_loader_set_error_buf(error_buf, error_buf_size,
"tables cannot be shared", is_aot);
}
#if WASM_ENABLE_MEMORY64 == 0
if (table_flag & TABLE64_FLAG) {
wasm_loader_set_error_buf(error_buf, error_buf_size,
"invalid limits flags(table64 flag was "
"found, please enable memory64)",
is_aot);
return false;
}
#endif
}

if (table_flag > MAX_TABLE_SIZE_FLAG + TABLE64_FLAG) {
wasm_loader_set_error_buf(error_buf, error_buf_size,
"invalid limits flags", is_aot);
return false;
}

return true;
}

/*
* compare with a bigger type set in `wasm_value_type_size_internal()`,
* this function will only cover global value type, function's param
Expand Down
12 changes: 12 additions & 0 deletions core/iwasm/common/wasm_loader_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,22 @@
extern "C" {
#endif

#if WASM_ENABLE_MEMORY64 != 0
/* check consistency of memory64 flags across all memories,
* they must be either all wasm64 or all wasm32 */
bool
check_memory64_flags_consistency(WASMModule *module, char *error_buf,
uint32 error_buf_size, bool is_aot);
#endif

bool
wasm_memory_check_flags(const uint8 mem_flag, char *error_buf,
uint32 error_buf_size, bool is_aot);

bool
wasm_table_check_flags(const uint8 table_flag, char *error_buf,
uint32 error_buf_size, bool is_aot);

bool
is_valid_value_type(uint8 value_tpye);

Expand Down
1 change: 0 additions & 1 deletion core/iwasm/common/wasm_runtime_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,6 @@ runtime_exception_handler(EXCEPTION_POINTERS *exce_info)
PEXCEPTION_RECORD ExceptionRecord = exce_info->ExceptionRecord;
uint8 *sig_addr = (uint8 *)ExceptionRecord->ExceptionInformation[1];
WASMModuleInstance *module_inst;
WASMMemoryInstance *memory_inst;
WASMJmpBuf *jmpbuf_node;
uint8 *mapped_mem_start_addr = NULL;
uint8 *mapped_mem_end_addr = NULL;
Expand Down
17 changes: 14 additions & 3 deletions core/iwasm/compilation/aot_compiler.c
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,20 @@ aot_validate_wasm(AOTCompContext *comp_ctx)
}

#if WASM_ENABLE_MEMORY64 != 0
if (comp_ctx->pointer_size < sizeof(uint64) && IS_MEMORY64) {
aot_set_last_error("Compiling wasm64 to 32bit platform is not allowed");
return false;
if (comp_ctx->pointer_size < sizeof(uint64)) {
if (IS_MEMORY64) {
aot_set_last_error("Compiling wasm64(contains i64 memory section) "
"to 32bit platform is not allowed");
return false;
}

for (uint32 i = 0; i < comp_ctx->comp_data->table_count; ++i) {
if (IS_TABLE64(i)) {
aot_set_last_error("Compiling wasm64(contains i64 table "
"section) to 32bit platform is not allowed");
return false;
}
}
}
#endif

Expand Down
Loading