Repository navigation
drm: stop obfuscating the strings, and gate PRs on a warning-free build - #66
Merged
Merged
Conversation
`gndrm-obf` and `gndrm-obf-macros` XOR-encoded every message literal and decoded
it into a stack buffer at the use site, so `strings` over a shipped artifact
found nothing. Both crates are deleted, with every dependency on them. The log
text is a plain literal again, and that is the point: a diagnostic a user can
grep out of the .so is worth more than one they cannot.
Rust call sites — 585 `gndrm_obf::obf!` and one `obfc!`, across the ICD shim,
the daemon and the app side:
- a literal with no placeholders is the literal;
- anything else is the message and its arguments, e.g.
`logf!("proxy pool: fourcc 0x{:x} route={}", …)`.
The log macros do the formatting now: `logf!`, `logi!` and `log_reason!` take
`$($arg:tt)*` and pass them to `format_args!`, so a call site is the message and
not a wrapper around it. `log_reason!` still owns the line, because it stores it
as the reported reason.
`log.rs`'s logcat tag was the one `obfc!` use — six gate tags decoded into a
NUL-terminated buffer. They are `c"…"` literals now, and the `tag!` arm takes an
expression rather than a string literal.
Four `Display` impls were rewritten to write the message straight
(`write!(f, "{layout} (env)")`) instead of formatting into a `String` first.
C side: `tools/obf-shim.py` rewrote each `LOG(...)` site in the LD_PRELOAD shim
into an XOR-decode at build time, and `build-shim.sh` compiled the generated copy
from `target/shim/gen/`. The script is deleted and the shim compiles its source
as written, so the shipped `libgndrm_shim.so` now carries `intercepting %s for %s
in %s` and the rest.
Manifests: the two crate entries leave the workspace, and the dependency lines
(and the comments explaining why the obfuscation existed) leave
`gndrm-android`, `gndrm-daemon`, `gndrm-lsfg`, `gndrm-uapi` and `icd_shim`.
Text that described the removed behaviour: the log module docs said the tag is
decoded at runtime; `gndrm-daemon`'s two logger thunks explained a "stack
decode"; `asc.rs` said its refusal labels are owned because the literals are
obfuscated; `docs/performance/05` justified "no heap" by pointing at
`gndrm-obf/src/lib.rs:46`. All four now state what the code does. The historical
diff hunks in 05 and 06 are left as they were — they record patches as applied.
`THIRD_PARTY_NOTICES` listed "the obfuscation crates" in the licence scope; it
lists the ICD shim instead.
Verified: `cargo clippy --workspace --all-targets -- -D warnings` clean,
`cargo test --workspace` 340 passed / 0 failed across 30 suites,
`tools/build-android.sh` green through the export allowlist and undefined-symbol
audit, `tools/build-shim.sh android` green. `strings` on both rebuilt libraries
now shows the log text.
`cargo build --workspace --all-targets` under `RUSTFLAGS=-D warnings`, then `cargo clippy --workspace --all-targets -- -D warnings`. Both `--locked`. `--all-targets` is the part that earns its keep: it compiles the test and bench targets too, so a change that only breaks a test build fails the gate instead of failing at review. No artifacts are produced or uploaded — the job's status is the output. Host build only. `tools/build-android.sh` and `build-shim.sh android` need the NDK, the gamescope termux prefix (`GAMESCOPE_TERMUX_PREFIX`) and the export / undefined-symbol audits that read the cross build's output, which a hosted runner cannot stand up; the workflow header says so, so nobody reads a green run as covering the shipped artifacts. No `cargo fmt --check`: the tree is hand-formatted, and a fmt gate would fail every PR. Verified from a cold target directory, which is the closest local proxy for a first CI run: `cargo build` rc 0 with 0 warnings, `cargo clippy` rc 0, and actionlint 1.7.12 reports 0 parse errors and 0 errors.
The first run failed at link time, not in the code:
rust-lld: error: unable to find library -lvulkan
rust-lld: error: unable to find library -lwayland-client
error: could not compile `gn-utils` (bin "gn-device-probe" test)
`gn-utils` (and `icd_shim/src/x11.rs`) carry `#[link]` attributes for the host's
Vulkan, wayland and xcb, so `--all-targets` on a bare runner cannot link its
binaries. The runner now installs `libvulkan-dev`, `libwayland-dev`,
`libxcb1-dev`, `libxcb-dri3-dev`, `libxcb-present-dev` and `libxcb-sync-dev`
before building — the same set a developer machine has to have.
Verified in a clean `ubuntu:24.04` container with only those packages added,
which is what the runner is: `cargo build --workspace --all-targets --locked`
under `RUSTFLAGS=-D warnings` rc 0 with no warnings, and
`cargo clippy --workspace --all-targets --locked -- -D warnings` rc 0, both with
the current stable toolchain (1.99.1) rather than the local 1.98.0. actionlint
reports 0 errors.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two commits on top of
master, both structural: the codebase stops hiding its own text, and a PR gate starts checking that it builds clean.1. String obfuscation is gone (
1c7ec59)gndrm-obfandgndrm-obf-macrosXOR-encoded every message literal and decoded it into a stack buffer at the use site, sostringsover a shipped artifact found nothing. The project is open source; a diagnostic a user can pull out of the.sois worth more than one they cannot.Both crates are deleted, with every dependency on them. 585
gndrm_obf::obf!and oneobfc!across the ICD shim, the daemon and the app side collapse to the message they carried:The log macros absorb the formatting:
logf!,logi!andlog_reason!take$($arg:tt)*and pass them toformat_args!, so a call site readslogf!("proxy pool: fourcc 0x{:x} route={}", …)instead of wrapping a wrapper.log_reason!still builds and stores the line, because it is reported as the reason a process got no driver.log.rs's logcat tag was the singleobfc!use — six gate tags decoded into a NUL-terminated buffer. They arec"…"literals now, andtag!takes an expression rather than a string literal.Four
Displayimpls were formatting into aStringand writing that; they write the message straight now.C side:
tools/obf-shim.pyrewrote eachLOG(...)site in the LD_PRELOAD shim at build time andbuild-shim.shcompiled the generated copy fromtarget/shim/gen/. The script is deleted; the shim compiles its source as written, so the shippedlibgndrm_shim.socarriesintercepting %s for %s in %sand the rest.Manifests: the crate entries leave the workspace, and the dependency lines — with the comments that explained why the obfuscation existed — leave
gndrm-android,gndrm-daemon,gndrm-lsfg,gndrm-uapiandicd_shim.Prose that described the removed behaviour is corrected: the log module docs, the daemon's two logger thunks ("stack decode"),
asc.rs's refusal labels, anddocs/performance/05's "no heap" row, which justified itself by pointing atgndrm-obf/src/lib.rs:46. The historical diff hunks in05and06are left alone — they record patches as applied.THIRD_PARTY_NOTICESlisted "the obfuscation crates" in the licence scope; it lists the ICD shim.2. A PR gate that builds with warnings as errors (
9aa1364)--all-targetsis the part that earns its keep: test and bench targets compile too, so a change that only breaks a test build fails the gate rather than the reviewer. No artifacts, no report — the job status is the output.Host build only, and the workflow header says why:
tools/build-android.shandbuild-shim.sh androidneed the NDK, the gamescope termux prefix and the export / undefined-symbol audits that read the cross build's output. Nocargo fmt --checkeither — the tree is hand-formatted.Verified
From a cold target directory, which is the closest local proxy for a first CI run:
The gate itself runs green on this PR, third commit and after:
host build, no warnings—cargo buildandcargo clippyboth finished with no output beyond the compile lines, run 42954604587.Its first run failed, and the failure is why the workflow now installs six dev packages:
gn-utilsandicd_shim/src/x11.rscarry#[link]attributes for the host's Vulkan, wayland and xcb, so on a bare runner the build died at link time —unable to find library -lvulkan/-lwayland-client— rather than in the code. Fixed in49bcdb3, verified in a cleanubuntu:24.04container that had only those packages added.And the point of part 1, in the rebuilt libraries:
Not in this PR
strings, but nothing ran on hardware.cargo testin CI yet. One line in the workflow when it is wanted; it was scoped to "build with no warnings".THIRD_PARTY_NOTICEScopyright line still names Utkarsh Dalal whileREADMEandCargo.tomlname Joshua Tam and GameNative Inc. after licence: GPL-3.0-or-later, and both copyright holders named #52. Left alone rather than change a holder inside a refactor.