diff options
| author | Joakim Hulthe <joakim@hulthe.net> | 2025-08-04 17:19:23 +0200 |
|---|---|---|
| committer | Joakim Hulthe <joakim.hulthe@mullvad.net> | 2025-08-19 13:09:48 +0200 |
| commit | 6c86de2fd5a59671bc0978bdb4913faa7bd89075 (patch) | |
| tree | 9085f18f6a88fd4c4fe3c3fb307a9930abeac02c | |
| parent | 4a604469403d4cad38c6728797ec671cd67e0b3c (diff) | |
| download | mullvadvpn-6c86de2fd5a59671bc0978bdb4913faa7bd89075.tar.xz mullvadvpn-6c86de2fd5a59671bc0978bdb4913faa7bd89075.zip | |
Check eslogger PIDs before using them
| -rw-r--r-- | talpid-core/src/split_tunnel/macos/process.rs | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/talpid-core/src/split_tunnel/macos/process.rs b/talpid-core/src/split_tunnel/macos/process.rs index 9eed8bba9d..31e00b8df9 100644 --- a/talpid-core/src/split_tunnel/macos/process.rs +++ b/talpid-core/src/split_tunnel/macos/process.rs @@ -353,7 +353,10 @@ impl ProcessStates { impl InnerProcessStates { fn handle_message(&mut self, msg: ESMessage) { - let pid = msg.process.audit_token.pid; + let Some(pid) = msg.process.audit_token.checked_pid() else { + log::trace!("eslogger returned bad pid: {msg:?}"); + return; + }; match msg.event { ESEvent::Fork(evt) => self.handle_fork(pid, msg.process.executable.path, evt), @@ -365,7 +368,10 @@ impl InnerProcessStates { // For new processes, inherit all exclusion state from the parent, if there is one. // Otherwise, look up excluded paths fn handle_fork(&mut self, parent_pid: pid_t, exec_path: PathBuf, msg: ESForkEvent) { - let pid = msg.child.audit_token.pid; + let Some(pid) = msg.child.audit_token.checked_pid() else { + log::trace!("eslogger returned bad pid: {msg:?}"); + return; + }; if self.processes.contains_key(&pid) { log::error!("Conflicting pid! State already contains {pid}"); @@ -524,6 +530,13 @@ struct ESMessage { process: ESProcess, } +impl ESAuditToken { + /// Check that `pid` is positive and return it. + pub fn checked_pid(&self) -> Option<pid_t> { + (self.pid > 0).then_some(self.pid) + } +} + fn parse_eslogger_error(stderr_str: &str) -> Option<Error> { if stderr_str.contains("ES_NEW_CLIENT_RESULT_ERR_NOT_PERMITTED") { Some(Error::NeedFullDiskPermissions) |
