All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stephen Smalley <sds@tycho.nsa.gov>
To: Ondrej Mosnacek <omosnace@redhat.com>,
	selinux@vger.kernel.org, Paul Moore <paul@paul-moore.com>
Cc: linux-audit@redhat.com
Subject: Re: [PATCH v3 2/4] selinux: replace some BUG_ON()s with a WARN_ON()
Date: Fri, 25 Jan 2019 09:52:40 -0500	[thread overview]
Message-ID: <8987cae9-327f-96b7-f598-2dec47097f31@tycho.nsa.gov> (raw)
In-Reply-To: <20190125100651.21753-3-omosnace@redhat.com>

On 1/25/19 5:06 AM, Ondrej Mosnacek wrote:
> We don't need to crash the machine in these cases. Let's just detect the
> buggy state early and error out with a warning.
> 
> Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>

Reviewed-by: Stephen Smalley <sds@tycho.nsa.gov>

> ---
>   security/selinux/avc.c | 5 +++--
>   1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/security/selinux/avc.c b/security/selinux/avc.c
> index 502162eeb3a0..5ebad47391c9 100644
> --- a/security/selinux/avc.c
> +++ b/security/selinux/avc.c
> @@ -678,7 +678,6 @@ static void avc_audit_pre_callback(struct audit_buffer *ab, void *a)
>   		return;
>   	}
>   
> -	BUG_ON(!sad->tclass || sad->tclass >= ARRAY_SIZE(secclass_map));
>   	perms = secclass_map[sad->tclass-1].perms;
>   
>   	audit_log_string(ab, " {");
> @@ -731,7 +730,6 @@ static void avc_audit_post_callback(struct audit_buffer *ab, void *a)
>   		kfree(scontext);
>   	}
>   
> -	BUG_ON(!sad->tclass || sad->tclass >= ARRAY_SIZE(secclass_map));
>   	audit_log_format(ab, " tclass=%s", secclass_map[sad->tclass-1].name);
>   
>   	if (sad->denied)
> @@ -748,6 +746,9 @@ noinline int slow_avc_audit(struct selinux_state *state,
>   	struct common_audit_data stack_data;
>   	struct selinux_audit_data sad;
>   
> +	if (WARN_ON(!tclass || tclass >= ARRAY_SIZE(secclass_map)))
> +		return -EINVAL;
> +
>   	if (!a) {
>   		a = &stack_data;
>   		a->type = LSM_AUDIT_DATA_NONE;
> 


  reply	other threads:[~2019-01-25 14:49 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-25 10:06 [PATCH v3 0/4] Report raw context in AVCs + refactoring Ondrej Mosnacek
2019-01-25 10:06 ` Ondrej Mosnacek
2019-01-25 10:06 ` [PATCH v3 1/4] selinux: inline some AVC functions used only once Ondrej Mosnacek
2019-01-25 10:06   ` Ondrej Mosnacek
2019-01-25 14:49   ` Stephen Smalley
2019-01-25 22:11   ` Paul Moore
2019-01-25 22:11     ` Paul Moore
2019-01-25 10:06 ` [PATCH v3 2/4] selinux: replace some BUG_ON()s with a WARN_ON() Ondrej Mosnacek
2019-01-25 10:06   ` Ondrej Mosnacek
2019-01-25 14:52   ` Stephen Smalley [this message]
2019-01-25 22:26   ` Paul Moore
2019-01-25 22:26     ` Paul Moore
2019-01-25 10:06 ` [PATCH v3 3/4] selinux: remove some useless BUG_ONs Ondrej Mosnacek
2019-01-25 10:06   ` Ondrej Mosnacek
2019-01-25 13:52   ` Stephen Smalley
2019-01-25 15:55     ` Ondrej Mosnacek
2019-01-25 15:55       ` Ondrej Mosnacek
2019-01-25 22:36       ` Paul Moore
2019-01-25 22:36         ` Paul Moore
2019-01-25 10:06 ` [PATCH v3 4/4] selinux: log invalid contexts in AVCs Ondrej Mosnacek
2019-01-25 10:06   ` Ondrej Mosnacek
2019-01-25 14:56   ` Stephen Smalley
2019-01-25 14:56     ` Stephen Smalley
2019-01-25 22:35   ` Paul Moore
2019-01-25 22:35     ` Paul Moore

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=8987cae9-327f-96b7-f598-2dec47097f31@tycho.nsa.gov \
    --to=sds@tycho.nsa.gov \
    --cc=linux-audit@redhat.com \
    --cc=omosnace@redhat.com \
    --cc=paul@paul-moore.com \
    --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.