From 2221c93bbcbb5817b79159be588d3114572aa8a9 Mon Sep 17 00:00:00 2001 From: Russell Hancox Date: Thu, 22 Oct 2020 13:41:31 -0400 Subject: [PATCH] santa-driver: Fix some new Xcode 12 warnings (#502) The ossharedptr-misuse warning is generated from within system headers and I couldn't find a simple way to prevent that other than disabling the warning entirely. We don't use OSSharedPtr directly anyway. --- Source/santa_driver/BUILD | 1 + Source/santa_driver/SantaDecisionManager.cc | 12 ++++++------ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/Source/santa_driver/BUILD b/Source/santa_driver/BUILD index 4b1695084..ac492144d 100644 --- a/Source/santa_driver/BUILD +++ b/Source/santa_driver/BUILD @@ -23,6 +23,7 @@ cc_library( copts = [ "-mkernel", "-fapple-kext", + "-Wno-ossharedptr-misuse", "-I__BAZEL_XCODE_SDKROOT__/System/Library/Frameworks/Kernel.framework/Headers", ], defines = [ diff --git a/Source/santa_driver/SantaDecisionManager.cc b/Source/santa_driver/SantaDecisionManager.cc index 5d2238011..3163b3aec 100644 --- a/Source/santa_driver/SantaDecisionManager.cc +++ b/Source/santa_driver/SantaDecisionManager.cc @@ -616,7 +616,7 @@ int SantaDecisionManager::VnodeCallback(const kauth_cred_t cred, pid_t pid = proc_pid(proc); pid_t ppid = proc_ppid(proc); // pid_t is 32-bit; pid is in upper 32 bits, ppid in lower. - uint64_t val = ((uint64_t)pid << 32) | (ppid & 0xFFFFFFFF); + uint64_t val = ((uint64_t)pid << 32) | ((uint64_t)ppid & 0xFFFFFFFF); vnode_pid_map_->set(vnode_id, val); if (returnedAction == ACTION_RESPOND_ALLOW_COMPILER && ppid != 0) { // Do some additional bookkeeping for compilers: @@ -674,8 +674,8 @@ void SantaDecisionManager::FileOpCallback( uint64_t val = vnode_pid_map_->get(vnode_id); if (val) { // pid_t is 32-bit, so pid is in upper 32 bits, ppid in lower. - message->pid = (val >> 32); - message->ppid = (val & ~0xFFFFFFFF00000000); + message->pid = (pid_t)(val >> 32); + message->ppid = (pid_t)(val & ~0xFFFFFFFF00000000); } PostToLogQueue(message); @@ -816,7 +816,7 @@ extern "C" int vnode_scope_callback( // We only care about regular files. if (vnode_vtype(vp) != VREG) return KAUTH_RESULT_DEFER; - if ((action & KAUTH_VNODE_EXECUTE) && !(action & KAUTH_VNODE_ACCESS)) { // NOLINT + if ((action & (int)KAUTH_VNODE_EXECUTE) && !(action & (int)KAUTH_VNODE_ACCESS)) { sdm->IncrementListenerInvocations(); int result = sdm->VnodeCallback(credential, reinterpret_cast(arg0), @@ -824,9 +824,9 @@ extern "C" int vnode_scope_callback( reinterpret_cast(arg3)); sdm->DecrementListenerInvocations(); return result; - } else if (action & KAUTH_VNODE_WRITE_DATA || action & KAUTH_VNODE_APPEND_DATA) { + } else if (action & (int)KAUTH_VNODE_WRITE_DATA || action & (int)KAUTH_VNODE_APPEND_DATA) { sdm->IncrementListenerInvocations(); - if (!(action & KAUTH_VNODE_ACCESS)) { // NOLINT + if (!(action & (int)KAUTH_VNODE_ACCESS)) { auto vnode_id = sdm->GetVnodeIDForVnode(reinterpret_cast(arg0), vp); sdm->RemoveFromCache(vnode_id); }