| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "sandbox/linux/seccomp-bpf-helpers/syscall_parameters_restrictions.h" | 5 #include "sandbox/linux/seccomp-bpf-helpers/syscall_parameters_restrictions.h" |
| 6 | 6 |
| 7 #include <errno.h> | 7 #include <errno.h> |
| 8 #include <sched.h> | 8 #include <sched.h> |
| 9 #include <sys/resource.h> | 9 #include <sys/resource.h> |
| 10 #include <sys/syscall.h> | 10 #include <sys/syscall.h> |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 switch (sysno) { | 220 switch (sysno) { |
| 221 case __NR_prlimit64: | 221 case __NR_prlimit64: |
| 222 return RestrictPrlimit64(getpid()); | 222 return RestrictPrlimit64(getpid()); |
| 223 default: | 223 default: |
| 224 return Allow(); | 224 return Allow(); |
| 225 } | 225 } |
| 226 } | 226 } |
| 227 }; | 227 }; |
| 228 | 228 |
| 229 BPF_TEST_C(ParameterRestrictions, prlimit64_allowed, RestrictPrlimit64Policy) { | 229 BPF_TEST_C(ParameterRestrictions, prlimit64_allowed, RestrictPrlimit64Policy) { |
| 230 BPF_ASSERT_EQ(0, syscall(__NR_prlimit64, 0, RLIMIT_AS, NULL, NULL)); | 230 BPF_ASSERT_EQ(0, sys_prlimit64(0, RLIMIT_AS, NULL, NULL)); |
| 231 BPF_ASSERT_EQ(0, syscall(__NR_prlimit64, getpid(), RLIMIT_AS, NULL, NULL)); | 231 BPF_ASSERT_EQ(0, sys_prlimit64(getpid(), RLIMIT_AS, NULL, NULL)); |
| 232 } | 232 } |
| 233 | 233 |
| 234 BPF_DEATH_TEST_C(ParameterRestrictions, | 234 BPF_DEATH_TEST_C(ParameterRestrictions, |
| 235 prlimit64_crash_not_self, | 235 prlimit64_crash_not_self, |
| 236 DEATH_SEGV_MESSAGE(sandbox::GetErrorMessageContentForTests()), | 236 DEATH_SEGV_MESSAGE(sandbox::GetErrorMessageContentForTests()), |
| 237 RestrictPrlimit64Policy) { | 237 RestrictPrlimit64Policy) { |
| 238 const pid_t kInitPID = 1; | 238 const pid_t kInitPID = 1; |
| 239 BPF_ASSERT_NE(kInitPID, getpid()); | 239 BPF_ASSERT_NE(kInitPID, getpid()); |
| 240 syscall(__NR_prlimit64, kInitPID, RLIMIT_AS, NULL, NULL); | 240 sys_prlimit64(kInitPID, RLIMIT_AS, NULL, NULL); |
| 241 } | 241 } |
| 242 | 242 |
| 243 } // namespace | 243 } // namespace |
| 244 | 244 |
| 245 } // namespace sandbox | 245 } // namespace sandbox |
| OLD | NEW |