aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Johansen <john.johansen@canonical.com>2013-07-11 00:12:43 -0400
committerJohn Johansen <john.johansen@canonical.com>2013-08-14 14:42:07 -0400
commit038165070aa55375d4bdd2f84b34a486feca63d6 (patch)
tree327014e8b5120a0ccc66418159c72f769e9b174d
parent8651e1d6572bc2c061073f05fabcd7175789259d (diff)
apparmor: allow setting any profile into the unconfined state
Allow emulating the default profile behavior from boot, by allowing loading of a profile in the unconfined state into a new NS. Signed-off-by: John Johansen <john.johansen@canonical.com> Acked-by: Seth Arnold <seth.arnold@canonical.com>
-rw-r--r--security/apparmor/domain.c4
-rw-r--r--security/apparmor/include/policy.h6
-rw-r--r--security/apparmor/include/policy_unpack.h7
-rw-r--r--security/apparmor/policy.c6
-rw-r--r--security/apparmor/policy_unpack.c8
5 files changed, 22 insertions, 9 deletions
diff --git a/security/apparmor/domain.c b/security/apparmor/domain.c
index bc28f2670ee4..26c607c971f5 100644
--- a/security/apparmor/domain.c
+++ b/security/apparmor/domain.c
@@ -371,8 +371,8 @@ int apparmor_bprm_set_creds(struct linux_binprm *bprm)
371 error = aa_path_name(&bprm->file->f_path, profile->path_flags, &buffer, 371 error = aa_path_name(&bprm->file->f_path, profile->path_flags, &buffer,
372 &name, &info); 372 &name, &info);
373 if (error) { 373 if (error) {
374 if (profile->flags & 374 if (unconfined(profile) ||
375 (PFLAG_IX_ON_NAME_ERROR | PFLAG_UNCONFINED)) 375 (profile->flags & PFLAG_IX_ON_NAME_ERROR))
376 error = 0; 376 error = 0;
377 name = bprm->filename; 377 name = bprm->filename;
378 goto audit; 378 goto audit;
diff --git a/security/apparmor/include/policy.h b/security/apparmor/include/policy.h
index 8a68226ff7f7..65662e3c75cf 100644
--- a/security/apparmor/include/policy.h
+++ b/security/apparmor/include/policy.h
@@ -56,11 +56,11 @@ enum profile_mode {
56 APPARMOR_ENFORCE, /* enforce access rules */ 56 APPARMOR_ENFORCE, /* enforce access rules */
57 APPARMOR_COMPLAIN, /* allow and log access violations */ 57 APPARMOR_COMPLAIN, /* allow and log access violations */
58 APPARMOR_KILL, /* kill task on access violation */ 58 APPARMOR_KILL, /* kill task on access violation */
59 APPARMOR_UNCONFINED, /* profile set to unconfined */
59}; 60};
60 61
61enum profile_flags { 62enum profile_flags {
62 PFLAG_HAT = 1, /* profile is a hat */ 63 PFLAG_HAT = 1, /* profile is a hat */
63 PFLAG_UNCONFINED = 2, /* profile is an unconfined profile */
64 PFLAG_NULL = 4, /* profile is null learning profile */ 64 PFLAG_NULL = 4, /* profile is null learning profile */
65 PFLAG_IX_ON_NAME_ERROR = 8, /* fallback to ix on name lookup fail */ 65 PFLAG_IX_ON_NAME_ERROR = 8, /* fallback to ix on name lookup fail */
66 PFLAG_IMMUTABLE = 0x10, /* don't allow changes/replacement */ 66 PFLAG_IMMUTABLE = 0x10, /* don't allow changes/replacement */
@@ -199,7 +199,7 @@ struct aa_profile {
199 struct aa_dfa *xmatch; 199 struct aa_dfa *xmatch;
200 int xmatch_len; 200 int xmatch_len;
201 enum audit_mode audit; 201 enum audit_mode audit;
202 enum profile_mode mode; 202 long mode;
203 long flags; 203 long flags;
204 u32 path_flags; 204 u32 path_flags;
205 int size; 205 int size;
@@ -240,7 +240,7 @@ ssize_t aa_remove_profiles(char *name, size_t size);
240#define PROF_ADD 1 240#define PROF_ADD 1
241#define PROF_REPLACE 0 241#define PROF_REPLACE 0
242 242
243#define unconfined(X) ((X)->flags & PFLAG_UNCONFINED) 243#define unconfined(X) ((X)->mode == APPARMOR_UNCONFINED)
244 244
245 245
246/** 246/**
diff --git a/security/apparmor/include/policy_unpack.h b/security/apparmor/include/policy_unpack.h
index 0d7ad722b8ff..c214fb88b1bc 100644
--- a/security/apparmor/include/policy_unpack.h
+++ b/security/apparmor/include/policy_unpack.h
@@ -27,6 +27,13 @@ struct aa_load_ent {
27void aa_load_ent_free(struct aa_load_ent *ent); 27void aa_load_ent_free(struct aa_load_ent *ent);
28struct aa_load_ent *aa_load_ent_alloc(void); 28struct aa_load_ent *aa_load_ent_alloc(void);
29 29
30#define PACKED_FLAG_HAT 1
31
32#define PACKED_MODE_ENFORCE 0
33#define PACKED_MODE_COMPLAIN 1
34#define PACKED_MODE_KILL 2
35#define PACKED_MODE_UNCONFINED 3
36
30int aa_unpack(void *udata, size_t size, struct list_head *lh, const char **ns); 37int aa_unpack(void *udata, size_t size, struct list_head *lh, const char **ns);
31 38
32#endif /* __POLICY_INTERFACE_H */ 39#endif /* __POLICY_INTERFACE_H */
diff --git a/security/apparmor/policy.c b/security/apparmor/policy.c
index 7a80b0c7e0ce..2e4e2ecb25bc 100644
--- a/security/apparmor/policy.c
+++ b/security/apparmor/policy.c
@@ -96,6 +96,7 @@ const char *const profile_mode_names[] = {
96 "enforce", 96 "enforce",
97 "complain", 97 "complain",
98 "kill", 98 "kill",
99 "unconfined",
99}; 100};
100 101
101/** 102/**
@@ -290,8 +291,9 @@ static struct aa_namespace *alloc_namespace(const char *prefix,
290 if (!ns->unconfined) 291 if (!ns->unconfined)
291 goto fail_unconfined; 292 goto fail_unconfined;
292 293
293 ns->unconfined->flags = PFLAG_UNCONFINED | PFLAG_IX_ON_NAME_ERROR | 294 ns->unconfined->flags = PFLAG_IX_ON_NAME_ERROR |
294 PFLAG_IMMUTABLE | PFLAG_NS_COUNT; 295 PFLAG_IMMUTABLE | PFLAG_NS_COUNT;
296 ns->unconfined->mode = APPARMOR_UNCONFINED;
295 297
296 /* ns and ns->unconfined share ns->unconfined refcount */ 298 /* ns and ns->unconfined share ns->unconfined refcount */
297 ns->unconfined->ns = ns; 299 ns->unconfined->ns = ns;
diff --git a/security/apparmor/policy_unpack.c b/security/apparmor/policy_unpack.c
index ce15313896ee..cac0aa075787 100644
--- a/security/apparmor/policy_unpack.c
+++ b/security/apparmor/policy_unpack.c
@@ -511,12 +511,16 @@ static struct aa_profile *unpack_profile(struct aa_ext *e)
511 goto fail; 511 goto fail;
512 if (!unpack_u32(e, &tmp, NULL)) 512 if (!unpack_u32(e, &tmp, NULL))
513 goto fail; 513 goto fail;
514 if (tmp) 514 if (tmp & PACKED_FLAG_HAT)
515 profile->flags |= PFLAG_HAT; 515 profile->flags |= PFLAG_HAT;
516 if (!unpack_u32(e, &tmp, NULL)) 516 if (!unpack_u32(e, &tmp, NULL))
517 goto fail; 517 goto fail;
518 if (tmp) 518 if (tmp == PACKED_MODE_COMPLAIN)
519 profile->mode = APPARMOR_COMPLAIN; 519 profile->mode = APPARMOR_COMPLAIN;
520 else if (tmp == PACKED_MODE_KILL)
521 profile->mode = APPARMOR_KILL;
522 else if (tmp == PACKED_MODE_UNCONFINED)
523 profile->mode = APPARMOR_UNCONFINED;
520 if (!unpack_u32(e, &tmp, NULL)) 524 if (!unpack_u32(e, &tmp, NULL))
521 goto fail; 525 goto fail;
522 if (tmp) 526 if (tmp)