diff options
author | Paul Moore <pmoore@redhat.com> | 2013-11-08 13:56:38 -0500 |
---|---|---|
committer | Paul Moore <pmoore@redhat.com> | 2013-11-08 13:56:38 -0500 |
commit | 94851b18d4eb94f8bbf0d9176f7429bd8e371f62 (patch) | |
tree | c3c743ac6323e1caf9e987d6946cc4b2333a8256 /security/apparmor/domain.c | |
parent | 42d64e1add3a1ce8a787116036163b8724362145 (diff) | |
parent | 5e01dc7b26d9f24f39abace5da98ccbd6a5ceb52 (diff) |
Merge tag 'v3.12'
Linux 3.12
Diffstat (limited to 'security/apparmor/domain.c')
-rw-r--r-- | security/apparmor/domain.c | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/security/apparmor/domain.c b/security/apparmor/domain.c index 01b7bd669a88..26c607c971f5 100644 --- a/security/apparmor/domain.c +++ b/security/apparmor/domain.c | |||
@@ -144,7 +144,7 @@ static struct aa_profile *__attach_match(const char *name, | |||
144 | int len = 0; | 144 | int len = 0; |
145 | struct aa_profile *profile, *candidate = NULL; | 145 | struct aa_profile *profile, *candidate = NULL; |
146 | 146 | ||
147 | list_for_each_entry(profile, head, base.list) { | 147 | list_for_each_entry_rcu(profile, head, base.list) { |
148 | if (profile->flags & PFLAG_NULL) | 148 | if (profile->flags & PFLAG_NULL) |
149 | continue; | 149 | continue; |
150 | if (profile->xmatch && profile->xmatch_len > len) { | 150 | if (profile->xmatch && profile->xmatch_len > len) { |
@@ -177,9 +177,9 @@ static struct aa_profile *find_attach(struct aa_namespace *ns, | |||
177 | { | 177 | { |
178 | struct aa_profile *profile; | 178 | struct aa_profile *profile; |
179 | 179 | ||
180 | read_lock(&ns->lock); | 180 | rcu_read_lock(); |
181 | profile = aa_get_profile(__attach_match(name, list)); | 181 | profile = aa_get_profile(__attach_match(name, list)); |
182 | read_unlock(&ns->lock); | 182 | rcu_read_unlock(); |
183 | 183 | ||
184 | return profile; | 184 | return profile; |
185 | } | 185 | } |
@@ -359,7 +359,7 @@ int apparmor_bprm_set_creds(struct linux_binprm *bprm) | |||
359 | cxt = cred_cxt(bprm->cred); | 359 | cxt = cred_cxt(bprm->cred); |
360 | BUG_ON(!cxt); | 360 | BUG_ON(!cxt); |
361 | 361 | ||
362 | profile = aa_get_profile(aa_newest_version(cxt->profile)); | 362 | profile = aa_get_newest_profile(cxt->profile); |
363 | /* | 363 | /* |
364 | * get the namespace from the replacement profile as replacement | 364 | * get the namespace from the replacement profile as replacement |
365 | * can change the namespace | 365 | * can change the namespace |
@@ -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; |
@@ -417,7 +417,7 @@ int apparmor_bprm_set_creds(struct linux_binprm *bprm) | |||
417 | 417 | ||
418 | if (!(cp.allow & AA_MAY_ONEXEC)) | 418 | if (!(cp.allow & AA_MAY_ONEXEC)) |
419 | goto audit; | 419 | goto audit; |
420 | new_profile = aa_get_profile(aa_newest_version(cxt->onexec)); | 420 | new_profile = aa_get_newest_profile(cxt->onexec); |
421 | goto apply; | 421 | goto apply; |
422 | } | 422 | } |
423 | 423 | ||
@@ -434,7 +434,7 @@ int apparmor_bprm_set_creds(struct linux_binprm *bprm) | |||
434 | new_profile = aa_get_profile(profile); | 434 | new_profile = aa_get_profile(profile); |
435 | goto x_clear; | 435 | goto x_clear; |
436 | } else if (perms.xindex & AA_X_UNCONFINED) { | 436 | } else if (perms.xindex & AA_X_UNCONFINED) { |
437 | new_profile = aa_get_profile(ns->unconfined); | 437 | new_profile = aa_get_newest_profile(ns->unconfined); |
438 | info = "ux fallback"; | 438 | info = "ux fallback"; |
439 | } else { | 439 | } else { |
440 | error = -ENOENT; | 440 | error = -ENOENT; |
@@ -641,7 +641,10 @@ int aa_change_hat(const char *hats[], int count, u64 token, bool permtest) | |||
641 | if (count) { | 641 | if (count) { |
642 | /* attempting to change into a new hat or switch to a sibling */ | 642 | /* attempting to change into a new hat or switch to a sibling */ |
643 | struct aa_profile *root; | 643 | struct aa_profile *root; |
644 | root = PROFILE_IS_HAT(profile) ? profile->parent : profile; | 644 | if (PROFILE_IS_HAT(profile)) |
645 | root = aa_get_profile_rcu(&profile->parent); | ||
646 | else | ||
647 | root = aa_get_profile(profile); | ||
645 | 648 | ||
646 | /* find first matching hat */ | 649 | /* find first matching hat */ |
647 | for (i = 0; i < count && !hat; i++) | 650 | for (i = 0; i < count && !hat; i++) |
@@ -653,6 +656,7 @@ int aa_change_hat(const char *hats[], int count, u64 token, bool permtest) | |||
653 | error = -ECHILD; | 656 | error = -ECHILD; |
654 | else | 657 | else |
655 | error = -ENOENT; | 658 | error = -ENOENT; |
659 | aa_put_profile(root); | ||
656 | goto out; | 660 | goto out; |
657 | } | 661 | } |
658 | 662 | ||
@@ -667,6 +671,7 @@ int aa_change_hat(const char *hats[], int count, u64 token, bool permtest) | |||
667 | 671 | ||
668 | /* freed below */ | 672 | /* freed below */ |
669 | name = new_compound_name(root->base.hname, hats[0]); | 673 | name = new_compound_name(root->base.hname, hats[0]); |
674 | aa_put_profile(root); | ||
670 | target = name; | 675 | target = name; |
671 | /* released below */ | 676 | /* released below */ |
672 | hat = aa_new_null_profile(profile, 1); | 677 | hat = aa_new_null_profile(profile, 1); |
@@ -676,6 +681,7 @@ int aa_change_hat(const char *hats[], int count, u64 token, bool permtest) | |||
676 | goto audit; | 681 | goto audit; |
677 | } | 682 | } |
678 | } else { | 683 | } else { |
684 | aa_put_profile(root); | ||
679 | target = hat->base.hname; | 685 | target = hat->base.hname; |
680 | if (!PROFILE_IS_HAT(hat)) { | 686 | if (!PROFILE_IS_HAT(hat)) { |
681 | info = "target not hat"; | 687 | info = "target not hat"; |