From ed0086eb66f49f54fd3a8502fb781554131ff3a9 Mon Sep 17 00:00:00 2001 From: Christian Blichmann Date: Mon, 14 Sep 2020 01:18:09 -0700 Subject: [PATCH] Fix dynamic binary startup on PPC and newer glibc (> 2.19) This allows the `_llseek` syscall when it is defined. PiperOrigin-RevId: 331498182 Change-Id: I2760b264e3a82000b38d278a9c280501a3dbc724 --- sandboxed_api/sandbox2/policybuilder.cc | 6 +++++- sandboxed_api/sandbox2/stack_trace.cc | 3 +++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/sandboxed_api/sandbox2/policybuilder.cc b/sandboxed_api/sandbox2/policybuilder.cc index c0bfd41..678677d 100644 --- a/sandboxed_api/sandbox2/policybuilder.cc +++ b/sandboxed_api/sandbox2/policybuilder.cc @@ -533,7 +533,11 @@ PolicyBuilder& PolicyBuilder::AllowStaticStartup() { PolicyBuilder& PolicyBuilder::AllowDynamicStartup() { AllowRead(); AllowStat(); - AllowSyscalls({__NR_lseek, __NR_close, __NR_munmap}); + AllowSyscalls({__NR_lseek, +#ifdef __NR__llseek + __NR__llseek, // Newer glibc on PPC +#endif + __NR_close, __NR_munmap}); AddPolicyOnSyscall(__NR_mprotect, { ARG_32(2), JEQ32(PROT_READ, ALLOW), diff --git a/sandboxed_api/sandbox2/stack_trace.cc b/sandboxed_api/sandbox2/stack_trace.cc index 868b89e..ef494b1 100644 --- a/sandboxed_api/sandbox2/stack_trace.cc +++ b/sandboxed_api/sandbox2/stack_trace.cc @@ -86,6 +86,9 @@ std::unique_ptr StackTracePeer::GetPolicy(pid_t target_pid, // libunwind .AllowSyscall(__NR_fstat) .AllowSyscall(__NR_lseek) +#ifdef __NR__llseek + .AllowSyscall(__NR__llseek) // Newer glibc on PPC +#endif .AllowSyscall(__NR_mincore) .AllowSyscall(__NR_mprotect) .AllowSyscall(__NR_munmap)