Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(851)

Side by Side Diff: sandbox/linux/integration_tests/bpf_dsl_seccomp_unittest.cc

Issue 2512073003: Aarch64 buildfix. (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <errno.h> 5 #include <errno.h>
6 #include <fcntl.h> 6 #include <fcntl.h>
7 #include <pthread.h> 7 #include <pthread.h>
8 #include <sched.h> 8 #include <sched.h>
9 #include <signal.h> 9 #include <signal.h>
10 #include <stddef.h> 10 #include <stddef.h>
(...skipping 1977 matching lines...) Expand 10 before | Expand all | Expand 10 after
1988 !IS_SECCOMP_EVENT(status)) { 1988 !IS_SECCOMP_EVENT(status)) {
1989 BPF_ASSERT_NE(-1, ptrace(PTRACE_CONT, pid, NULL, NULL)); 1989 BPF_ASSERT_NE(-1, ptrace(PTRACE_CONT, pid, NULL, NULL));
1990 continue; 1990 continue;
1991 } 1991 }
1992 1992
1993 unsigned long data; 1993 unsigned long data;
1994 BPF_ASSERT_NE(-1, ptrace(PTRACE_GETEVENTMSG, pid, NULL, &data)); 1994 BPF_ASSERT_NE(-1, ptrace(PTRACE_GETEVENTMSG, pid, NULL, &data));
1995 BPF_ASSERT_EQ(kTraceData, data); 1995 BPF_ASSERT_EQ(kTraceData, data);
1996 1996
1997 regs_struct regs; 1997 regs_struct regs;
1998 BPF_ASSERT_NE(-1, ptrace(PTRACE_GETREGS, pid, NULL, &regs)); 1998 BPF_ASSERT_NE(-1, ptrace(static_cast<enum __ptrace_request>(PTRACE_GETREGS), pid, NULL, &regs));
Jorge Lucangeli Obes 2016/11/18 19:54:00 This line is longer than 80 cols.
1999 switch (SECCOMP_PT_SYSCALL(regs)) { 1999 switch (SECCOMP_PT_SYSCALL(regs)) {
2000 case __NR_write: 2000 case __NR_write:
2001 // Skip writes to stdout, make it return kExpectedReturnValue. Allow 2001 // Skip writes to stdout, make it return kExpectedReturnValue. Allow
2002 // writes to stderr so that BPF_ASSERT messages show up. 2002 // writes to stderr so that BPF_ASSERT messages show up.
2003 if (SECCOMP_PT_PARM1(regs) == STDOUT_FILENO) { 2003 if (SECCOMP_PT_PARM1(regs) == STDOUT_FILENO) {
2004 BPF_ASSERT_NE(-1, SetSyscall(pid, &regs, -1)); 2004 BPF_ASSERT_NE(-1, SetSyscall(pid, &regs, -1));
2005 SECCOMP_PT_RESULT(regs) = kExpectedReturnValue; 2005 SECCOMP_PT_RESULT(regs) = kExpectedReturnValue;
2006 BPF_ASSERT_NE(-1, ptrace(PTRACE_SETREGS, pid, NULL, &regs)); 2006 BPF_ASSERT_NE(-1, ptrace(static_cast<enum __ptrace_request>(PTRACE_SET REGS), pid, NULL, &regs));
Jorge Lucangeli Obes 2016/11/18 19:54:00 And this one.
2007 } 2007 }
2008 break; 2008 break;
2009 2009
2010 case __NR_kill: 2010 case __NR_kill:
2011 // Rewrite to exit(kExpectedReturnValue). 2011 // Rewrite to exit(kExpectedReturnValue).
2012 BPF_ASSERT_NE(-1, SetSyscall(pid, &regs, __NR_exit)); 2012 BPF_ASSERT_NE(-1, SetSyscall(pid, &regs, __NR_exit));
2013 SECCOMP_PT_PARM1(regs) = kExpectedReturnValue; 2013 SECCOMP_PT_PARM1(regs) = kExpectedReturnValue;
2014 BPF_ASSERT_NE(-1, ptrace(PTRACE_SETREGS, pid, NULL, &regs)); 2014 BPF_ASSERT_NE(-1, ptrace(static_cast<enum __ptrace_request>(PTRACE_SETRE GS), pid, NULL, &regs));
Jorge Lucangeli Obes 2016/11/18 19:54:00 And this one too.
2015 break; 2015 break;
2016 2016
2017 default: 2017 default:
2018 // Allow all other syscalls. 2018 // Allow all other syscalls.
2019 break; 2019 break;
2020 } 2020 }
2021 2021
2022 BPF_ASSERT_NE(-1, ptrace(PTRACE_CONT, pid, NULL, NULL)); 2022 BPF_ASSERT_NE(-1, ptrace(PTRACE_CONT, pid, NULL, NULL));
2023 } 2023 }
2024 } 2024 }
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
2256 BPF_ASSERT_EQ(ENOSYS, errno); 2256 BPF_ASSERT_EQ(ENOSYS, errno);
2257 2257
2258 BPF_ASSERT_EQ(-1, syscall(__NR_setgid, 300)); 2258 BPF_ASSERT_EQ(-1, syscall(__NR_setgid, 300));
2259 BPF_ASSERT_EQ(EPERM, errno); 2259 BPF_ASSERT_EQ(EPERM, errno);
2260 } 2260 }
2261 2261
2262 } // namespace 2262 } // namespace
2263 2263
2264 } // namespace bpf_dsl 2264 } // namespace bpf_dsl
2265 } // namespace sandbox 2265 } // namespace sandbox
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698