From: Casey Schaufler <casey@schaufler-ca.com>
To: "José Bollo" <jose.bollo@open.eurogiciel.org>,
"James Morris" <james.l.morris@oracle.com>,
"Serge E. Hallyn" <serge@hallyn.com>,
linux-security-module <linux-security-module@vger.kernel.org>,
linux-kernel <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] Smack: getting the Smack security context of keys
Date: Wed, 25 Mar 2015 07:42:06 -0700 [thread overview]
Message-ID: <5512C93E.2010906@schaufler-ca.com> (raw)
In-Reply-To: <1424184082.12824.10.camel@open.eurogiciel.org>
On 2/17/2015 6:41 AM, José Bollo wrote:
> With this commit, the LSM Smack implements the LSM
> side part of the system call keyctl with the action
> code KEYCTL_GET_SECURITY.
>
> It is now possible to get the context of, for example,
> the user session key using the command "keyctl security @s".
>
> Signed-off-by: José Bollo <jose.bollo@open.eurogiciel.org>
Applied to git://git.gitorious.org/smack-next/kernel.git#smack-for-4.1
> ---
> security/smack/smack_lsm.c | 30 ++++++++++++++++++++++++++++++
> 1 file changed, 30 insertions(+)
>
> diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c
> index fa64740..c1ff996 100644
> --- a/security/smack/smack_lsm.c
> +++ b/security/smack/smack_lsm.c
> @@ -3208,6 +3208,35 @@ static int smack_key_permission(key_ref_t
> key_ref,
> return smk_access(tsp, keyp->security,
> MAY_READWRITE, &ad);
> }
> +
> +/*
> + * smack_key_getsecurity - Smack label tagging the key
> + * @key points to the key to be queried
> + * @_buffer points to a pointer that should be set to point to the
> + * resulting string (if no label or an error occurs).
> + * Return the length of the string (including terminating NUL) or -ve
> if
> + * an error.
> + * May also return 0 (and a NULL buffer pointer) if there is no label.
> + */
> +static int smack_key_getsecurity(struct key *key, char **_buffer)
> +{
> + int length;
> + char *copy;
> +
> + if (key->security == NULL) {
> + *_buffer = NULL;
> + return 0;
> + }
> +
> + length = (int)strlen(key->security) + 1;
> + copy = kmalloc((size_t)length, GFP_KERNEL);
> + if (copy == NULL)
> + return -ENOMEM;
> +
> + memcpy(copy, key->security, (size_t)length);
> + *_buffer = copy;
> + return length;
> +}
> #endif /* CONFIG_KEYS */
>
> /*
> @@ -3514,6 +3543,7 @@ struct security_operations smack_ops = {
> .key_alloc = smack_key_alloc,
> .key_free = smack_key_free,
> .key_permission = smack_key_permission,
> + .key_getsecurity = smack_key_getsecurity,
> #endif /* CONFIG_KEYS */
>
> /* Audit hooks */
prev parent reply other threads:[~2015-03-25 14:42 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-02-17 14:41 [PATCH] Smack: getting the Smack security context of keys José Bollo
2015-03-25 14:42 ` Casey Schaufler [this message]
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=5512C93E.2010906@schaufler-ca.com \
--to=casey@schaufler-ca.com \
--cc=james.l.morris@oracle.com \
--cc=jose.bollo@open.eurogiciel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-security-module@vger.kernel.org \
--cc=serge@hallyn.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox