| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 <fcntl.h> | 8 #include <fcntl.h> |
| 9 #include <fcntl.h> | 9 #include <fcntl.h> |
| 10 #include <linux/net.h> | 10 #include <linux/net.h> |
| (...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 354 #if !defined(GRND_NONBLOCK) | 354 #if !defined(GRND_NONBLOCK) |
| 355 #define GRND_NONBLOCK 1 | 355 #define GRND_NONBLOCK 1 |
| 356 #endif | 356 #endif |
| 357 | 357 |
| 358 ResultExpr RestrictGetRandom() { | 358 ResultExpr RestrictGetRandom() { |
| 359 const Arg<unsigned int> flags(2); | 359 const Arg<unsigned int> flags(2); |
| 360 const unsigned int kGoodFlags = GRND_NONBLOCK; | 360 const unsigned int kGoodFlags = GRND_NONBLOCK; |
| 361 return If((flags & ~kGoodFlags) == 0, Allow()).Else(CrashSIGSYS()); | 361 return If((flags & ~kGoodFlags) == 0, Allow()).Else(CrashSIGSYS()); |
| 362 } | 362 } |
| 363 | 363 |
| 364 ResultExpr RestrictPrlimitToGetrlimit(pid_t target_pid) { |
| 365 const Arg<pid_t> pid(0); |
| 366 const Arg<uintptr_t> new_limit(2); |
| 367 // Only allow 'get' operations, and only for the current process. |
| 368 return If(AllOf(new_limit == 0, AnyOf(pid == 0, pid == target_pid)), Allow()) |
| 369 .Else(Error(EPERM)); |
| 370 } |
| 371 |
| 364 } // namespace sandbox. | 372 } // namespace sandbox. |
| OLD | NEW |