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

Side by Side Diff: sandbox/linux/services/yama.h

Issue 188193002: Linux sandbox: add basic Yama support (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments. Add testing. Created 6 years, 9 months 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 | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef SANDBOX_LINUX_SERVICES_YAMA_H_
6 #define SANDBOX_LINUX_SERVICES_YAMA_H_
7
8 #include "base/basictypes.h"
9 #include "base/process/process_handle.h"
10
11 namespace sandbox {
12
13 // Yama is a LSM kernel module which can restrict ptrace().
14 // This class provides ways to detect if Yama is present and enabled
15 // and to restrict which processes can ptrace the current process.
16 class Yama {
17 public:
18 // This enum should be used to set or check a bitmask.
19 // A value of 0 would indicate that the status is not known.
20 enum GlobalStatus {
21 STATUS_KNOWN = 1 << 0,
22 STATUS_PRESENT = 1 << 1,
23 STATUS_ENFORCING = 1 << 2,
24 // STATUS_STRICT_ENFORCING corresponds to either mode 2 or mode 3 of Yama.
25 // Ptrace could be entirely denied, or restricted to CAP_SYS_PTRACE
26 // and PTRACE_TRACEME.
27 STATUS_STRICT_ENFORCING = 1 << 3
28 };
29
30 // Restrict who can ptrace() the current process to its ancestors.
31 // If this succeeds, then Yama is available on this kernel.
32 // However, Yama may not be enforcing at this time.
33 static bool RestrictPtracersToAncestors();
34
35 // Disable Yama restrictions for the current process.
36 // This will fail if Yama is not available on this kernel.
37 // This is meant for testing only. If you need this, implement
38 // a per-pid authorization instead.
39 static bool DisableYamaRestrictions();
40
41 // Checks if Yama is currently in enforcing for the machine (not the current
Jorge Lucangeli Obes 2014/03/06 15:42:09 "in enforcing mode"
jln (very slow on Chromium) 2014/03/06 21:43:46 Done.
42 // process). This requires access to the filesystem and will use
43 // /proc/sys/kernel/yama/ptrace_scope.
44 static int GetStatus();
45
46 // Helper for checking for STATUS_PRESENT in GetStatus().
47 static bool IsPresent();
48 // Helper for checkking for STATUS_ENFORCING in GetStatus().
49 static bool IsEnforcing();
50
51 private:
52 DISALLOW_IMPLICIT_CONSTRUCTORS(Yama);
53 };
54
55 } // namespace sandbox
56
57 #endif // SANDBOX_LINUX_SERVICES_YAMA_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698