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

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

Issue 2490893002: seccomp-bpf: Allow MADV_FREE in madvise(2) (Closed)
Patch Set: Remove stray comma 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 (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/baseline_policy.h" 5 #include "sandbox/linux/seccomp-bpf-helpers/baseline_policy.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <sys/mman.h> 8 #include <sys/mman.h>
9 #include <sys/socket.h> 9 #include <sys/socket.h>
10 #include <sys/syscall.h> 10 #include <sys/syscall.h>
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 return Error(EPERM); 167 return Error(EPERM);
168 168
169 if (sysno == __NR_getpriority || sysno ==__NR_setpriority) 169 if (sysno == __NR_getpriority || sysno ==__NR_setpriority)
170 return RestrictGetSetpriority(current_pid); 170 return RestrictGetSetpriority(current_pid);
171 171
172 if (sysno == __NR_getrandom) { 172 if (sysno == __NR_getrandom) {
173 return RestrictGetRandom(); 173 return RestrictGetRandom();
174 } 174 }
175 175
176 if (sysno == __NR_madvise) { 176 if (sysno == __NR_madvise) {
177 // Only allow MADV_DONTNEED (aka MADV_FREE). 177 // Only allow MADV_DONTNEED and MADV_FREE.
178 const Arg<int> advice(2); 178 const Arg<int> advice(2);
179 return If(advice == MADV_DONTNEED, Allow()).Else(Error(EPERM)); 179 return If(AnyOf(advice == MADV_DONTNEED
180 #if defined(MADV_FREE)
181 // MADV_FREE was introduced in Linux 4.5 and started being
182 // defined in glibc 2.24.
183 , advice == MADV_FREE
184 #endif
185 ), Allow()).Else(Error(EPERM));
180 } 186 }
181 187
182 #if defined(__i386__) || defined(__x86_64__) || defined(__mips__) || \ 188 #if defined(__i386__) || defined(__x86_64__) || defined(__mips__) || \
183 defined(__aarch64__) 189 defined(__aarch64__)
184 if (sysno == __NR_mmap) 190 if (sysno == __NR_mmap)
185 return RestrictMmapFlags(); 191 return RestrictMmapFlags();
186 #endif 192 #endif
187 193
188 #if defined(__i386__) || defined(__arm__) || defined(__mips__) 194 #if defined(__i386__) || defined(__arm__) || defined(__mips__)
189 if (sysno == __NR_mmap2) 195 if (sysno == __NR_mmap2)
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 DCHECK_EQ(sys_getpid(), policy_pid_); 285 DCHECK_EQ(sys_getpid(), policy_pid_);
280 } 286 }
281 return EvaluateSyscallImpl(fs_denied_errno_, policy_pid_, sysno); 287 return EvaluateSyscallImpl(fs_denied_errno_, policy_pid_, sysno);
282 } 288 }
283 289
284 ResultExpr BaselinePolicy::InvalidSyscall() const { 290 ResultExpr BaselinePolicy::InvalidSyscall() const {
285 return CrashSIGSYS(); 291 return CrashSIGSYS();
286 } 292 }
287 293
288 } // namespace sandbox. 294 } // 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