Skip to content

Abla 0.2.72

Choose a tag to compare

@AndreBaltazar8 AndreBaltazar8 released this 25 Nov 09:12
· 590 commits to master since this release

Behaviour changes and migration (read first)

  • The OpenSSL-based (hosted) TLS client and server are stricter.

    • TLS 1.2 is the minimum, whatever the system's openssl.cnf allows.
    • Renegotiation is refused in both directions.
    • A server certificate whose host name appears only in the subject's
      common name, with no DNS subject alternative name, is refused, as the
      pure TLS client already does. Reissue such a certificate with a SAN.
    • A host given as an IP address is matched against the certificate's IP
      SANs and is not sent as SNI.

    (8f920a4, decision #136)

  • Android: the host's function table is copied. The library now copies
    the table a host passes to abla_android_host_install, so the table may
    be a local or be freed afterwards, and a table with a null function is
    refused with -1. Apps built the standard way are unaffected. (6a3df34)

  • Raw memory and raw system calls need trusted code (a warning now, an
    error in v0.2.73).
    A call from an ordinary (non-trusted) function to
    any of these prints warning[native.trust]:

    • abla/unsafe's raw-address functions: nativePointerAddress,
      nativePointerFromAddress, the callNative* family, raw loads and
      stores, MMIO;
    • the raw constructors of NativeByteBuffer, NativeI64Cell and
      NativePointerCell;
    • the raw system calls linuxSyscall0 to linuxSyscall6.

    Taking one of them as a function value counts too. Wrap the raw part in
    a small trusted function, which is where the argument for its safety
    belongs, or use a safe API: the buffer factories (nativeByteBuffer(size))
    and their checked methods, linuxRealtimeNanoseconds,
    secureRandomBytes, linuxReadAtDescriptor, linuxTcpConnectStart,
    linuxFileSync and the socket timeout setters. A dependency that needs
    trusted code needs your project's trusted.native line. Functions that
    only produce the address of static storage or of a function
    (nativeStaticAllocate, nativeFunctionAddress, ...) stay open. A
    project's own extern declarations without trusted are unchanged and
    documented as its own unchecked boundary. (91e710c, d6ab4c8,
    00b78c4, 31dcaae, decisions #130, #133 and #139)

  • Raw-address helpers are no longer public in the standard library. 256
    public trusted functions that took a memory address as an integer
    (for example aesWipe(address, length)) let any program write or free
    memory it does not own. They are now private or in internal files no
    program can import: the low-level arithmetic of x25519 (49), aes (40),
    ed25519 (14), mlkem (19), p256 (15), rsa (10), sha3 (10), chacha (6) and
    the rest of crypto; simd's address loads and stores (60); json's
    write-at-address encoders (7); the compiler bridge (8); llvm/orc's raw
    calls (4); and a few more. Each has a public API that takes values,
    strings or buffers instead. Also: aesGcmKeyNew/Free/SealWithKey/
    OpenWithKey give way to aesGcmKeyOwner(key) with .seal and .open;
    tlsOpen and tlsUpgradeHandle no longer take OpenSSL certificate and
    key addresses (use the TlsClientIdentity overloads); llvmOrcCallMain
    gives way to session.runMain. tlsControlInt, tlsControlPointer and
    tlsCloseHandle stay public but refuse a handle the TLS layer did not
    make. The raw big-number functions (bn*) stay public in this release;
    use BigModulus/BigNumber. ablac build --stdlib-internals exposes
    the hidden names to the standard library's own tests and tools only.
    (586305e, 9a818a6, 7b31b32, 8c09a48, decision #122)

Highlights

  • GPU kernels written in Abla (first step, experimental). A top-level
    function marked @kernel is ordinary Abla in a GPU subset: it runs once
    per thread, finds
    its thread with abla/kernel's ids, and reaches memory only through
    bounds-checked KernelF32Buffer/KernelU32Buffer (a load outside gives 0
    and a store outside does nothing, on every backend). The same function
    runs on the CPU (kernelRunCpu) or is built to PTX for CUDA (sm_80, via
    the host's LLVM opt/llc through ABLA_LLVM_TOOLS or PATH) and
    launched through abla/kernel/cuda with the driver API; no CUDA toolkit
    is needed. Vulkan and Metal come later (docs/design/gpu-kernels.md).
    (68e2e53, 1bc49a1, decision #141)

  • jsonDecode. jsonDecode and jsonDecodeDocument answer with a
    sealed JsonDecoded (JsonParsed, JsonMalformed, JsonLimitExceeded),
    so a when over the result must handle a malformed input and an input
    over the limits, instead of reading the JSON null that jsonParse gives
    on failure. (66f46ed)

  • Safe descriptor calls. linuxTcpConnectStart (a non-blocking connect
    to a numeric IPv4 address) and linuxSocketPendingError in
    abla/sys/linux/net, and linuxFileSync and linuxReadAtDescriptor (a
    read at an offset that leaves the file position alone) in
    abla/sys/linux/fs, replace the raw system calls packages carried.
    httpAsyncConnect now refuses a port outside 1 to 65535 with -22.
    (6255ec0)

  • copy with selected fields replaced. A non-generic class without a
    copy of its own supports value.copy(field = replacement) when the
    caller can name its primary constructor and every field can be copied:
    omitted fields come from the receiver, and constructor defaults are not
    run. A written copy keeps its usual rules, and resource, affine and
    delegated fields need an explicit one. (1fe088b, 806db06, 041e0ca,
    82ab784, decisions #125 and #132)

  • array.mapped. values.mapped { value -> ... } returns a fresh array,
    calling the block once per element in order; both element types must be
    copyable. (393637a)

  • Big numbers without addresses. BigModulus and BigNumber in
    abla/crypto/bignum do modular arithmetic on values that own and wipe
    their memory, with every width checked, so code like a wallet's field
    arithmetic no longer needs the raw bn* functions. (8905679,
    decisions #135 and #140)

  • ablac build --valgrind. The runtime tells valgrind's memcheck about
    its heap, so memcheck reports heap misuse and leaks in a program's own
    objects (ABLA_VALGRIND=1 for the builds a build program starts).
    (2b61e63, decision #129)

Fixes

  • Signal watch state (high): linuxSignalWatchGet and
    linuxSignalWatchSet read and wrote a word at any offset from the
    signal-watch state, so ordinary code could read and write any address
    (since v0.2.38). They now accept only the state's own words. (5130685)
  • Readers refuse an impossible count: every standard-library reader
    that turns a returned count into a string or a copy now stops the
    program with a clear message if the count is larger than what it asked
    for, instead of reading past its buffer. On Windows, a reset connection
    is a negative error, a peer that stays silent past a receive timeout is
    EAGAIN with no bytes, and SO_LINGER keeps its time. (90438e5,
    d670112)
  • Windows runtime: every kernel32 and ws2_32 function that returns a
    32-bit value is declared 32-bit, so its result no longer depends on the
    undefined upper half of the register (on x64 and ARM64); a check keeps it
    that way (903b989). dup2 works, and F_DUPFD honours its minimum
    (0eb4d19).
  • Reads with a huge maximum: TcpConnection.read, file reads and the
    compact TCP reader sized their buffer from the caller's maximum, which
    wrapped for the largest integer (the system refused the read, so nothing
    overflowed). The buffer is now sized by what is available to read, and a
    maximum of 0 or less reads nothing. (27db61b)
  • Editor analysis requests have a time budget: the analysis service
    stops an analysis, query or refactor check after 60 seconds of wall-clock
    time and answers complete: false with an issue, instead of working on
    a hostile or huge workspace indefinitely; it keeps serving requests.
    ABLA_ANALYSIS_BUDGET_MS (up to 600,000) overrides it. (71522a4)
  • Windows on ARM64: AES-GCM and TLS work (closes the known issue of
    v0.2.67 to v0.2.71):
    the CPU feature check no longer reads a register
    Windows reserves to the system, so a program that used AES-GCM, every
    TLS connection included, no longer dies on its first call. (6f9962a)

Performance

  • Compile speed: a default build no longer carries the runtime's
    valgrind hooks (adf1e28); reading a file no longer compiles the network
    modules (SocketReceiveResult now lives in
    abla/sys/linux/descriptor-result, and abla/sys/linux/net still
    re-exports it) (b161f92); and the editor's deadline checks are kept out
    of the compiler's hot loops (cff5991). Together these undo the
    compile-time regressions measured since v0.2.71.

  • TLS with OCSP staples: the staple check reuses the certificate path
    the chain check already verified, so a handshake with a staple costs
    about 0.35 ms more than before the default flip, not 0.65 ms.
    (3fa8eec)

  • Inline blocks: a literal block passed to an inline function is
    specialized before LLVM boxing, and inlined array loops are lowered
    before layout analysis. (748c84f, d3f5c87, a9e65ba)

  • Editor analysis: tiny analysis snapshots stay on the ordinary heap,
    ordinary compiler sources poll the request deadline less often, and the
    standard library's generic bodies stay out of pending editor
    evaluations. (2a0d6b4, 5fc638a, f1c77a9)

Docs

  • The tour explains compound updates and indexed array iteration.
    (d8d6826)

Known issue

  • GPU kernels (experimental): code that is not trusted can use abla/kernel to read or write memory it does not own, through the CUDA host types and kernel launches (since v0.2.72) and through workgroup shared memory on the CPU backend (since v0.2.73). Until v0.2.77, don't build dependencies you don't trust that import abla/kernel. Fixed in v0.2.77.
  • await task { ... } or await thread { ... }, with the task or thread written directly after await, doesn't keep it alive while it runs: a garbage collection inside its body can free it, and the program crashes or uses freed memory. Until v0.2.77, bind the task or thread to a val first (val t = task { ... }; await t). Fixed in v0.2.77.
  • Reading a very long number as a floating-point value (parseFloat, JSON's asF64 or readNumber, strtod) takes time quadratic in its digits, so one request carrying a JSON number of about a megabyte can keep a server busy for minutes. Until v0.2.77, reject or truncate numbers longer than a few hundred digits before converting them, or keep request bodies small. Fixed in v0.2.77.
  • A dependency's compile-time transform, or its custom $ syntax handler, can run compile-time code with your project's own compile-time grants (process, environment, file writes, network, native code), not the dependency's. Until v0.2.74, don't authorize those capabilities for your own project when you build with dependencies you don't trust. Fixed in v0.2.74, except for the case below.
  • A compile-time # site that a dependency's custom $ syntax handler builds into your file runs with your project's own compile-time grants (process, environment, file writes, network, native code), not the dependency's. Until v0.2.78, don't authorize those capabilities in a file that uses $ syntax from a dependency you don't trust. Fixed in v0.2.78.
  • ablac package update can run a dependency's compile-time import-provider code with your project's own compile-time grants (process, file writes, network), before the dependency is locked. Until v0.2.74, don't authorize those capabilities for your own project while you update dependencies you don't trust. Fixed in v0.2.74.
  • Ordinary code can write fields that the standard library's native buffers and cells rely on (closed of a NativeByteBuffer, NativeI64Cell or NativePointerCell), so safe code can reach memory it doesn't own. Until v0.2.79, don't write those fields outside the standard library, and check that your dependencies don't. Fixed in v0.2.79.
  • Safe code can make the GPU kernel runtime (abla/kernel, abla/kernel/cuda) read or write memory it doesn't own. Until v0.2.79, don't run kernel code from dependencies you don't trust, open one CUDA device at a time, and don't upload to or download into a buffer you have closed. Fixed in v0.2.79.
  • A dependency's custom $ syntax handler can have code of its own run at compile time with the grants of your file that uses the syntax (process, environment, file writes, network, native code). Until v0.2.79, don't authorize those capabilities in a file that uses $ syntax from a dependency you don't trust. Fixed in v0.2.79.
  • A dependency's prepared copy in .abla/packages/ is trusted by its marker files without checking its contents against abla.lock in single-file builds, and in project builds that also have a vendored copy, so a changed copy (from a restored CI cache, or committed next to a reviewed lock) is built as is. Until v0.2.79, delete .abla/packages/ before building when it may come from somewhere you don't control (it is fetched again and checked), and don't cache or commit it. Fixed in v0.2.79.
  • The HTTP clients (HttpClient.send, HttpAsyncClient, and the WebSocket TLS client's upgrade request) write the method, path and header values they are given without checking them, so a line break in a value that came from user input can add headers or a second request. Until v0.2.79, percent-encode user input in paths and queries (percentEncode) and refuse CR, LF and other control bytes in header values before passing them to a client. Fixed in v0.2.79.
  • The static Linux compiler's own hardening was weaker than a glibc build's: its stack-protector canary was a fixed value on AArch64, its _FORTIFY_SOURCE buffer checks did nothing, and realpath could overrun its caller's buffer with a very deep working directory plus a long relative path. None of these is reachable alone; each makes a separate overflow bug in LLVM or lld easier to exploit when compiling code you don't trust. On AArch64 its printf family also read arguments from the wrong place, so text that LLVM formats could show stack contents or crash the compiler. Until v0.2.79, on x86-64 Linux the dynamic compiler asset (ablac-dynamic-x86_64-linux, built on glibc) avoids them; elsewhere, build code you don't trust from a shallow directory. Fixed in v0.2.79.

Bootstrap convergence

Two fresh Linux builders bootstrapped the source of v0.2.72 (0d3c4b0903cf7f21966c23d5ba60fc0c622a013d) from different seeds and reached the same compiler:

  • route A: v0.2.71 (ablac-x86_64-linux sha256 e80eed4c65c9ea87f0cb4aef196e581dde1649407a3f1e6ccd849b577c38a69e) -> stage 1, 2, 3
  • route B: v0.2.70 (sha256 a6d6fb279ab6cf8a93703e36d6d5fbece49229fc416cb8a2c4a5b75504a96ad4) -> the sources of v0.2.71 (4f73994cff344c5d11500ab416ac8512232b2548), twice -> stage 1, 2, 3
  • canonical IR (raw, non-debug, pre-prune --emit-llvm src/orc_main.ab at /build/source): sha256 4346327b1d719cdcea651ea19f9656a94b1d8f6158eebdf48730ea28b002a74f
  • stage 2 executable fd52aa5a951f917934971c2a887139be2b0083f8cc9bc5fd5e57df2e7eb107ce, object 5a7d3717323731c2382b60e39b5040022dbb97692fa488b0be1f4cddb41def89
  • toolchain: environment d00897b2d6cc51118a9495656126ec6b32b87504a2eb780e173bac4eec54f68b, closure b1872f918c677d4b376f11826949774047bafeac6c208592b89a05f2dc4640aa
  • run: https://github.com/AndreBaltazar8/ablac/actions/runs/45580542422

This is route convergence within one compiler lineage: it is not an independent implementation, and it does not exclude a seed compromise shared by both routes (docs/bootstrap.md).