mirror of
https://github.com/morluto/rea.git
synced 2026-12-01 19:09:21 +00:00
refactor(elf): decouple structural admission from lane policies and type MIPS limitations (#14356)
Decouple fatal ELF structural/framing checks from optional trailing
section-table range observations via an explicit sectionRanges policy
("strict" | "observe") on validateElfDeclaredRanges, keeping native
section-directory and non-MIPS32 validation strict while making
readMipsElfMetadata reachable for carved MIPS32 ELFs.
Replace untyped string[] limitations on MipsElfMetadata and
MipsElfInspection with the MipsElfLimitation discriminated union
("truncated_section_table" | "unexamined_declarations") so
GhidraMipsProfile switches on typed kinds rather than prose prefixes,
admitting carved recordless legacy MIPS32 ET_EXEC images while keeping
declared-ABI, non-ET_EXEC, PSP, and non-section-truncation limitations
fail-closed.
Closes #14343
This commit is contained in:
1 parent
b6e06169cd
commit
782c274200
9 files changed
+526
-204
No files matched your search
@@ -29,7 +29,7 @@ import {
|
||||
type ExecutableMetadata,
|
||||
} from "../domain/binaryTarget.js";
|
||||
import {
|
||||
isRecordlessLegacyMips32Header,
|
||||
isRecordlessLegacyMipsExecHeader,
|
||||
PE_CODEVIEW_PREFIX_BYTES,
|
||||
type PeCodeViewRecord,
|
||||
type UniversalMachOSlice,
|
||||
@@ -234,13 +234,13 @@ const readElfMetadata = async (
|
||||
const { fileSize, hostArchitecture, signal } = options;
|
||||
const parsed = parseExecutableHeader(bytes, hostArchitecture, fileSize);
|
||||
if (!parsed.ok || parsed.value.format !== "elf") return parsed;
|
||||
const isMips32 =
|
||||
parsed.value.architecture === "mips" && parsed.value.mips.elfClass === 32;
|
||||
const ranges = await readElfDeclarations(
|
||||
handle,
|
||||
bytes,
|
||||
validateElfDeclaredRanges(bytes, fileSize, {
|
||||
allowTruncatedSectionTable:
|
||||
parsed.value.architecture === "mips" &&
|
||||
isRecordlessLegacyMips32Header(parsed.value.mips),
|
||||
sectionRanges: isMips32 ? "observe" : "strict",
|
||||
}),
|
||||
signal,
|
||||
);
|
||||
@@ -259,14 +259,23 @@ const readElfMetadata = async (
|
||||
),
|
||||
},
|
||||
});
|
||||
if (parsed.value.architecture !== "mips" || parsed.value.mips.elfClass !== 32)
|
||||
return parsed;
|
||||
if (!isMips32) return parsed;
|
||||
const { sectionTruncation } = ranges.value;
|
||||
if (sectionTruncation?.kind === "truncated_section_payload")
|
||||
return err(sectionTruncation.reason);
|
||||
const declarations = await readMipsElfMetadata(
|
||||
handle,
|
||||
parsed.value.mips,
|
||||
() => throwIfTargetResolutionCancelled(signal),
|
||||
);
|
||||
if (!declarations.ok) return declarations;
|
||||
if (sectionTruncation !== undefined) {
|
||||
const admitsTruncatedSectionTable =
|
||||
sectionTruncation.kind === "truncated_section_table" &&
|
||||
isRecordlessLegacyMipsExecHeader(parsed.value.mips) &&
|
||||
declarations.value.abiFlags === null;
|
||||
if (!admitsTruncatedSectionTable) return err(sectionTruncation.reason);
|
||||
}
|
||||
return ok({
|
||||
...parsed.value,
|
||||
mips: {
|
||||
|
||||
Reference in new issue
Block a user