[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <9aff97f4-ae7b-905f-5c06-3bb3904ae525@canonical.com>
Date: Thu, 21 Apr 2022 09:51:10 -0700
From: John Johansen <john.johansen@...onical.com>
To: Casey Schaufler <casey@...aufler-ca.com>,
casey.schaufler@...el.com, jmorris@...ei.org,
linux-security-module@...r.kernel.org, selinux@...r.kernel.org
Cc: linux-audit@...hat.com, keescook@...omium.org,
penguin-kernel@...ove.sakura.ne.jp, paul@...l-moore.com,
stephen.smalley.work@...il.com, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v35 01/29] integrity: disassociate ima_filter_rule from
security_audit_rule
On 4/18/22 07:59, Casey Schaufler wrote:
> Create real functions for the ima_filter_rule interfaces.
> These replace #defines that obscure the reuse of audit
> interfaces. The new fuctions are put in security.c because
> they use security module registered hooks that we don't
> want exported.
>
> Signed-off-by: Casey Schaufler <casey@...aufler-ca.com>
> Acked-by: Paul Moore <paul@...l-moore.com>
Reviewed-by: John Johansen <john.johansen@...onical.com>
> ---
> include/linux/security.h | 24 ++++++++++++++++++++++++
> security/integrity/ima/ima.h | 26 --------------------------
> security/security.c | 21 +++++++++++++++++++++
> 3 files changed, 45 insertions(+), 26 deletions(-)
>
> diff --git a/include/linux/security.h b/include/linux/security.h
> index 25b3ef71f495..2986342dad41 100644
> --- a/include/linux/security.h
> +++ b/include/linux/security.h
> @@ -1917,6 +1917,30 @@ static inline void security_audit_rule_free(void *lsmrule)
> #endif /* CONFIG_SECURITY */
> #endif /* CONFIG_AUDIT */
>
> +#if defined(CONFIG_IMA_LSM_RULES) && defined(CONFIG_SECURITY)
> +int ima_filter_rule_init(u32 field, u32 op, char *rulestr, void **lsmrule);
> +int ima_filter_rule_match(u32 secid, u32 field, u32 op, void *lsmrule);
> +void ima_filter_rule_free(void *lsmrule);
> +
> +#else
> +
> +static inline int ima_filter_rule_init(u32 field, u32 op, char *rulestr,
> + void **lsmrule)
> +{
> + return 0;
> +}
> +
> +static inline int ima_filter_rule_match(u32 secid, u32 field, u32 op,
> + void *lsmrule)
> +{
> + return 0;
> +}
> +
> +static inline void ima_filter_rule_free(void *lsmrule)
> +{ }
> +
> +#endif /* defined(CONFIG_IMA_LSM_RULES) && defined(CONFIG_SECURITY) */
> +
> #ifdef CONFIG_SECURITYFS
>
> extern struct dentry *securityfs_create_file(const char *name, umode_t mode,
> diff --git a/security/integrity/ima/ima.h b/security/integrity/ima/ima.h
> index be965a8715e4..1b5d70ac2dc9 100644
> --- a/security/integrity/ima/ima.h
> +++ b/security/integrity/ima/ima.h
> @@ -418,32 +418,6 @@ static inline void ima_free_modsig(struct modsig *modsig)
> }
> #endif /* CONFIG_IMA_APPRAISE_MODSIG */
>
> -/* LSM based policy rules require audit */
> -#ifdef CONFIG_IMA_LSM_RULES
> -
> -#define ima_filter_rule_init security_audit_rule_init
> -#define ima_filter_rule_free security_audit_rule_free
> -#define ima_filter_rule_match security_audit_rule_match
> -
> -#else
> -
> -static inline int ima_filter_rule_init(u32 field, u32 op, char *rulestr,
> - void **lsmrule)
> -{
> - return -EINVAL;
> -}
> -
> -static inline void ima_filter_rule_free(void *lsmrule)
> -{
> -}
> -
> -static inline int ima_filter_rule_match(u32 secid, u32 field, u32 op,
> - void *lsmrule)
> -{
> - return -EINVAL;
> -}
> -#endif /* CONFIG_IMA_LSM_RULES */
> -
> #ifdef CONFIG_IMA_READ_POLICY
> #define POLICY_FILE_FLAGS (S_IWUSR | S_IRUSR)
> #else
> diff --git a/security/security.c b/security/security.c
> index b7cf5cbfdc67..22543fdb6041 100644
> --- a/security/security.c
> +++ b/security/security.c
> @@ -2586,6 +2586,27 @@ int security_audit_rule_match(u32 secid, u32 field, u32 op, void *lsmrule)
> }
> #endif /* CONFIG_AUDIT */
>
> +#ifdef CONFIG_IMA_LSM_RULES
> +/*
> + * The integrity subsystem uses the same hooks as
> + * the audit subsystem.
> + */
> +int ima_filter_rule_init(u32 field, u32 op, char *rulestr, void **lsmrule)
> +{
> + return call_int_hook(audit_rule_init, 0, field, op, rulestr, lsmrule);
> +}
> +
> +void ima_filter_rule_free(void *lsmrule)
> +{
> + call_void_hook(audit_rule_free, lsmrule);
> +}
> +
> +int ima_filter_rule_match(u32 secid, u32 field, u32 op, void *lsmrule)
> +{
> + return call_int_hook(audit_rule_match, 0, secid, field, op, lsmrule);
> +}
> +#endif /* CONFIG_IMA_LSM_RULES */
> +
> #ifdef CONFIG_BPF_SYSCALL
> int security_bpf(int cmd, union bpf_attr *attr, unsigned int size)
> {
Powered by blists - more mailing lists