* [PATCH] selinux: check sidtab limit before adding a new entry
@ 2019-07-22 13:21 Ondrej Mosnacek
2019-07-22 14:17 ` William Roberts
2019-07-22 16:50 ` Kees Cook
0 siblings, 2 replies; 10+ messages in thread
From: Ondrej Mosnacek @ 2019-07-22 13:21 UTC (permalink / raw)
To: selinux, Paul Moore; +Cc: NitinGote, kernel-hardening, Kees Cook
We need to error out when trying to add an entry above SIDTAB_MAX in
sidtab_reverse_lookup() to avoid overflow on the odd chance that this
happens.
Fixes: ee1a84fdfeed ("selinux: overhaul sidtab to fix bug and improve performance")
Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
---
security/selinux/ss/sidtab.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/security/selinux/ss/sidtab.c b/security/selinux/ss/sidtab.c
index e63a90ff2728..54c1ba1e79ab 100644
--- a/security/selinux/ss/sidtab.c
+++ b/security/selinux/ss/sidtab.c
@@ -286,6 +286,11 @@ static int sidtab_reverse_lookup(struct sidtab *s, struct context *context,
++count;
}
+ /* bail out if we already reached max entries */
+ rc = -ENOMEM;
+ if (count == SIDTAB_MAX)
+ goto out_unlock;
+
/* insert context into new entry */
rc = -ENOMEM;
dst = sidtab_do_lookup(s, count, 1);
--
2.21.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH] selinux: check sidtab limit before adding a new entry
2019-07-22 13:21 [PATCH] selinux: check sidtab limit before adding a new entry Ondrej Mosnacek
@ 2019-07-22 14:17 ` William Roberts
2019-07-22 16:50 ` Kees Cook
1 sibling, 0 replies; 10+ messages in thread
From: William Roberts @ 2019-07-22 14:17 UTC (permalink / raw)
To: Ondrej Mosnacek
Cc: selinux, Paul Moore, NitinGote, kernel-hardening, Kees Cook
On Mon, Jul 22, 2019 at 8:34 AM Ondrej Mosnacek <omosnace@redhat.com> wrote:
>
> We need to error out when trying to add an entry above SIDTAB_MAX in
> sidtab_reverse_lookup() to avoid overflow on the odd chance that this
> happens.
>
> Fixes: ee1a84fdfeed ("selinux: overhaul sidtab to fix bug and improve performance")
> Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
> ---
> security/selinux/ss/sidtab.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/security/selinux/ss/sidtab.c b/security/selinux/ss/sidtab.c
> index e63a90ff2728..54c1ba1e79ab 100644
> --- a/security/selinux/ss/sidtab.c
> +++ b/security/selinux/ss/sidtab.c
> @@ -286,6 +286,11 @@ static int sidtab_reverse_lookup(struct sidtab *s, struct context *context,
> ++count;
> }
>
> + /* bail out if we already reached max entries */
> + rc = -ENOMEM;
Wouldn't -EOVERFLOW be better?
> + if (count == SIDTAB_MAX)
> + goto out_unlock;
> +
> /* insert context into new entry */
> rc = -ENOMEM;
> dst = sidtab_do_lookup(s, count, 1);
> --
> 2.21.0
>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] selinux: check sidtab limit before adding a new entry
@ 2019-07-22 14:17 ` William Roberts
0 siblings, 0 replies; 10+ messages in thread
From: William Roberts @ 2019-07-22 14:17 UTC (permalink / raw)
To: Ondrej Mosnacek
Cc: selinux, Paul Moore, NitinGote, kernel-hardening, Kees Cook
On Mon, Jul 22, 2019 at 8:34 AM Ondrej Mosnacek <omosnace@redhat.com> wrote:
>
> We need to error out when trying to add an entry above SIDTAB_MAX in
> sidtab_reverse_lookup() to avoid overflow on the odd chance that this
> happens.
>
> Fixes: ee1a84fdfeed ("selinux: overhaul sidtab to fix bug and improve performance")
> Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
> ---
> security/selinux/ss/sidtab.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/security/selinux/ss/sidtab.c b/security/selinux/ss/sidtab.c
> index e63a90ff2728..54c1ba1e79ab 100644
> --- a/security/selinux/ss/sidtab.c
> +++ b/security/selinux/ss/sidtab.c
> @@ -286,6 +286,11 @@ static int sidtab_reverse_lookup(struct sidtab *s, struct context *context,
> ++count;
> }
>
> + /* bail out if we already reached max entries */
> + rc = -ENOMEM;
Wouldn't -EOVERFLOW be better?
> + if (count == SIDTAB_MAX)
> + goto out_unlock;
> +
> /* insert context into new entry */
> rc = -ENOMEM;
> dst = sidtab_do_lookup(s, count, 1);
> --
> 2.21.0
>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] selinux: check sidtab limit before adding a new entry
2019-07-22 13:21 [PATCH] selinux: check sidtab limit before adding a new entry Ondrej Mosnacek
2019-07-22 14:17 ` William Roberts
@ 2019-07-22 16:50 ` Kees Cook
2019-07-23 0:36 ` Paul Moore
2019-07-23 6:48 ` Ondrej Mosnacek
1 sibling, 2 replies; 10+ messages in thread
From: Kees Cook @ 2019-07-22 16:50 UTC (permalink / raw)
To: Ondrej Mosnacek
Cc: selinux, Paul Moore, NitinGote, kernel-hardening, linux-security-module
On Mon, Jul 22, 2019 at 03:21:11PM +0200, Ondrej Mosnacek wrote:
> We need to error out when trying to add an entry above SIDTAB_MAX in
> sidtab_reverse_lookup() to avoid overflow on the odd chance that this
> happens.
>
> Fixes: ee1a84fdfeed ("selinux: overhaul sidtab to fix bug and improve performance")
> Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
Is this reachable from unprivileged userspace?
> ---
> security/selinux/ss/sidtab.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/security/selinux/ss/sidtab.c b/security/selinux/ss/sidtab.c
> index e63a90ff2728..54c1ba1e79ab 100644
> --- a/security/selinux/ss/sidtab.c
> +++ b/security/selinux/ss/sidtab.c
> @@ -286,6 +286,11 @@ static int sidtab_reverse_lookup(struct sidtab *s, struct context *context,
> ++count;
> }
>
> + /* bail out if we already reached max entries */
> + rc = -ENOMEM;
> + if (count == SIDTAB_MAX)
Do you want to use >= here instead?
-Kees
> + goto out_unlock;
> +
> /* insert context into new entry */
> rc = -ENOMEM;
> dst = sidtab_do_lookup(s, count, 1);
> --
> 2.21.0
>
--
Kees Cook
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] selinux: check sidtab limit before adding a new entry
2019-07-22 16:50 ` Kees Cook
@ 2019-07-23 0:36 ` Paul Moore
2019-07-23 6:48 ` Ondrej Mosnacek
1 sibling, 0 replies; 10+ messages in thread
From: Paul Moore @ 2019-07-23 0:36 UTC (permalink / raw)
To: Kees Cook
Cc: Ondrej Mosnacek, selinux, NitinGote, kernel-hardening,
linux-security-module
On Mon, Jul 22, 2019 at 12:50 PM Kees Cook <keescook@chromium.org> wrote:
> On Mon, Jul 22, 2019 at 03:21:11PM +0200, Ondrej Mosnacek wrote:
> > We need to error out when trying to add an entry above SIDTAB_MAX in
> > sidtab_reverse_lookup() to avoid overflow on the odd chance that this
> > happens.
> >
> > Fixes: ee1a84fdfeed ("selinux: overhaul sidtab to fix bug and improve performance")
> > Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
>
> Is this reachable from unprivileged userspace?
I believe it's reachable via selinuxfs under /sys/fs/selinux/context,
and the DAC permissions are for the relevant files are 0666, but the
SELinux policy might restrict that.
> > ---
> > security/selinux/ss/sidtab.c | 5 +++++
> > 1 file changed, 5 insertions(+)
> >
> > diff --git a/security/selinux/ss/sidtab.c b/security/selinux/ss/sidtab.c
> > index e63a90ff2728..54c1ba1e79ab 100644
> > --- a/security/selinux/ss/sidtab.c
> > +++ b/security/selinux/ss/sidtab.c
> > @@ -286,6 +286,11 @@ static int sidtab_reverse_lookup(struct sidtab *s, struct context *context,
> > ++count;
> > }
> >
> > + /* bail out if we already reached max entries */
> > + rc = -ENOMEM;
> > + if (count == SIDTAB_MAX)
>
> Do you want to use >= here instead?
Yes, definitely.
--
paul moore
www.paul-moore.com
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] selinux: check sidtab limit before adding a new entry
@ 2019-07-23 0:36 ` Paul Moore
0 siblings, 0 replies; 10+ messages in thread
From: Paul Moore @ 2019-07-23 0:36 UTC (permalink / raw)
To: Kees Cook
Cc: Ondrej Mosnacek, selinux, NitinGote, kernel-hardening,
linux-security-module
On Mon, Jul 22, 2019 at 12:50 PM Kees Cook <keescook@chromium.org> wrote:
> On Mon, Jul 22, 2019 at 03:21:11PM +0200, Ondrej Mosnacek wrote:
> > We need to error out when trying to add an entry above SIDTAB_MAX in
> > sidtab_reverse_lookup() to avoid overflow on the odd chance that this
> > happens.
> >
> > Fixes: ee1a84fdfeed ("selinux: overhaul sidtab to fix bug and improve performance")
> > Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
>
> Is this reachable from unprivileged userspace?
I believe it's reachable via selinuxfs under /sys/fs/selinux/context,
and the DAC permissions are for the relevant files are 0666, but the
SELinux policy might restrict that.
> > ---
> > security/selinux/ss/sidtab.c | 5 +++++
> > 1 file changed, 5 insertions(+)
> >
> > diff --git a/security/selinux/ss/sidtab.c b/security/selinux/ss/sidtab.c
> > index e63a90ff2728..54c1ba1e79ab 100644
> > --- a/security/selinux/ss/sidtab.c
> > +++ b/security/selinux/ss/sidtab.c
> > @@ -286,6 +286,11 @@ static int sidtab_reverse_lookup(struct sidtab *s, struct context *context,
> > ++count;
> > }
> >
> > + /* bail out if we already reached max entries */
> > + rc = -ENOMEM;
> > + if (count == SIDTAB_MAX)
>
> Do you want to use >= here instead?
Yes, definitely.
--
paul moore
www.paul-moore.com
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] selinux: check sidtab limit before adding a new entry
2019-07-22 14:17 ` William Roberts
@ 2019-07-23 6:48 ` Ondrej Mosnacek
-1 siblings, 0 replies; 10+ messages in thread
From: Ondrej Mosnacek @ 2019-07-23 6:48 UTC (permalink / raw)
To: William Roberts
Cc: SElinux list, Paul Moore, NitinGote, kernel-hardening, Kees Cook
On Mon, Jul 22, 2019 at 4:17 PM William Roberts
<bill.c.roberts@gmail.com> wrote:
> On Mon, Jul 22, 2019 at 8:34 AM Ondrej Mosnacek <omosnace@redhat.com> wrote:
> >
> > We need to error out when trying to add an entry above SIDTAB_MAX in
> > sidtab_reverse_lookup() to avoid overflow on the odd chance that this
> > happens.
> >
> > Fixes: ee1a84fdfeed ("selinux: overhaul sidtab to fix bug and improve performance")
> > Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
> > ---
> > security/selinux/ss/sidtab.c | 5 +++++
> > 1 file changed, 5 insertions(+)
> >
> > diff --git a/security/selinux/ss/sidtab.c b/security/selinux/ss/sidtab.c
> > index e63a90ff2728..54c1ba1e79ab 100644
> > --- a/security/selinux/ss/sidtab.c
> > +++ b/security/selinux/ss/sidtab.c
> > @@ -286,6 +286,11 @@ static int sidtab_reverse_lookup(struct sidtab *s, struct context *context,
> > ++count;
> > }
> >
> > + /* bail out if we already reached max entries */
> > + rc = -ENOMEM;
>
> Wouldn't -EOVERFLOW be better?
Good point. Will change it in v2.
>
> > + if (count == SIDTAB_MAX)
> > + goto out_unlock;
> > +
> > /* insert context into new entry */
> > rc = -ENOMEM;
> > dst = sidtab_do_lookup(s, count, 1);
> > --
> > 2.21.0
> >
Thanks,
--
Ondrej Mosnacek <omosnace at redhat dot com>
Software Engineer, Security Technologies
Red Hat, Inc.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] selinux: check sidtab limit before adding a new entry
@ 2019-07-23 6:48 ` Ondrej Mosnacek
0 siblings, 0 replies; 10+ messages in thread
From: Ondrej Mosnacek @ 2019-07-23 6:48 UTC (permalink / raw)
To: William Roberts
Cc: SElinux list, Paul Moore, NitinGote, kernel-hardening, Kees Cook
On Mon, Jul 22, 2019 at 4:17 PM William Roberts
<bill.c.roberts@gmail.com> wrote:
> On Mon, Jul 22, 2019 at 8:34 AM Ondrej Mosnacek <omosnace@redhat.com> wrote:
> >
> > We need to error out when trying to add an entry above SIDTAB_MAX in
> > sidtab_reverse_lookup() to avoid overflow on the odd chance that this
> > happens.
> >
> > Fixes: ee1a84fdfeed ("selinux: overhaul sidtab to fix bug and improve performance")
> > Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
> > ---
> > security/selinux/ss/sidtab.c | 5 +++++
> > 1 file changed, 5 insertions(+)
> >
> > diff --git a/security/selinux/ss/sidtab.c b/security/selinux/ss/sidtab.c
> > index e63a90ff2728..54c1ba1e79ab 100644
> > --- a/security/selinux/ss/sidtab.c
> > +++ b/security/selinux/ss/sidtab.c
> > @@ -286,6 +286,11 @@ static int sidtab_reverse_lookup(struct sidtab *s, struct context *context,
> > ++count;
> > }
> >
> > + /* bail out if we already reached max entries */
> > + rc = -ENOMEM;
>
> Wouldn't -EOVERFLOW be better?
Good point. Will change it in v2.
>
> > + if (count == SIDTAB_MAX)
> > + goto out_unlock;
> > +
> > /* insert context into new entry */
> > rc = -ENOMEM;
> > dst = sidtab_do_lookup(s, count, 1);
> > --
> > 2.21.0
> >
Thanks,
--
Ondrej Mosnacek <omosnace at redhat dot com>
Software Engineer, Security Technologies
Red Hat, Inc.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] selinux: check sidtab limit before adding a new entry
2019-07-22 16:50 ` Kees Cook
@ 2019-07-23 6:48 ` Ondrej Mosnacek
2019-07-23 6:48 ` Ondrej Mosnacek
1 sibling, 0 replies; 10+ messages in thread
From: Ondrej Mosnacek @ 2019-07-23 6:48 UTC (permalink / raw)
To: Kees Cook
Cc: SElinux list, Paul Moore, NitinGote, kernel-hardening,
Linux Security Module list
On Mon, Jul 22, 2019 at 6:50 PM Kees Cook <keescook@chromium.org> wrote:
> On Mon, Jul 22, 2019 at 03:21:11PM +0200, Ondrej Mosnacek wrote:
> > We need to error out when trying to add an entry above SIDTAB_MAX in
> > sidtab_reverse_lookup() to avoid overflow on the odd chance that this
> > happens.
> >
> > Fixes: ee1a84fdfeed ("selinux: overhaul sidtab to fix bug and improve performance")
> > Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
>
> Is this reachable from unprivileged userspace?
>
> > ---
> > security/selinux/ss/sidtab.c | 5 +++++
> > 1 file changed, 5 insertions(+)
> >
> > diff --git a/security/selinux/ss/sidtab.c b/security/selinux/ss/sidtab.c
> > index e63a90ff2728..54c1ba1e79ab 100644
> > --- a/security/selinux/ss/sidtab.c
> > +++ b/security/selinux/ss/sidtab.c
> > @@ -286,6 +286,11 @@ static int sidtab_reverse_lookup(struct sidtab *s, struct context *context,
> > ++count;
> > }
> >
> > + /* bail out if we already reached max entries */
> > + rc = -ENOMEM;
> > + if (count == SIDTAB_MAX)
>
> Do you want to use >= here instead?
Makes sense. Also staged for v2.
>
> -Kees
>
> > + goto out_unlock;
> > +
> > /* insert context into new entry */
> > rc = -ENOMEM;
> > dst = sidtab_do_lookup(s, count, 1);
> > --
> > 2.21.0
> >
>
> --
> Kees Cook
Thanks,
--
Ondrej Mosnacek <omosnace at redhat dot com>
Software Engineer, Security Technologies
Red Hat, Inc.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] selinux: check sidtab limit before adding a new entry
@ 2019-07-23 6:48 ` Ondrej Mosnacek
0 siblings, 0 replies; 10+ messages in thread
From: Ondrej Mosnacek @ 2019-07-23 6:48 UTC (permalink / raw)
To: Kees Cook
Cc: SElinux list, Paul Moore, NitinGote, kernel-hardening,
Linux Security Module list
On Mon, Jul 22, 2019 at 6:50 PM Kees Cook <keescook@chromium.org> wrote:
> On Mon, Jul 22, 2019 at 03:21:11PM +0200, Ondrej Mosnacek wrote:
> > We need to error out when trying to add an entry above SIDTAB_MAX in
> > sidtab_reverse_lookup() to avoid overflow on the odd chance that this
> > happens.
> >
> > Fixes: ee1a84fdfeed ("selinux: overhaul sidtab to fix bug and improve performance")
> > Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
>
> Is this reachable from unprivileged userspace?
>
> > ---
> > security/selinux/ss/sidtab.c | 5 +++++
> > 1 file changed, 5 insertions(+)
> >
> > diff --git a/security/selinux/ss/sidtab.c b/security/selinux/ss/sidtab.c
> > index e63a90ff2728..54c1ba1e79ab 100644
> > --- a/security/selinux/ss/sidtab.c
> > +++ b/security/selinux/ss/sidtab.c
> > @@ -286,6 +286,11 @@ static int sidtab_reverse_lookup(struct sidtab *s, struct context *context,
> > ++count;
> > }
> >
> > + /* bail out if we already reached max entries */
> > + rc = -ENOMEM;
> > + if (count == SIDTAB_MAX)
>
> Do you want to use >= here instead?
Makes sense. Also staged for v2.
>
> -Kees
>
> > + goto out_unlock;
> > +
> > /* insert context into new entry */
> > rc = -ENOMEM;
> > dst = sidtab_do_lookup(s, count, 1);
> > --
> > 2.21.0
> >
>
> --
> Kees Cook
Thanks,
--
Ondrej Mosnacek <omosnace at redhat dot com>
Software Engineer, Security Technologies
Red Hat, Inc.
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2019-07-23 12:30 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-22 13:21 [PATCH] selinux: check sidtab limit before adding a new entry Ondrej Mosnacek
2019-07-22 14:17 ` William Roberts
2019-07-22 14:17 ` William Roberts
2019-07-23 6:48 ` Ondrej Mosnacek
2019-07-23 6:48 ` Ondrej Mosnacek
2019-07-22 16:50 ` Kees Cook
2019-07-23 0:36 ` Paul Moore
2019-07-23 0:36 ` Paul Moore
2019-07-23 6:48 ` Ondrej Mosnacek
2019-07-23 6:48 ` Ondrej Mosnacek
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.