lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAKwvOdkdy10K+6Jw=Sd4PxrvQgc=HssoJqJN9q8NVWkWiuZtRQ@mail.gmail.com>
Date:   Mon, 15 Jun 2020 11:23:44 -0700
From:   Nick Desaulniers <ndesaulniers@...gle.com>
To:     Kees Cook <keescook@...omium.org>
Cc:     Sami Tolvanen <samitolvanen@...gle.com>,
        James Morris <jamorris@...ux.microsoft.com>,
        David Howells <dhowells@...hat.com>,
        "Eric W. Biederman" <ebiederm@...ssion.com>,
        KP Singh <kpsingh@...gle.com>,
        Casey Schaufler <casey@...aufler-ca.com>,
        Thomas Cedeno <thomascedeno@...gle.com>,
        Anders Roxell <anders.roxell@...aro.org>,
        LKML <linux-kernel@...r.kernel.org>,
        clang-built-linux <clang-built-linux@...glegroups.com>
Subject: Re: [PATCH] security: fix the key_permission LSM hook function type

On Mon, Jun 15, 2020 at 11:21 AM Kees Cook <keescook@...omium.org> wrote:
>
> On Mon, Jun 15, 2020 at 11:12:32AM -0700, Sami Tolvanen wrote:
> > Commit 8c0637e950d6 ("keys: Make the KEY_NEED_* perms an enum rather than
> > a mask") changed the type of the key_permission callback functions, but
> > didn't change the type of the hook, which trips indirect call checking with
> > Control-Flow Integrity (CFI). This change fixes the issue by changing the
> > hook type to match the functions.
> >
> > Fixes: 8c0637e950d6 ("keys: Make the KEY_NEED_* perms an enum rather than a mask")
> > Signed-off-by: Sami Tolvanen <samitolvanen@...gle.com>
>
> Thanks for fixing this!
>
> Acked-by: Kees Cook <keescook@...omium.org>
>
> I wonder if there is any compiler option we can turn on to catch the
> implicit enum/int casting that would help for these kinds of things
> without absolutely exploding the build warnings.
>
> I see -Wenum-conversion, but that seems to be between enums, not between
> int.
>
> I see this, but it's external:
> https://noamlewis.wordpress.com/2017/10/05/type-safe-enums-in-c-using-a-clang-plugin/

Unfortunately, using a looser integral type is the typical workaround
for -Wenum-conversion warnings (which is on by default, GCC recently
added that flag, too).  For warning on enum to int, the kernel would
probably blow up with warnings. I don't know of any such existing
warning flag.

>
> -Kees
>
> > ---
> >  include/linux/lsm_hook_defs.h | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/include/linux/lsm_hook_defs.h b/include/linux/lsm_hook_defs.h
> > index 6791813cd439..24f6683f1cfc 100644
> > --- a/include/linux/lsm_hook_defs.h
> > +++ b/include/linux/lsm_hook_defs.h
> > @@ -360,7 +360,7 @@ LSM_HOOK(int, 0, key_alloc, struct key *key, const struct cred *cred,
> >        unsigned long flags)
> >  LSM_HOOK(void, LSM_RET_VOID, key_free, struct key *key)
> >  LSM_HOOK(int, 0, key_permission, key_ref_t key_ref, const struct cred *cred,
> > -      unsigned perm)
> > +      enum key_need_perm need_perm)
> >  LSM_HOOK(int, 0, key_getsecurity, struct key *key, char **_buffer)
> >  #endif /* CONFIG_KEYS */
> >
> >
> > base-commit: b3a9e3b9622ae10064826dccb4f7a52bd88c7407
> > --
> > 2.27.0.290.gba653c62da-goog
> >
>
> --
> Kees Cook
>
> --
> You received this message because you are subscribed to the Google Groups "Clang Built Linux" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to clang-built-linux+unsubscribe@...glegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/clang-built-linux/202006151113.7A2F638A7%40keescook.



-- 
Thanks,
~Nick Desaulniers

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ