Skip to content

fix(fs): preserve file bytes when a write arrives in chunks (#748) - #751

Merged
alexis900 merged 1 commit into
developfrom
fix/chunked-write-preserve
Nov 17, 2026
Merged

alexis900 merged 1 commit into
developfrom
fix/chunked-write-preserve

Conversation

@alexis900

Copy link
Copy Markdown
Collaborator

Qué cambia

file_write conserva el contenido no sobrescrito cuando el nuevo fichero es
mayor que el rango escrito (necesario porque cada escritura COW usa bloques
nuevos). Para leer ese prefijo llamaba a file_read(entry, …) pasando
entry.extent_lba, que está en bloques de 4096 B, mientras que file_read
espera el LBA de sectores (igual que neodos_v2::read_entry_bytes, que lo
traduce con translate_lba(extent_lba * 8)).

Consecuencia: cualquier escritura que no sea «todo el fichero desde el offset 0
en una sola llamada» guardaba basura en el prefijo, con el tamaño correcto.

Eso es exactamente lo que hacía neocurl -o:

Arreglo

Traducir el extent a sectores antes de la lectura de preservación (misma
convención que el resto del módulo). También afecta positivamente al volcado del
hive del registro, que se escribe en trozos de 4 KiB.

Verificación

  • Test nuevo de kernel neofs_v2_chunked_write_preserves_prefix: escribe
    1024 B + 367 B + 100 B en tres llamadas y comprueba byte a byte que el prefijo
    se conserva y que el fichero crece bien.
  • En huésped: neocurl -o … 525 B y 1391 B ya producen DER válido;
    neocurl --ca C:\TLS\ISRG.DER https://valid-isrgrootx1.letsencrypt.org/
    verifica la cadena real (antes: malformed DER), y la descarga de IANA sigue
    dando 200 569858 bytes.

Closes #748

`file_write` merges the untouched prefix of the old file because every write
allocates fresh COW blocks. It read that prefix with
`file_read(entry, …)`, passing `entry.extent_lba` — which is in 4096-byte
blocks — while `file_read` expects a **sector** LBA, as
`neodos_v2::read_entry_bytes` does (`translate_lba(extent_lba * 8)`). The
preserve read therefore started at an unrelated location, so any file written
in more than one call kept garbage where it should have kept its old bytes,
with the correct final size.

That is `neocurl -o`: a 525-byte body fits in one `sys_write`, but 1391 bytes
take two (the syscall caps at 4 KiB) and the result was a corrupt DER — the
`--ca` failure tracked in #748. The registry hive, flushed in 4 KiB chunks, was
exposed to the same bug.

The preserve read now translates the extent like the rest of the module.
Kernel test `neofs_v2_chunked_write_preserves_prefix` writes 1024 + 367 + 100
bytes in three calls and checks every byte.

Closes #748
@alexis900
alexis900 merged commit 702be62 into develop Nov 17, 2026
4 checks passed
@alexis900
alexis900 deleted the fix/chunked-write-preserve branch November 17, 2026 08:17
alexis900 added a commit that referenced this pull request Nov 17, 2026
* feat(tls): load the system trust store (D8)

HTTPS needed an explicit `--ca FILE`: the image carried no roots, so every real
connection was a fixture exercise.

- `libtls::der::split_certificates` splits a concatenated DER bundle using the
  X.690 lengths (no PEM/base64 parser on the target), with tests.
- `libnet::http_transport::system_roots()` reads
  `\NeoDOS\System\config\roots.der` through `ReadContent` and returns the
  anchors; a missing or unreadable bundle yields an empty list so TLS fails
  closed.
- `neocurl` uses the system store when `--ca` is absent (`--ca` still
  overrides), and refuses to start when there are no anchors at all.
- NeoDev (external, NeoDOS-Project/NeoDev#47) packs the bundle from the host's
  CA store; `NEODOS_TRUST_BUNDLE` overrides the source.

Docs: D8 marked resolved in `libtls-https-design.md` (§3.6) and the userland
guide; `CHANGELOG.md` gains an Unreleased section with this and the filesystem
fixes from #750/#751/#754.

* fix(usermode): raise the binary slot to 512 KiB and refuse oversized images

`MAX_BIN_SIZE` capped a user binary at 192 KiB and the loader *silently
truncated* anything larger, so the ELF parser failed far from the cause. When
`neocurl.nxe` (crypto + TLS + trust store) crossed 192 KiB the shell reported
"Comando o nombre de archivo incorrecto" and the binary simply never ran.

- `MAX_BIN_SIZE` is now 512 KiB (slot 576 KiB → 56 slots in the 32 MB user
  window, still ample).
- `create_process_from_ob_path` refuses a binary bigger than the cap with
  `NoMemory` and logs the size, instead of loading a truncated image.
- The design note for large NXEs records the new limit.

Refs #755
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

neocurl --ca: un DER de 1391 B se lee corrupto (el de 525 B funciona)

1 participant