A device can be made to open no dynamic library's file; only regular files are read
A pipeline creation loads, for each install name its stage's libraries name, the file that name names (dynamic_library.rs, `stage_with_dependencies`), and `new_dynamic_library_with_url` and a binary archive's descriptor read the file they name. Where the library bytes come from another party (a guest's metallib in a virtual GPU), its install names name any host path: `/dev/zero` grew `read_to_end` until the process ran out of memory, a FIFO blocked the creating thread for ever, opening a device file could act on the device, and any host file that parses as a dynamic metallib linked into the pipeline. - `DeviceOptions::load_no_dynamic_library_file` (and `RawDevice`'s), off by default: the device opens no file a library's install names name and refuses `new_dynamic_library_with_url` (`DynamicLibraryError::NoFileLoading`, new). A creation links only the libraries its function descriptors give (`libraries.preloaded`, `libraries.loaded` by install name); an install name `loaded` lacks loads nothing, so a creation whose import survives specialization fails `Compile(NeedsInput(DynamicLibrary))`, as Metal's does for a file it cannot load. - Without the switch, every such read goes through `container::read_file`: a regular file alone, looked at before it is opened, opened `O_NONBLOCK | O_NOCTTY` and looked at again through the handle, read once no further than its length when opened, a length the process cannot hold refused rather than allocated. A FIFO, device or directory loads nothing as an install name and is `InvalidFile` for `new_dynamic_library_with_url` and a binary archive. The stage_with_dependencies call sites (compute, render, mesh, tile creation) pass the device. Docs: the field's and variant's doc comments, the runtime README's options table, docs/API.md's accepted differences. api_signatures.tsv blessed (two fields, one variant); docs/REFUSALS.md regenerates unchanged. Tests, each failing without the change (a control commit neutralizing the gate and the regular-file read, run once): - tests::binary_archive::a_path_of_no_regular_file_is_no_archive_and_is_not_waited_on (CPU): a FIFO and /dev/zero are InvalidFile, each read bounded at 30 s. - runtime_lane::dynamic_libraries::an_install_name_of_no_regular_file_loads_nothing_and_waits_on_nothing (lavapipe): a FIFO's and /dev/zero's install names load nothing, the creation is refused NeedsInput(DynamicLibrary), new_dynamic_library_with_url is InvalidFile, each bounded at 60 s. - runtime_lane::dynamic_libraries::a_device_that_loads_no_file_links_only_the_libraries_it_is_given (lavapipe): with the switch, a client linked against A's real file is refused, A preloaded or not; given A in `libraries.loaded` it links A's values; new_dynamic_library_with_url is refused.
This commit is contained in:
1 parent
6e9528c2fe
commit
3a7568d5b4
14 files changed
+321
-39
No files matched your search
+11
@@ -4746,6 +4746,17 @@ each item named states the rule in full.
|
||||
path, not a URL.
|
||||
- **A dynamic library's file is its metallib.** `DynamicLibrary::serialize_to_url` writes the bytes
|
||||
the library was made from, without a slice of GPU code; the runtime loads either form.
|
||||
- **Only a regular file is read.** A pipeline creation's install name, a
|
||||
`Device::new_dynamic_library_with_url` path or a binary archive's path that names a FIFO, a
|
||||
device or a directory is not opened for reading: the install name loads nothing, and the other
|
||||
two are `InvalidFile`. A file is read once, no further than its length when opened. Metal's
|
||||
answer for such paths is not measured.
|
||||
- **A device can be made to open no dynamic library's file.** Under
|
||||
`DeviceOptions::load_no_dynamic_library_file` (and `RawDevice`'s), a creation links only the
|
||||
libraries its function descriptors give, an install name `libraries.loaded` lacks fails a
|
||||
creation whose import survives specialization (`Compile(NeedsInput(DynamicLibrary))`) where Metal
|
||||
would read the file, and `new_dynamic_library_with_url` is refused
|
||||
(`DynamicLibraryError::NoFileLoading`). Off by default.
|
||||
|
||||
**Resource IDs and identifiers**
|
||||
|
||||
|
||||
Reference in new issue
Block a user