Port the MediaTek audio firmware path exception from workflow shell
scripting into a declarative stage-1 compatibility rule.
Upstream kernel 5.10.226+ introduced name_contains_dotdot() in
drivers/base/firmware_loader/main.c to prevent path traversal in
firmware requests. On MediaTek Dimensity and Helio platforms, the
tfa98xx speaker codec requests firmware via relative traversal paths
(e.g. '../../odm/firmware/tfa98xx.cnt'), which causes the upstream
check to fail with -EINVAL (-22), leaving the codec uninitialized
and breaking speaker audio.
Add rule 'mtk-tfa98xx-firmware-dotdot-exception':
- Target: android12-5.10 (sublevel >= 226) on MediaTek SoCs
(soc=("dimensity*", "helio*")).
- Uses Composite edit:
1. InsertRelative: injects name_is_confined_vendor_firmware() above
name_contains_dotdot().
2. ReplaceRegex: gates the dotdot failure condition on the helper.
- Gated by when: only runs if name_contains_dotdot() is present and
the helper has not already been added.
This confines the traversal exception strictly to fixed vendor firmware
roots ('../../odm/firmware/', '../odm/firmware/') while ensuring any
further traversal attempts are still rejected, preserving upstream
security defense-in-depth without disabling the guard kernel-wide.
Fixes#287
Replace the per-KMI fake_patched/fake_patched2/fake_patched_expand bash
flags (grep/sed/perl one-liners) with a declarative, idempotent Python
compatibility layer:
- scripts/fix_susfs_compatibility_patches.py: stage1/stage2 driver with
Target (KMI + sublevel range) matching, Rule-based dispatch, and
comment/string-literal-aware brace scanning (BraceScope) for safely
scoping edits to a single function body.
- scripts/README.md: full usage guide and Edit-type reference.
- tests/test_susfs_compat.py, tests/test_rules_integration.py: unit and
integration coverage for the primitives and the real RULES tuple.
Workflow changes:
- stage 1 now runs before the main SUSFS patch, stage 2 after it;
`patch -p1` invocations remain in the workflow shell, never in Python.
- main patch is applied via dry-run-then-apply instead of applying for
real and patching over .rej files.
- fold_fixup_entries.patch application stays in-workflow, gated on the
same header-presence check as before.
- compat state is written to $RUNNER_TEMP, keyed per KMI, so stage 2
can tell which stage-1 edits actually fired without relying on
remembered line numbers/offsets.
All existing fake_patched*-gated edits were ported to Rule entries with
their original sublevel gates preserved (zswap <=57, dma-buf <=92,
vma-block-expand/pagemap-locals <=30, swap-slots >=123). Previously
ungated edits (android14-6.1 trace/hooks/blk.h, android13-5.15
trace/hooks/mm.h, dma-buf on android14-6.1) were added as new Rules
since they existed in bash but were missing from the first pass of the
Python port.