~apparmor-dev/apparmor/master

« back to all changes in this revision

Viewing changes to kernel-patches/4.6/0017-apparmor-allow-SYS_CAP_RESOURCE-to-be-sufficient-to-.patch

  • Committer: Steve Beattie
  • Date: 2019-02-19 09:38:13 UTC
  • Revision ID: sbeattie@ubuntu.com-20190219093813-ud526ee6hwn8nljz
The AppArmor project has been converted to git and is now hosted on
gitlab.

To get the converted repository, please do
  git clone https://gitlab.com/apparmor/apparmor

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
From a3896605318b86d8cf288c122e03604e349d5dd7 Mon Sep 17 00:00:00 2001
2
 
From: Jeff Mahoney <jeffm@suse.com>
3
 
Date: Fri, 6 Nov 2015 15:17:30 -0500
4
 
Subject: [PATCH 17/27] apparmor: allow SYS_CAP_RESOURCE to be sufficient to
5
 
 prlimit another task
6
 
 
7
 
While using AppArmor, SYS_CAP_RESOURCE is insufficient to call prlimit
8
 
on another task. The only other example of a AppArmor mediating access to
9
 
another, already running, task (ignoring fork+exec) is ptrace.
10
 
 
11
 
The AppArmor model for ptrace is that one of the following must be true:
12
 
1) The tracer is unconfined
13
 
2) The tracer is in complain mode
14
 
3) The tracer and tracee are confined by the same profile
15
 
4) The tracer is confined but has SYS_CAP_PTRACE
16
 
 
17
 
1), 2, and 3) are already true for setrlimit.
18
 
 
19
 
We can match the ptrace model just by allowing CAP_SYS_RESOURCE.
20
 
 
21
 
We still test the values of the rlimit since it can always be overridden
22
 
using a value that means unlimited for a particular resource.
23
 
 
24
 
Signed-off-by: Jeff Mahoney <jeffm@suse.com>
25
 
Signed-off-by: John Johansen <john.johansen@canonical.com>
26
 
---
27
 
 security/apparmor/resource.c | 6 ++++--
28
 
 1 file changed, 4 insertions(+), 2 deletions(-)
29
 
 
30
 
diff --git a/security/apparmor/resource.c b/security/apparmor/resource.c
31
 
index 748bf0c..67a6072 100644
32
 
--- a/security/apparmor/resource.c
33
 
+++ b/security/apparmor/resource.c
34
 
@@ -101,9 +101,11 @@ int aa_task_setrlimit(struct aa_profile *profile, struct task_struct *task,
35
 
        /* TODO: extend resource control to handle other (non current)
36
 
         * profiles.  AppArmor rules currently have the implicit assumption
37
 
         * that the task is setting the resource of a task confined with
38
 
-        * the same profile.
39
 
+        * the same profile or that the task setting the resource of another
40
 
+        * task has CAP_SYS_RESOURCE.
41
 
         */
42
 
-       if (profile != task_profile ||
43
 
+       if ((profile != task_profile &&
44
 
+            aa_capable(profile, CAP_SYS_RESOURCE, 1)) ||
45
 
            (profile->rlimits.mask & (1 << resource) &&
46
 
             new_rlim->rlim_max > profile->rlimits.limits[resource].rlim_max))
47
 
                error = -EACCES;
48
 
2.7.4
49