Skip to content

fix(remove-system.map): skip read-only files instead of aborting#373

Open
maybebyte wants to merge 1 commit into
Kicksecure:masterfrom
maybebyte:fix/remove-system-map-readonly-continue
Open

fix(remove-system.map): skip read-only files instead of aborting#373
maybebyte wants to merge 1 commit into
Kicksecure:masterfrom
maybebyte:fix/remove-system-map-readonly-continue

Conversation

@maybebyte

Copy link
Copy Markdown
Contributor

Summary

remove-system.map shreds System.map* files because they expose a kernel
symbol-to-address map useful for exploitation. The deletion loop aborts on
the first read-only match, so writable copies in other locations are left on
disk while the run still reports success.

Changes

  • Root cause: the read-only branch of the loop calls exit 0, which
    terminates the whole script on the first non-writable System.map (commonly
    /boot, which is often read-only). Later writable copies under /usr/src,
    /lib/modules, and / are then never shredded, and the Done. Success.
    summary is skipped even though the exit code reports success.
  • Replace exit 0 with continue so each read-only file is noted and the
    loop proceeds through the remaining locations. The exit code is unchanged.

Testing

  • Minimal reproduction of the loop's control flow: with exit 0 the run stops
    after the first read-only entry (no summary printed); with continue it
    processes the following writable entry and prints Done. Success.
  • shellcheck on the modified script: no new findings (only a pre-existing
    SC1091 info note on the unrelated source line).
  • No automated tests cover this script.

Notes for reviewers

  • Behavior delta: on systems where an early System.map (e.g. under /boot)
    is read-only, writable copies elsewhere that were previously skipped will now
    be shredded — the tool's intended behavior.

The read-only branch of the deletion loop calls `exit 0`, which
terminates the whole script on the first non-writable System.map. Later
writable copies (for example under /usr/src or /lib/modules) are then
never shredded, and the "Done. Success." summary is skipped while the
exit code still reports success -- a false all-clear that can leave a
kernel symbol map on disk.

Replace `exit 0` with `continue` so each read-only file is noted and the
loop proceeds to the remaining locations. The script's exit code is
unchanged, so callers are unaffected.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant