|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
Private bounded validator seams shared by the mdl verifiers. More...
#include <stddef.h>#include <stdint.h>#include "mdl_export.h"#include "mdl_storage.h"#include "mdl_verify.h"#include "ra8_attributes.h"#include "ra8_err.h"Go to the source code of this file.
Data Structures | |
| struct | mdl_verify_arena_t |
| Allocation bridge retaining an explicit capacity failure. More... | |
| struct | mdl_verify_io_t |
| One open portable input and its immutable size snapshot. More... | |
Enumerations | |
| enum | mdl_verify_limit_t : uint32_t { k_verify_member_max = 100000U } |
| Bounded member policy shared by every structural verifier. More... | |
Functions | |
| void * | priv_mdl_verify_workspace_take (mdl_export_workspace_t *workspace, size_t bytes, size_t alignment) |
| Reserve one aligned span from the verifier's caller-owned arena. | |
| void * | priv_mdl_verify_arena_alloc (void *opaque, size_t items, size_t size) |
| Allocate one aligned miniz span from a monotonic arena. | |
| void | priv_mdl_verify_arena_free (void *opaque, void *address) |
| Accept a miniz free for a monotonic arena. | |
| ra8_err_t | priv_mdl_verify_io_read_up_to (mdl_verify_io_t *io, uint8_t *destination, size_t length, size_t *out_read) |
| Read up to a requested portable span. | |
| bool | priv_mdl_verify_is_image (const char *name) |
| Recognize supported image suffixes. | |
| bool | priv_mdl_verify_safe_member_name (const char *name) |
| Reject unsafe archive member paths. | |
| ra8_err_t | priv_mdl_verify_tar (mdl_verify_io_t *io, mdl_verify_report_t *report) |
| Validate an uncompressed CBT. | |
| ra8_err_t | priv_mdl_verify_gzip_tar (mdl_verify_io_t *io, mdl_export_workspace_t *workspace, mdl_verify_report_t *report) |
| Validate a gzip-compressed CBT. | |
Private bounded validator seams shared by the mdl verifiers.
Publishes the borrowed-input and miniz-arena state that both the container verifier and the streamed tarball verifier operate on, together with the bounded member policy every format shares.
[Ring 4 / Domain] {World: NS}
Definition in file mdl_verify_internal.h.
| enum mdl_verify_limit_t : uint32_t |
Bounded member policy shared by every structural verifier.
| Enumerator | |
|---|---|
| k_verify_member_max | Maximum archive member count. |
Definition at line 26 of file mdl_verify_internal.h.
| void * priv_mdl_verify_arena_alloc | ( | void * | opaque, |
| size_t | items, | ||
| size_t | size ) |
Allocate one aligned miniz span from a monotonic arena.
Prefixes each payload with a bounded header recording its extent so a later reallocation can copy exactly the preserved bytes.
| [in,out] | opaque | Bound mdl_verify_arena_t callback context. |
| [in] | items | Element count requested by miniz. |
| [in] | size | Element size requested by miniz. |
| NULL | The product overflowed or the arena is exhausted. |
| other | One writable payload of items times size bytes. |
opaque addresses one arena bound to a reset workspace. Definition at line 138 of file mdl_verify.c.
References mdl_alloc_header_t::bytes, mdl_verify_arena_t::exhausted, priv_mdl_verify_workspace_take(), RA8_PRIV, and mdl_verify_arena_t::workspace.
Referenced by internal_arena_realloc(), internal_gzip_init_inflate(), and internal_verify_zip().
| void priv_mdl_verify_arena_free | ( | void * | opaque, |
| void * | address ) |
Accept a miniz free for a monotonic arena.
Individual allocations remain reserved until the owning verifier resets the workspace, so this release has nothing to reclaim.
| [in,out] | opaque | Borrowed arena context. |
| [in] | address | Allocation being released. |
opaque is the callback context handed to miniz. address is NULL or was produced by priv_mdl_verify_arena_alloc. address is not accessed. Definition at line 162 of file mdl_verify.c.
References RA8_PRIV.
Referenced by internal_gzip_init_inflate(), and internal_verify_zip().
| ra8_err_t priv_mdl_verify_gzip_tar | ( | mdl_verify_io_t * | io, |
| mdl_export_workspace_t * | workspace, | ||
| mdl_verify_report_t * | report ) |
Validate a gzip-compressed CBT.
Streams raw inflate into the USTAR state machine and checks the fixed RFC 1952 framing, the stored CRC32 and ISIZE, and that no compressed byte follows the end-of-stream marker.
| [in,out] | io | Borrowed open input positioned at offset zero. |
| [in,out] | workspace | Exclusive caller-owned scratch arena. |
| [out] | report | Candidate report populated only on success. |
| k_ra8_ok | The complete gzip frame and inner TAR were valid. |
| k_ra8_err_validation_failed | Framing, CRC, size, or structure failed. |
| k_ra8_err_invalid_size | The scratch arena or a byte bound was exceeded. |
io is open. workspace was reset by the owning verifier. Definition at line 460 of file mdl_verify_tarball.c.
References internal_gzip_consume(), internal_gzip_header_valid(), internal_gzip_init_inflate(), internal_io_read_exact(), internal_tar_finish(), k_gzip_header_bytes, k_gzip_min_bytes, k_mdl_storage_io_bytes, k_ra8_err_validation_failed, k_ra8_ok, RA8_PRIV, mdl_gzip_stream_t::stream, and mdl_gzip_stream_t::tar.
Referenced by internal_verify_borrowed().
| ra8_err_t priv_mdl_verify_io_read_up_to | ( | mdl_verify_io_t * | io, |
| uint8_t * | destination, | ||
| size_t | length, | ||
| size_t * | out_read ) |
Read up to a requested portable span.
Repeats short reads and stops only at end of file or on failure.
| [in,out] | io | Open verifier input. |
| [out] | destination | Writable destination buffer. |
| [in] | length | Maximum byte count to transfer. |
| [out] | out_read | Byte count actually produced. |
| k_ra8_ok | Data or a clean end of file was observed. |
| other | The portable read failed; out_read holds the prefix. |
io is open and destination spans length bytes. out_read is non-NULL and does not alias destination. out_read never exceeds length. Definition at line 233 of file mdl_verify.c.
References fw_fs_read(), k_ra8_ok, and RA8_PRIV.
Referenced by internal_io_read_exact(), internal_jof_pread(), internal_zip_read(), and priv_mdl_verify_tar().
| bool priv_mdl_verify_is_image | ( | const char * | name | ) |
Recognize supported image suffixes.
Applies the archive image allowlist case-insensitively.
| [in] | name | Archive member name. |
| true | The suffix is one of the supported image extensions. |
| false | No supported suffix matched. |
name is a NUL-terminated string. name remains valid for the call. name is unchanged. Definition at line 79 of file mdl_verify.c.
References internal_ends_ci(), and RA8_PRIV.
Referenced by internal_tar_member(), and internal_zip_member().
| bool priv_mdl_verify_safe_member_name | ( | const char * | name | ) |
Reject unsafe archive member paths.
Rejects absolute, empty, dot, parent, and backslash segments.
| [in] | name | Archive member name, or NULL. |
| true | The name is a safe relative path. |
| false | The name is NULL, absolute, or escapes its root. |
name is NULL or NUL-terminated. name is unchanged. Definition at line 86 of file mdl_verify.c.
References RA8_PRIV.
Referenced by internal_tar_member(), and internal_zip_member().
| ra8_err_t priv_mdl_verify_tar | ( | mdl_verify_io_t * | io, |
| mdl_verify_report_t * | report ) |
Validate an uncompressed CBT.
Streams borrowed reads straight into the USTAR state machine, so no archive-sized buffer is retained for any member.
| [in,out] | io | Borrowed open input positioned at offset zero. |
| [out] | report | Candidate report populated only on success. |
| k_ra8_ok | Every record and the terminating pair were valid. |
| k_ra8_err_validation_failed | A record, name, or terminator was invalid. |
| k_ra8_err_invalid_size | A member count or byte total exceeded its bound. |
io is open. Definition at line 255 of file mdl_verify_tarball.c.
References internal_tar_feed(), internal_tar_finish(), mdl_storage_t::io_buffer, mdl_storage_t::io_buffer_bytes, k_ra8_ok, priv_mdl_verify_io_read_up_to(), and RA8_PRIV.
Referenced by internal_verify_borrowed().
| void * priv_mdl_verify_workspace_take | ( | mdl_export_workspace_t * | workspace, |
| size_t | bytes, | ||
| size_t | alignment ) |
Reserve one aligned span from the verifier's caller-owned arena.
Rounds the bump cursor up to alignment, refuses a request that would leave the arena, and records the resulting high-water mark.
| [in,out] | workspace | Exclusive caller-owned bump arena. |
| [in] | bytes | Nonzero span extent to reserve. |
| [in] | alignment | Power-of-two alignment required by the caller. |
| NULL | The request was malformed or the arena is exhausted. |
| other | One writable span of bytes bytes inside the arena. |
workspace is non-NULL and owns writable arena storage. alignment is a nonzero power of two. Definition at line 30 of file mdl_verify.c.
References mdl_export_workspace::cap, mdl_export_workspace::data, mdl_export_workspace::high_water, memcpy(), and mdl_export_workspace::used.
Referenced by internal_gzip_init_inflate(), and priv_mdl_verify_arena_alloc().