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

Side by Side Diff: sandbox/linux/seccomp-bpf-helpers/syscall_parameters_restrictions.cc

Issue 2536103002: Linux Sandbox: Whitelist prlimit64 when used as getrlimit (Closed)
Patch Set: Created 4 years 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 | « sandbox/linux/seccomp-bpf-helpers/syscall_parameters_restrictions.h ('k') | 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 (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
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.
OLDNEW
« no previous file with comments | « sandbox/linux/seccomp-bpf-helpers/syscall_parameters_restrictions.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698