All of lore.kernel.org
 help / color / mirror / Atom feed
From: John Johansen <john.johansen@canonical.com>
To: Casey Schaufler <casey@schaufler-ca.com>,
	casey.schaufler@intel.com, jmorris@namei.org,
	linux-security-module@vger.kernel.org, selinux@vger.kernel.org
Cc: keescook@chromium.org, penguin-kernel@i-love.sakura.ne.jp,
	paul@paul-moore.com, sds@tycho.nsa.gov
Subject: [PATCH v3 22/24] LSM: Return the lsmblob slot on initialization
Date: Mon, 24 Jun 2019 14:47:24 -0700	[thread overview]
Message-ID: <11e751ea-c93c-efe7-558e-632af59d2355@canonical.com> (raw)
In-Reply-To: <20190621185233.6766-23-casey@schaufler-ca.com>

On 6/21/19 11:52 AM, Casey Schaufler wrote:
> Return the slot allocated to the calling LSM in the lsmblob
> structure. This can be used to set lsmblobs explicitly for
> netlabel interfaces.
> 
> Signed-off-by: Casey Schaufler <casey@schaufler-ca.com>

Reviewed-by: John Johansen <john.johansen@canonical.com>


> ---
>  include/linux/lsm_hooks.h  | 4 ++--
>  security/apparmor/lsm.c    | 8 ++++++--
>  security/security.c        | 9 +++++++--
>  security/selinux/hooks.c   | 5 ++++-
>  security/smack/smack_lsm.c | 5 ++++-
>  5 files changed, 23 insertions(+), 8 deletions(-)
> 
> diff --git a/include/linux/lsm_hooks.h b/include/linux/lsm_hooks.h
> index 4d1ddf1a2aa6..ce341bcbce5d 100644
> --- a/include/linux/lsm_hooks.h
> +++ b/include/linux/lsm_hooks.h
> @@ -2068,8 +2068,8 @@ struct lsm_blob_sizes {
>  extern struct security_hook_heads security_hook_heads;
>  extern char *lsm_names;
>  
> -extern void security_add_hooks(struct security_hook_list *hooks, int count,
> -				char *lsm);
> +extern int security_add_hooks(struct security_hook_list *hooks, int count,
> +			      char *lsm);
>  
>  #define LSM_FLAG_LEGACY_MAJOR	BIT(0)
>  #define LSM_FLAG_EXCLUSIVE	BIT(1)
> diff --git a/security/apparmor/lsm.c b/security/apparmor/lsm.c
> index 2716e7731279..dcbbefbd95ff 100644
> --- a/security/apparmor/lsm.c
> +++ b/security/apparmor/lsm.c
> @@ -47,6 +47,9 @@
>  /* Flag indicating whether initialization completed */
>  int apparmor_initialized;
>  
> +/* Slot for the AppArmor secid in the lsmblob structure */
> +int apparmor_lsmblob_slot;
> +
>  DEFINE_PER_CPU(struct aa_buffers, aa_buffers);
>  
>  
> @@ -1678,8 +1681,9 @@ static int __init apparmor_init(void)
>  		aa_free_root_ns();
>  		goto buffers_out;
>  	}
> -	security_add_hooks(apparmor_hooks, ARRAY_SIZE(apparmor_hooks),
> -				"apparmor");
> +	apparmor_lsmblob_slot = security_add_hooks(apparmor_hooks,
> +						   ARRAY_SIZE(apparmor_hooks),
> +						   "apparmor");
>  
>  	/* Report that AppArmor successfully initialized */
>  	apparmor_initialized = 1;
> diff --git a/security/security.c b/security/security.c
> index b2ffcd1f3057..c93a368b697b 100644
> --- a/security/security.c
> +++ b/security/security.c
> @@ -437,9 +437,12 @@ static int lsm_slot __initdata;
>   * Each LSM has to register its hooks with the infrastructure.
>   * If the LSM is using hooks that export secids allocate a slot
>   * for it in the lsmblob.
> + *
> + * Returns the slot number in the lsmblob structure if one is
> + * allocated or LSMBLOB_INVALID if one was not allocated.
>   */
> -void __init security_add_hooks(struct security_hook_list *hooks, int count,
> -				char *lsm)
> +int __init security_add_hooks(struct security_hook_list *hooks, int count,
> +			      char *lsm)
>  {
>  	int slot = LSMBLOB_INVALID;
>  	int i;
> @@ -479,6 +482,8 @@ void __init security_add_hooks(struct security_hook_list *hooks, int count,
>  	}
>  	if (lsm_append(lsm, &lsm_names) < 0)
>  		panic("%s - Cannot get early memory.\n", __func__);
> +
> +	return slot;
>  }
>  
>  int call_lsm_notifier(enum lsm_event event, void *data)
> diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
> index ee840fecfebb..1e09acbf9630 100644
> --- a/security/selinux/hooks.c
> +++ b/security/selinux/hooks.c
> @@ -103,6 +103,7 @@
>  #include "avc_ss.h"
>  
>  struct selinux_state selinux_state;
> +int selinux_lsmblob_slot;
>  
>  /* SECMARK reference count */
>  static atomic_t selinux_secmark_refcount = ATOMIC_INIT(0);
> @@ -6877,7 +6878,9 @@ static __init int selinux_init(void)
>  
>  	hashtab_cache_init();
>  
> -	security_add_hooks(selinux_hooks, ARRAY_SIZE(selinux_hooks), "selinux");
> +	selinux_lsmblob_slot = security_add_hooks(selinux_hooks,
> +						  ARRAY_SIZE(selinux_hooks),
> +						  "selinux");
>  
>  	if (avc_add_callback(selinux_netcache_avc_callback, AVC_CALLBACK_RESET))
>  		panic("SELinux: Unable to register AVC netcache callback\n");
> diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c
> index 3834b751d1e9..273f311fb153 100644
> --- a/security/smack/smack_lsm.c
> +++ b/security/smack/smack_lsm.c
> @@ -60,6 +60,7 @@ static LIST_HEAD(smk_ipv6_port_list);
>  #endif
>  static struct kmem_cache *smack_inode_cache;
>  int smack_enabled;
> +int smack_lsmblob_slot;
>  
>  #define A(s) {"smack"#s, sizeof("smack"#s) - 1, Opt_##s}
>  static struct {
> @@ -4749,7 +4750,9 @@ static __init int smack_init(void)
>  	/*
>  	 * Register with LSM
>  	 */
> -	security_add_hooks(smack_hooks, ARRAY_SIZE(smack_hooks), "smack");
> +	smack_lsmblob_slot = security_add_hooks(smack_hooks,
> +						ARRAY_SIZE(smack_hooks),
> +						"smack");
>  	smack_enabled = 1;
>  
>  	pr_info("Smack:  Initializing.\n");
> 




  parent reply	other threads:[~2019-06-24 21:47 UTC|newest]

Thread overview: 85+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-21 18:52 [PATCH v3 00/24] LSM: Module stacking for AppArmor Casey Schaufler
2019-06-21 18:52 ` [PATCH v3 01/24] LSM: Infrastructure management of the superblock Casey Schaufler
2019-06-24 18:31   ` John Johansen
2019-06-21 18:52 ` [PATCH v3 02/24] LSM: Infrastructure management of the sock security Casey Schaufler
2019-06-24 18:33   ` John Johansen
2019-06-21 18:52 ` [PATCH v3 03/24] LSM: Infrastructure management of the key blob Casey Schaufler
2019-06-24 18:33   ` John Johansen
2019-06-21 18:52 ` [PATCH v3 04/24] LSM: Create and manage the lsmblob data structure Casey Schaufler
2019-06-22 22:42   ` Kees Cook
2019-06-24 18:38   ` John Johansen
2019-06-21 18:52 ` [PATCH v3 05/24] Use lsmblob in security_audit_rule_match Casey Schaufler
2019-06-22 22:43   ` Kees Cook
2019-06-24 18:39   ` John Johansen
2019-06-21 18:52 ` [PATCH v3 06/24] LSM: Use lsmblob in security_kernel_act_as Casey Schaufler
2019-06-22 22:43   ` Kees Cook
2019-06-24 18:38   ` John Johansen
2019-06-21 18:52 ` [PATCH v3 07/24] net: Prepare UDS for secuirty module stacking Casey Schaufler
2019-06-22 22:43   ` Kees Cook
2019-06-24 18:39   ` John Johansen
2019-06-21 18:52 ` [PATCH v3 08/24] LSM: Use lsmblob in security_secctx_to_secid Casey Schaufler
2019-06-22 22:44   ` Kees Cook
2019-06-24 18:38   ` John Johansen
2019-06-21 18:52 ` [PATCH v3 09/24] LSM: Use lsmblob in security_secid_to_secctx Casey Schaufler
2019-06-22 22:44   ` Kees Cook
2019-06-24 18:39   ` John Johansen
2019-06-21 18:52 ` [PATCH v3 10/24] Use lsmblob in security_ipc_getsecid Casey Schaufler
2019-06-22 22:48   ` Kees Cook
2019-06-24 16:39     ` Casey Schaufler
2019-06-24 17:20       ` Casey Schaufler
2019-06-24 21:09       ` Kees Cook
2019-06-24 18:39   ` John Johansen
2019-06-21 18:52 ` [PATCH v3 11/24] LSM: Use lsmblob in security_task_getsecid Casey Schaufler
2019-06-22 22:49   ` Kees Cook
2019-06-24 18:40   ` John Johansen
2019-06-21 18:52 ` [PATCH v3 12/24] LSM: Use lsmblob in security_inode_getsecid Casey Schaufler
2019-06-22 22:49   ` Kees Cook
2019-06-24 18:40   ` John Johansen
2019-06-21 18:52 ` [PATCH v3 13/24] LSM: Use lsmblob in security_cred_getsecid Casey Schaufler
2019-06-22 22:50   ` Kees Cook
2019-06-24 18:40   ` John Johansen
2019-06-21 18:52 ` [PATCH v3 14/24] IMA: Change internal interfaces to use lsmblobs Casey Schaufler
2019-06-22 22:51   ` Kees Cook
2019-06-24 18:40   ` John Johansen
2019-06-21 18:52 ` [PATCH v3 15/24] LSM: Specify which LSM to display Casey Schaufler
2019-06-22 22:51   ` Kees Cook
2019-06-24 18:48   ` John Johansen
2019-06-21 18:52 ` [PATCH v3 16/24] LSM: Ensure the correct LSM context releaser Casey Schaufler
2019-06-22 22:52   ` Kees Cook
2019-06-24 21:46   ` John Johansen
2019-06-21 18:52 ` [PATCH v3 17/24] LSM: Use lsmcontext in security_secid_to_secctx Casey Schaufler
2019-06-22 22:52   ` Kees Cook
2019-06-24 21:46   ` John Johansen
2019-06-21 18:52 ` [PATCH v3 18/24] LSM: Use lsmcontext in security_dentry_init_security Casey Schaufler
2019-06-22 22:54   ` Kees Cook
2019-06-24 21:46   ` John Johansen
2019-06-21 18:52 ` [PATCH v3 19/24] LSM: Use lsmcontext in security_inode_getsecctx Casey Schaufler
2019-06-22 22:56   ` Kees Cook
2019-06-24 21:46   ` John Johansen
2019-06-21 18:52 ` [PATCH v3 20/24] LSM: security_secid_to_secctx in netlink netfilter Casey Schaufler
2019-06-22 22:57   ` Kees Cook
2019-06-24 21:47   ` John Johansen
2019-06-21 18:52 ` [PATCH v3 21/24] Audit: Store LSM audit information in an lsmblob Casey Schaufler
2019-06-22 23:12   ` Kees Cook
2019-06-24 21:33   ` John Johansen
2019-06-25  1:01     ` Casey Schaufler
2019-06-25  1:46       ` Paul Moore
2019-06-25  1:46         ` Paul Moore
2019-06-25  2:14         ` John Johansen
2019-06-25  2:14           ` John Johansen
2019-06-25  2:42           ` Paul Moore
2019-06-25  2:42             ` Paul Moore
2019-06-25 15:30             ` Casey Schaufler
2019-06-25 15:30               ` Casey Schaufler
2019-06-21 18:52 ` [PATCH v3 22/24] LSM: Return the lsmblob slot on initialization Casey Schaufler
2019-06-22 23:13   ` Kees Cook
2019-06-24 21:39     ` John Johansen
2019-06-24 21:50       ` Kees Cook
2019-06-24 21:53       ` Casey Schaufler
2019-06-24 21:47   ` John Johansen [this message]
2019-06-21 18:52 ` [PATCH v3 23/24] NET: Store LSM netlabel data in a lsmblob Casey Schaufler
2019-06-22 23:15   ` Kees Cook
2019-06-24 21:44   ` John Johansen
2019-06-21 18:52 ` [PATCH v3 24/24] AppArmor: Remove the exclusive flag Casey Schaufler
2019-06-22 23:15   ` Kees Cook
2019-06-24 21:45   ` John Johansen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=11e751ea-c93c-efe7-558e-632af59d2355@canonical.com \
    --to=john.johansen@canonical.com \
    --cc=casey.schaufler@intel.com \
    --cc=casey@schaufler-ca.com \
    --cc=jmorris@namei.org \
    --cc=keescook@chromium.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=paul@paul-moore.com \
    --cc=penguin-kernel@i-love.sakura.ne.jp \
    --cc=sds@tycho.nsa.gov \
    --cc=selinux@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.