[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAGXu5jLmk1CtD272bEWh6ubrVcEc_eEWzPGO7vEQtXKoax_rVg@mail.gmail.com>
Date: Thu, 28 Apr 2016 09:01:27 -0700
From: Kees Cook <keescook@...omium.org>
To: Ingo Molnar <mingo@...nel.org>
Cc: Yinghai Lu <yinghai@...nel.org>, Baoquan He <bhe@...hat.com>,
Borislav Petkov <bp@...e.de>, Ingo Molnar <mingo@...hat.com>,
"x86@...nel.org" <x86@...nel.org>,
Andrew Morton <akpm@...ux-foundation.org>,
Andrey Ryabinin <aryabinin@...tuozzo.com>,
Dmitry Vyukov <dvyukov@...gle.com>,
"H.J. Lu" <hjl.tools@...il.com>,
Josh Poimboeuf <jpoimboe@...hat.com>,
Andy Lutomirski <luto@...nel.org>,
LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v2] x86/boot: Rename overlapping memcpy() to memmove()
On Thu, Apr 28, 2016 at 2:37 AM, Ingo Molnar <mingo@...nel.org> wrote:
>
> * Kees Cook <keescook@...omium.org> wrote:
>
>> On Thu, Apr 28, 2016 at 2:04 AM, Ingo Molnar <mingo@...nel.org> wrote:
>> >
>> > * Kees Cook <keescook@...omium.org> wrote:
>> > > +#define memmove memmove
>> >
>> > Btw., what's the purpose of this define? If it's already defined then we should
>> > get a build warning. If it's not, we won't.
>>
>> It's for the decompressor that checks for memmove existing already via
>> "ifdef memmove". If this isn't done here, we will end up with two
>> memmove implementations.
>
> So:
>
> triton:~/tip> git grep memmove | grep -i ifdef
> triton:~/tip>
>
> what am I missing?
Sorry, I typoed. It's #ifndef:
lib/decompress_unxz.c:
#ifndef memmove
/* Not static to avoid a conflict with the prototype in the Linux headers. */
void *memmove(void *dest, const void *src, size_t size)
{
...
In the regular kernel, each architecture provides a define for memmove, e.g.:
arch/x86/include/asm/string_64.h:#define memmove(dst, src, len)
__memmove(dst, src, len)
So the compressed boot stub does too so the decompressor can work in
both code bases.
-Kees
>> >> +void *memcpy(void *dest, const void *src, size_t n)
>> >
>> > btw., if there's any doubt about other overlapping uses, we could add this to
>> > memcpy():
>> >
>> > WARN_ON_ONCE(dest > src && dest-src < n);
>> >
>> > or so? Does printk() work so early on?
>>
>> It does not, but we could use either "error" or the new "warn". Should
>> we abort a boot in this case, or just warn about it? (Our
>> implementations of memcpy, fwiw, currently seem to support overlap, so
>> I would suggest warn.)
>
> Yeah, I'd definitely not try to crash the bootup for the user, but try to
> continue.
>
> Thanks,
>
> Ingo
--
Kees Cook
Chrome OS & Brillo Security
Powered by blists - more mailing lists