linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mathias Krause <minipli@googlemail.com>
To: Kees Cook <keescook@chromium.org>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Herbert Xu <herbert@gondor.apana.org.au>,
	"linux-crypto@vger.kernel.org" <linux-crypto@vger.kernel.org>
Subject: Re: [PATCH v2] crypto: prefix module autoloading with "crypto-"
Date: Wed, 19 Nov 2014 00:12:24 +0100	[thread overview]
Message-ID: <CA+rthh80M=NN710zOFW7Hfid8aV-TuwdhHdoB0UF0Bboshy9zw@mail.gmail.com> (raw)
In-Reply-To: <CAGXu5jLGS4cNv_+xLH1fPzg8rUnXL5S+eKmHFn4jckaJkdeRjA@mail.gmail.com>

On 18 November 2014 01:45, Kees Cook <keescook@chromium.org> wrote:
> On Mon, Nov 17, 2014 at 3:20 PM, Mathias Krause <minipli@googlemail.com> wrote:
>> On 17 November 2014 21:02, Kees Cook <keescook@chromium.org> wrote:
>>> This prefixes all crypto module loading with "crypto-" so we never run
>>> the risk of exposing module auto-loading to userspace via a crypto API,
>>> as demonstrated by Mathias Krause:
>>>
>>> https://lkml.org/lkml/2013/3/4/70
>>>
>>> Signed-off-by: Kees Cook <keescook@chromium.org>
>>> ---
>>> v2:
>>>  - added missing #include, thanks to minipli
>>>  - built with allmodconfig
>>> [...snip...]
>>> diff --git a/include/linux/crypto.h b/include/linux/crypto.h
>>> index d45e949699ea..d14230f6e977 100644
>>> --- a/include/linux/crypto.h
>>> +++ b/include/linux/crypto.h
>>> @@ -26,6 +26,13 @@
>>>  #include <linux/uaccess.h>
>>>
>>>  /*
>>> + * Autoloaded crypto modules should only use a prefixed name to avoid allowing
>>> + * arbitrary modules to be loaded.
>>> + */
>>> +#define MODULE_ALIAS_CRYPTO(name)      \
>>> +               MODULE_ALIAS("crypto-" name)
>>
>> This would break userland relying on the old aliases, e.g. 'modprobe
>> aes' no longer works.
>>
>> Why not have both aliases, one with the "crypto-" prefix for on-demand
>> loading within the crypto API and one without for manual loading from
>> userland? E.g., something like this:
>>
>> #define MODULE_ALIAS_CRYPTO(name)      \
>>                MODULE_ALIAS(name); \
>>                MODULE_ALIAS("crypto-" name)
>>
>> That would prevent the userland breakage and still achieves the goal
>> of restricting the request_module() call offered by the means of the
>> AF_ALG API.
>
> That was my intention originally, and I should go back to it. The
> trouble is with the use of __UNIQUE_ID in the MODULE_ALIAS macro. It
> uses __LINE__ to produce the id, so the suggested macro expansion
> (which is what I started with) won't work on non-gcc compilers.
>
> I haven't found any solutions for C89 version of gcc's __COUNTER__,
> and I haven't found any C89 ways to force a macro to be expanded as
> being multi-line.

Well, clang should support it as well, according to [1]. But still, a
compiler independent solution would be nice.
Anyway, the __COUNTER__ support is gcc >= 4.3 only. So, according to
Documentation/Changes, stating gcc 3.2 is the minimum supported
version for compiling the kernel, this would be a no-go, too.

[1] http://clang.llvm.org/docs/LanguageExtensions.html#builtin-macros

>
> I'd like to avoid having to open-code both MODULE_ALIAS and
> MODULE_ALIAS_CRYPTO in each module's source.
>
> Anyone see some sneaky way to accomplish this?

Unfortunately, I do not ... beside this, maybe:

#define MODULE_ALIAS_CRYPTO(name)      \
               __MODULE_INFO(alias, alias_userland, name); \
               __MODULE_INFO(alias, alias_crypto, "crypto-" name)

Looks ugly, but works. ;)


Regards,
Mathias

  reply	other threads:[~2014-11-18 23:12 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-17 20:02 [PATCH v2] crypto: prefix module autoloading with "crypto-" Kees Cook
2014-11-17 23:20 ` Mathias Krause
2014-11-18  0:45   ` Kees Cook
2014-11-18 23:12     ` Mathias Krause [this message]
2014-11-19  0:04       ` Kees Cook

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='CA+rthh80M=NN710zOFW7Hfid8aV-TuwdhHdoB0UF0Bboshy9zw@mail.gmail.com' \
    --to=minipli@googlemail.com \
    --cc=herbert@gondor.apana.org.au \
    --cc=keescook@chromium.org \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@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 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).