linux-security-module.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kees Cook <keescook@chromium.org>
To: Micah Morton <mortonm@chromium.org>
Cc: linux-security-module@vger.kernel.org, thomascedeno@google.com
Subject: Re: [PATCH] security: Add LSM hooks to set*gid syscalls
Date: Fri, 5 Jun 2020 14:25:51 -0700	[thread overview]
Message-ID: <202006051421.2168E5AA8@keescook> (raw)
In-Reply-To: <20200605193805.36531-1-mortonm@chromium.org>

On Fri, Jun 05, 2020 at 12:38:05PM -0700, Micah Morton wrote:
> The SafeSetID LSM uses the security_task_fix_setuid hook to filter
> set*uid() syscalls according to its configured security policy. In
> preparation for adding analagous support in the LSM for set*gid()
> syscalls, we add the requisite hook here. Tested by putting print
> statements in the security_task_fix_setgid hook and seeing them get hit
> during kernel boot.
> 
> From: Thomas Cedeno <thomascedeno@google.com>

^^^ this line should be before the commit log body (many tools won't
find it here).

> Signed-off-by: Thomas Cedeno <thomascedeno@google.com>
> Reviewed-by: Micah Morton <mortonm@chromium.org>
> ---
> NOTE: I (Micah) will send this patch as a pull request to Linus through
> my SafeSetID tree if there are no objections.
>  include/linux/lsm_hook_defs.h |  2 ++
>  include/linux/lsm_hooks.h     |  9 +++++++++
>  include/linux/security.h      |  9 +++++++++
>  kernel/sys.c                  | 15 ++++++++++++++-
>  security/security.c           |  6 ++++++
>  5 files changed, 40 insertions(+), 1 deletion(-)
> 
> diff --git a/include/linux/lsm_hook_defs.h b/include/linux/lsm_hook_defs.h
> index fb3ce6cec997..d5401c09f2d3 100644
> --- a/include/linux/lsm_hook_defs.h
> +++ b/include/linux/lsm_hook_defs.h
> @@ -191,6 +191,8 @@ LSM_HOOK(int, 0, kernel_post_read_file, struct file *file, char *buf,
>  	 loff_t size, enum kernel_read_file_id id)
>  LSM_HOOK(int, 0, task_fix_setuid, struct cred *new, const struct cred *old,
>  	 int flags)
> +LSM_HOOK(int, 0, task_fix_setgid, struct cred *new, const struct cred * old,
> +	 int flags)
>  LSM_HOOK(int, 0, task_setpgid, struct task_struct *p, pid_t pgid)
>  LSM_HOOK(int, 0, task_getpgid, struct task_struct *p)
>  LSM_HOOK(int, 0, task_getsid, struct task_struct *p)
> diff --git a/include/linux/lsm_hooks.h b/include/linux/lsm_hooks.h
> index 3e62dab77699..8012b610fe53 100644
> --- a/include/linux/lsm_hooks.h
> +++ b/include/linux/lsm_hooks.h
> @@ -659,6 +659,15 @@
>   *	@old is the set of credentials that are being replaces
>   *	@flags contains one of the LSM_SETID_* values.
>   *	Return 0 on success.
> + * @task_fix_setgid:
> + *     Update the module's state after setting one or more of the group
> + *     identity attributes of the current process.  The @flags parameter
> + *     indicates which of the set*gid system calls invoked this hook.
> + *     @new is the set of credentials that will be installed.  Modifications
> + *     should be made to this rather than to @current->cred.
> + *     @old is the set of credentials that are being replaced.
> + *     @flags contains one of the LSM_SETID_* values.
> + *     Return 0 on success.

The indenting here appears to be using spaces instead of a tab.

Everything else looks okay. (There are a surprising number of gid
changing places...)

-- 
Kees Cook

  reply	other threads:[~2020-06-05 21:25 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-05 19:38 [PATCH] security: Add LSM hooks to set*gid syscalls Micah Morton
2020-06-05 21:25 ` Kees Cook [this message]
2020-06-05 22:51   ` Micah Morton

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=202006051421.2168E5AA8@keescook \
    --to=keescook@chromium.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=mortonm@chromium.org \
    --cc=thomascedeno@google.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;
as well as URLs for NNTP newsgroup(s).