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 |
|
I think the assumption was that if one file couldn't be deleted, surely the other ones couldn't be either, since the filesystem was read-only. This is because I can see the logic behind erasing everything we can rather than aborting, but I wonder if it would be worth using tl;dr: I'll probably merge this and add a |
Indeed. Because this only known to be happening in some App Qubes, where
Old output (existing version): New output (when using So the output is worse. That can be fixed but my thinking was it's more code that in fact doesn't effectively accomplish anything more. |
|
Hey, thanks for the responses. I'm dealing with an NVMe SSD that is failing at the moment and am writing this off of an old spare computer that doesn't have all my dev tooling set up. I think Yeah, fair point about the I was thinking in terms of the output that we could potentially collect failed files in an array and report them to the user at the end. Then link to the wiki once at the bottom. Or log one line for each failed attempt during iteration instead of storing in an array. Either way, I can squelch the success line since it is misleading. Open to thoughts about that. I'd be willing to write the code for this once I've dealt with this other less fun stuff IRL, if it's something you all would be interested in. If not, that's cool too. I respect this project and want to help out. |
|
@maybebyte We're definitely interested in this :) Thanks for your submissions, they're quite helpful. |
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.