fix(remove-system.map): skip read-only files instead of aborting#373
fix(remove-system.map): skip read-only files instead of aborting#373maybebyte wants to merge 1 commit into
Conversation
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.
|
If the first match cannot be deleted what's the point of attempting to delete others? |
|
@adrelanos Let me see if I understand what you're saying here. You're saying that, if even one Since we are running this service as root, semantics of My thought process was that it isn't necessarily better to abort and keep other copies around. Better to reduce the total number of info leaks, even if it's not perfect. I didn't want to make invasive changes to try and ensure purity on a first pass. I also find it a little surprising on the user end. If I have a tool that removes |
Summary
remove-system.mapshredsSystem.map*files because they expose a kernelsymbol-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
exit 0, whichterminates 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 theDone. Success.summary is skipped even though the exit code reports success.
exit 0withcontinueso each read-only file is noted and theloop proceeds through the remaining locations. The exit code is unchanged.
Testing
exit 0the run stopsafter the first read-only entry (no summary printed); with
continueitprocesses the following writable entry and prints
Done. Success.shellcheckon the modified script: no new findings (only a pre-existingSC1091 info note on the unrelated
sourceline).Notes for reviewers
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.