diff mbox series

[10/10] LSM: SafeSetID: fix use of literal -1 in capable hook

Message ID 20190410165627.212572-1-mortonm@chromium.org (mailing list archive)
State New, archived
Headers show
Series [01/10] LSM: SafeSetID: fix pr_warn() to include newline | expand

Commit Message

Micah Morton April 10, 2019, 4:56 p.m. UTC
From: Jann Horn <jannh@google.com>

The capable() hook returns an error number. -EPERM is actually the same as
-1, so this doesn't make a difference in behavior.

Signed-off-by: Jann Horn <jannh@google.com>
Signed-off-by: Micah Morton <mortonm@chromium.org>
---
 security/safesetid/lsm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Kees Cook April 10, 2019, 5:28 p.m. UTC | #1
On Wed, Apr 10, 2019 at 9:56 AM Micah Morton <mortonm@chromium.org> wrote:
>
> From: Jann Horn <jannh@google.com>
>
> The capable() hook returns an error number. -EPERM is actually the same as
> -1, so this doesn't make a difference in behavior.
>
> Signed-off-by: Jann Horn <jannh@google.com>
> Signed-off-by: Micah Morton <mortonm@chromium.org>

Reviewed-by: Kees Cook <keescook@chromium.org>

-Kees

> ---
>  security/safesetid/lsm.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/security/safesetid/lsm.c b/security/safesetid/lsm.c
> index 4ab4d7cdba31..61b84e20f2dd 100644
> --- a/security/safesetid/lsm.c
> +++ b/security/safesetid/lsm.c
> @@ -90,7 +90,7 @@ static int safesetid_security_capable(const struct cred *cred,
>          */
>         pr_warn("Operation requires CAP_SETUID, which is not available to UID %u for operations besides approved set*uid transitions\n",
>                 __kuid_val(cred->uid));
> -       return -1;
> +       return -EPERM;
>  }
>
>  /*
> --
> 2.21.0.392.gf8f6787159e-goog
>
Micah Morton May 7, 2019, 3:03 p.m. UTC | #2
Ready for merge.

On Wed, Apr 10, 2019 at 10:29 AM Kees Cook <keescook@chromium.org> wrote:
>
> On Wed, Apr 10, 2019 at 9:56 AM Micah Morton <mortonm@chromium.org> wrote:
> >
> > From: Jann Horn <jannh@google.com>
> >
> > The capable() hook returns an error number. -EPERM is actually the same as
> > -1, so this doesn't make a difference in behavior.
> >
> > Signed-off-by: Jann Horn <jannh@google.com>
> > Signed-off-by: Micah Morton <mortonm@chromium.org>
>
> Reviewed-by: Kees Cook <keescook@chromium.org>
>
> -Kees
>
> > ---
> >  security/safesetid/lsm.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/security/safesetid/lsm.c b/security/safesetid/lsm.c
> > index 4ab4d7cdba31..61b84e20f2dd 100644
> > --- a/security/safesetid/lsm.c
> > +++ b/security/safesetid/lsm.c
> > @@ -90,7 +90,7 @@ static int safesetid_security_capable(const struct cred *cred,
> >          */
> >         pr_warn("Operation requires CAP_SETUID, which is not available to UID %u for operations besides approved set*uid transitions\n",
> >                 __kuid_val(cred->uid));
> > -       return -1;
> > +       return -EPERM;
> >  }
> >
> >  /*
> > --
> > 2.21.0.392.gf8f6787159e-goog
> >
>
>
> --
> Kees Cook
diff mbox series

Patch

diff --git a/security/safesetid/lsm.c b/security/safesetid/lsm.c
index 4ab4d7cdba31..61b84e20f2dd 100644
--- a/security/safesetid/lsm.c
+++ b/security/safesetid/lsm.c
@@ -90,7 +90,7 @@  static int safesetid_security_capable(const struct cred *cred,
 	 */
 	pr_warn("Operation requires CAP_SETUID, which is not available to UID %u for operations besides approved set*uid transitions\n",
 		__kuid_val(cred->uid));
-	return -1;
+	return -EPERM;
 }
 
 /*