From 74714447811c45405eeb906b70625881e3f35284 Mon Sep 17 00:00:00 2001 From: cnc Date: Thu, 4 Jun 2026 19:59:14 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=82=E8=80=83=E6=89=80=E6=9C=89=E5=88=86?= =?UTF-8?q?=E7=BB=84=EF=BC=8C=E5=AE=8C=E6=88=90=E5=B0=BD=E9=87=8F=E5=A4=9A?= =?UTF-8?q?=E7=9A=84=E5=86=85=E5=AE=B9=E3=80=82=E7=A6=81=E6=AD=A2=E9=A1=BA?= =?UTF-8?q?=E6=89=8B=E6=89=A9=E5=8A=9F=E8=83=BD=20smoke=EF=BC=9A=E9=94=81?= =?UTF-8?q?=E5=AE=9Adlfcn=E7=A6=81=E7=94=A8=E8=BE=B9=E7=95=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 结论:按 LinuxCNC src/emc/rs274ngc/interp_base.cc 的 dlopen/dlsym/dlerror 调用点,补强 WASM dlfcn shim 与 interp_base probe,确认浏览器安全探针中动态加载保持不可用;不扩展 smoke 解析。 --- check-linuxcnc-wasm-shims-source-map.sh | 7 ++++++- core/wasm_shims/interp_base_probe_main.cc | 23 ++++++++++++++++++++++- docs/linuxcnc-wasm-shims-source-map.md | 2 +- 3 files changed, 29 insertions(+), 3 deletions(-) diff --git a/check-linuxcnc-wasm-shims-source-map.sh b/check-linuxcnc-wasm-shims-source-map.sh index 88f86ec..4b9256b 100755 --- a/check-linuxcnc-wasm-shims-source-map.sh +++ b/check-linuxcnc-wasm-shims-source-map.sh @@ -19,7 +19,11 @@ grep -F 'set(linuxcnc_wasm_safe_probe_shims' core/CMakeLists.txt >/dev/null grep -F 'LinuxCNC source basis: this guard ties the documented WASM blocker map' \ check-linuxcnc-wasm-blockers-source-map.sh >/dev/null -grep -F 'dlopen' "$linuxcnc_root/src/emc/rs274ngc/interp_base.cc" >/dev/null +grep -F 'dlopen(NULL, RTLD_GLOBAL);' "$linuxcnc_root/src/emc/rs274ngc/interp_base.cc" >/dev/null +grep -F 'interp_lib = dlopen(interp_path, RTLD_NOW);' "$linuxcnc_root/src/emc/rs274ngc/interp_base.cc" >/dev/null +grep -F 'Constructor constructor = (Constructor)dlsym(interp_lib, "makeInterp");' \ + "$linuxcnc_root/src/emc/rs274ngc/interp_base.cc" >/dev/null +grep -F 'dlerror()' "$linuxcnc_root/src/emc/rs274ngc/interp_base.cc" >/dev/null grep -F '#define _(s) gettext(s)' "$linuxcnc_root/src/emc/rs274ngc/interp_internal.hh" >/dev/null grep -F 'int _task = 0;' "$linuxcnc_root/src/emc/rs274ngc/gcodemodule.cc" >/dev/null grep -F 'int _task = 1;' "$linuxcnc_root/src/emc/task/emctaskmain.cc" >/dev/null @@ -118,6 +122,7 @@ for phrase in [ "CMake `linuxcnc_wasm_safe_probe_shims` set", "RS274/WASM manifest", "browser-safe LinuxCNC adaptations", + "dynamic loading unavailable", "inactive-DB return values", "negative-status short-circuit behavior", ]: diff --git a/core/wasm_shims/interp_base_probe_main.cc b/core/wasm_shims/interp_base_probe_main.cc index a7e2ccd..876f77f 100644 --- a/core/wasm_shims/interp_base_probe_main.cc +++ b/core/wasm_shims/interp_base_probe_main.cc @@ -1,8 +1,29 @@ +#include "dlfcn.h" #include "interp_base.hh" +#include + // LinuxCNC source basis: src/emc/rs274ngc/interp_base.cc provides -// interp_from_shlib(), with the declaration in interp_base.hh. +// interp_from_shlib(), with the declaration in interp_base.hh. Its native +// dlopen()/dlsym() loader edge is intentionally unavailable in WASM probes. int main() { + if (dlopen(nullptr, RTLD_GLOBAL) != nullptr) { + return 2; + } + if (dlopen("/tmp/cnc_sim_missing_interpreter.so", RTLD_NOW) != nullptr) { + return 3; + } + if (dlsym(nullptr, "makeInterp") != nullptr) { + return 4; + } + const char *error = dlerror(); + if (!error || !std::strstr(error, "dynamic loading is unavailable")) { + return 5; + } + if (dlclose(nullptr) != 0) { + return 6; + } + InterpBase *interp = interp_from_shlib("nonexistent-interpreter.so"); return interp == nullptr ? 0 : 1; } diff --git a/docs/linuxcnc-wasm-shims-source-map.md b/docs/linuxcnc-wasm-shims-source-map.md index 81c2aa3..dffccfa 100644 --- a/docs/linuxcnc-wasm-shims-source-map.md +++ b/docs/linuxcnc-wasm-shims-source-map.md @@ -14,7 +14,7 @@ only; it must not add CNC behavior and must not expand the temporary smoke parse | Shim | LinuxCNC source basis | Boundary | | --- | --- | --- | -| `core/wasm_shims/dlfcn.cc` | `src/emc/rs274ngc/interp_base.cc` | Satisfies native `dlopen` symbols for browser-safe probes. | +| `core/wasm_shims/dlfcn.cc` | `src/emc/rs274ngc/interp_base.cc` | Satisfies native `dlopen` symbols for browser-safe probes while keeping dynamic loading unavailable. | | `core/wasm_shims/emc_status_shim.cc` | `src/emc/sai/dummyemcstat.cc` | Provides the source-backed `emcStatus` singleton shape without task/NML startup. | | `core/wasm_shims/gettext_shim.cc` | `src/emc/rs274ngc/interp_internal.hh` | Preserves LinuxCNC diagnostic call sites without browser gettext catalogs. | | `core/wasm_shims/linuxcnc_runtime_shim.cc` | `src/emc/rs274ngc/gcodemodule.cc`, `src/emc/task/emctaskmain.cc`, `src/emc/task/taskclass.cc`, `src/emc/rs274ngc/interp_namedparams.cc`, `src/hal/hal_lib.c`, `src/emc/rs274ngc/rs274ngc_pre.cc` | Keeps preview/task, builtin Python module, HAL lookup, and `wordexp()` edges compile-safe. |