Commit 7a612916 authored by Drew Davenport's avatar Drew Davenport Committed by Commit Bot

sandbox: Allow kcmp for amd gpu sandbox

mesa 19.3.4 and 20.0.x and later calls kcmp

Change-Id: I2616b5dfba2bed9a348a711c2e2b9c97598f64de
Bug: none
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2108797
Commit-Queue: Drew Davenport <ddavenport@chromium.org>
Reviewed-by: default avatarJorge Lucangeli Obes <jorgelo@chromium.org>
Cr-Commit-Position: refs/heads/master@{#751845}
parent 83df35b1
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#include "services/service_manager/sandbox/linux/bpf_cros_amd_gpu_policy_linux.h" #include "services/service_manager/sandbox/linux/bpf_cros_amd_gpu_policy_linux.h"
#include <fcntl.h> #include <fcntl.h>
#include <linux/kcmp.h>
#include <sys/socket.h> #include <sys/socket.h>
// Some arch's (arm64 for instance) unistd.h don't pull in symbols used here // Some arch's (arm64 for instance) unistd.h don't pull in symbols used here
...@@ -17,6 +18,7 @@ ...@@ -17,6 +18,7 @@
#include "sandbox/linux/bpf_dsl/bpf_dsl.h" #include "sandbox/linux/bpf_dsl/bpf_dsl.h"
#include "sandbox/linux/system_headers/linux_syscalls.h" #include "sandbox/linux/system_headers/linux_syscalls.h"
using sandbox::bpf_dsl::AllOf;
using sandbox::bpf_dsl::Allow; using sandbox::bpf_dsl::Allow;
using sandbox::bpf_dsl::Arg; using sandbox::bpf_dsl::Arg;
using sandbox::bpf_dsl::Error; using sandbox::bpf_dsl::Error;
...@@ -48,6 +50,17 @@ ResultExpr CrosAmdGpuProcessPolicy::EvaluateSyscall(int sysno) const { ...@@ -48,6 +50,17 @@ ResultExpr CrosAmdGpuProcessPolicy::EvaluateSyscall(int sysno) const {
return If(domain == AF_UNIX, Allow()).Else(Error(EPERM)); return If(domain == AF_UNIX, Allow()).Else(Error(EPERM));
} }
#endif #endif
case __NR_kcmp: {
const Arg<int> pid1(0);
const Arg<int> pid2(1);
const Arg<int> type(2);
const int policy_pid = GetPolicyPid();
// Only allowed when comparing file handles for the calling thread.
return If(AllOf(pid1 == policy_pid, pid2 == policy_pid,
type == KCMP_FILE),
Allow())
.Else(Error(EPERM));
}
default: default:
// Default to the generic GPU policy. // Default to the generic GPU policy.
return GpuProcessPolicy::EvaluateSyscall(sysno); return GpuProcessPolicy::EvaluateSyscall(sysno);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment