Re: [PATCH] APPARMOR: code cleanup on context.h
From: wzt wzt
Date: Mon Nov 15 2010 - 18:29:38 EST
hi, john, any comments?
On Sat, Nov 13, 2010 at 10:34 AM, <wzt.wzt@xxxxxxxxx> wrote:
> Use current api to replace old codes.
>
> Signed-off-by: Zhitong Wang <zhitong.wangzt@xxxxxxxxxxxxxxx>
>
> ---
> Âsecurity/apparmor/include/context.h | Â 34 +++++++++++++++-------------------
> Â1 files changed, 15 insertions(+), 19 deletions(-)
>
> diff --git a/security/apparmor/include/context.h b/security/apparmor/include/context.h
> index a9cbee4..c9112f3 100644
> --- a/security/apparmor/include/context.h
> +++ b/security/apparmor/include/context.h
> @@ -82,23 +82,6 @@ int aa_set_current_hat(struct aa_profile *profile, u64 token);
> Âint aa_restore_previous_profile(u64 cookie);
>
> Â/**
> - * __aa_task_is_confined - determine if @task has any confinement
> - * @task: task to check confinement of Â(NOT NULL)
> - *
> - * If @task != current needs to be called in RCU safe critical section
> - */
> -static inline bool __aa_task_is_confined(struct task_struct *task)
> -{
> - Â Â Â struct aa_task_cxt *cxt = __task_cred(task)->security;
> -
> - Â Â Â BUG_ON(!cxt || !cxt->profile);
> - Â Â Â if (unconfined(aa_newest_version(cxt->profile)))
> - Â Â Â Â Â Â Â return 0;
> -
> - Â Â Â return 1;
> -}
> -
> -/**
> Â* aa_cred_profile - obtain cred's profiles
> Â* @cred: cred to obtain profiles from Â(NOT NULL)
> Â*
> @@ -138,9 +121,8 @@ static inline struct aa_profile *aa_current_profile(void)
> Â{
> Â Â Â Âconst struct aa_task_cxt *cxt = current_cred()->security;
> Â Â Â Âstruct aa_profile *profile;
> - Â Â Â BUG_ON(!cxt || !cxt->profile);
>
> - Â Â Â profile = aa_newest_version(cxt->profile);
> + Â Â Â profile = __aa_current_profile();
> Â Â Â Â/*
> Â Â Â Â * Whether or not replacement succeeds, use newest profile so
> Â Â Â Â * there is no need to update it after replacement.
> @@ -151,4 +133,18 @@ static inline struct aa_profile *aa_current_profile(void)
> Â Â Â Âreturn profile;
> Â}
>
> +/**
> + * __aa_task_is_confined - determine if @task has any confinement
> + * @task: task to check confinement of Â(NOT NULL)
> + *
> + * If @task != current needs to be called in RCU safe critical section
> + */
> +static inline bool __aa_task_is_confined(struct task_struct *task)
> +{
> + Â Â Â if (unconfined(aa_cred_profile(__task_cred(task))))
> + Â Â Â Â Â Â Â return 0;
> +
> + Â Â Â return 1;
> +}
> +
> Â#endif /* __AA_CONTEXT_H */
> --
> 1.6.5.3
>
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/