include/strawberry/platform_process.hpp answers what /proc answers on Linux: running PIDs (proc_listallpids), executable path (proc_pidpath), parent and start time (sysctl KERN_PROC_PID, readable for every process), argv (KERN_PROCARGS2) and a boot id (kern.bootsessionuuid). A process is identified by its start time in microseconds since the epoch plus the boot id, so node ids survive PID reuse as on Linux. It is header-only, so the per-test source lists stay as they are. Users on macOS: resolve_process_ref (default root), the pipeline's image hashing and exec-decision actor, and YaraScanner::scan_process (scans the image by path). A synthetic procfs root still takes the procfs code, so the existing procfs tests run on macOS too. The resource governor samples Mach/sysctl on macOS: own CPU from getrusage, RSS from task_info, load from getloadavg, available memory from host_statistics64 (free + inactive + purgeable + speculative). The behavior engine knows macOS debuggers (debugserver, dtrace) and kext loaders (kernelmanagerd, kmutil), and macOS temp and Downloads paths count as drop locations. The Linux lists are unchanged. The KERN_PROCARGS2 parser is portable: a property test (exact argv recovery, truncation never invents data, total on junk) and the fuzz_procargs target run on every platform. test_platform_process checks the live helpers against this process; the daemon test reads the stopped state through sysctl on macOS. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
19 lines
697 B
C++
19 lines
697 B
C++
// KERN_PROCARGS2 buffers (macOS process argv). A process controls its own
|
|
// argv and environment, so the daemon parses attacker-influenced bytes.
|
|
#include "strawberry/platform_process.hpp"
|
|
|
|
#include <cstdint>
|
|
#include <cstdlib>
|
|
#include <string_view>
|
|
|
|
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
|
|
const std::string_view buffer(reinterpret_cast<const char*>(data), size);
|
|
const auto cmdline = strawberry::platform::procargs2_cmdline(buffer);
|
|
if (cmdline.size() > strawberry::platform::kMaxCmdlineBytes || cmdline.size() > size) {
|
|
std::abort();
|
|
}
|
|
if (!cmdline.empty() && cmdline.back() == ' ') {
|
|
std::abort();
|
|
}
|
|
return 0;
|
|
}
|