Repository navigation
Conversation
cmd_down runs as root and signalled whatever PID a stale pidfile named. After a crash or reboot that PID can be recycled by an unrelated process, so a bare kill hit an innocent process. Verify /proc/<pid>/comm matches the daemon name and the conf path appears in cmdline — the same identity the pkill fallback already required — before signalling. Stale, dead, and malformed pidfiles are still cleaned up.
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.
Summary
ap-mode.sh downruns as root (require_root) and signalled whatever PID its pidfiles named:Pidfiles outlive their daemons. After a hostapd/dnsmasq crash or an unclean reboot, the pidfile can name a PID since recycled by an unrelated process — a bare
killthen signals an innocent process as root. The adjacentpkill -ffallback already required the conf path in the process cmdline; the pidfile path skipped any identity check.New
kill_pidfilehelper verifies/proc/<pid>/commmatches the daemon name and the conf path appears in/proc/<pid>/cmdlinebefore signalling — the same identity thepkill -ffallback uses. Stale, dead, and malformed pidfiles are still removed, and a skip is logged so an operator can see the pidfile lied.Why this matters
cmd_downis invoked as root from the AP-mode systemd unit andodsflows; a recycled PID meanskilllands on an arbitrary system process.Regression coverage
ods/tests/test-ap-mode-stale-pid.sh(10 checks) drives the realcmd_downend-to-end under stubbedpkill/iptables/ip/nmcli:sleep) → process survives, pidfile removed, skip loggedtailcopy namedhostapd/dnsmasqso/proc/<pid>/commmatches) → killedkill "$(cat …)"remains; both daemons route throughkill_pidfileValidation
upstream/public-beta: the recycled-PID scenario kills the innocentsleep— defect reproduced; static checks fail as expected.bash -n+shellcheck -S errorclean; existingtests/test-ap-mode.shstill passes.Overlap check
ap-mode has several open PRs — #4273/#2406/#2791 (atomic state writes), #3686 (pipefail capability match), #3620 (activation rollback), #5774 (bounded iptables teardown), #6086/#5623 (netmask→prefix), #3829 (exec bits), #3119 (state file checks). None touch the pidfile kill path; this scope is disjoint.
Notes / limitations
/proc-based, matching the script's existingrequire_linuxgate.pkill -ffallback is retained unchanged — it catches daemons that lost their pidfile entirely.