Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1729955 > unrolled thread

Re: [PATCH 7/7] include/linux/string.h: add the option of fortified string.h functions

Started byGeert Uytterhoeven <geert@linux-m68k.org>
First post2017-09-10 13:00 +0200
Last post2017-09-10 16:00 +0200
Articles 2 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: [PATCH 7/7] include/linux/string.h: add the option of fortified  string.h functions Geert Uytterhoeven <geert@linux-m68k.org> - 2017-09-10 13:00 +0200
    Re: [PATCH 7/7] include/linux/string.h: add the option of fortified  string.h functions Arnd Bergmann <arnd@arndb.de> - 2017-09-10 16:00 +0200

#1729955 — Re: [PATCH 7/7] include/linux/string.h: add the option of fortified string.h functions

FromGeert Uytterhoeven <geert@linux-m68k.org>
Date2017-09-10 13:00 +0200
SubjectRe: [PATCH 7/7] include/linux/string.h: add the option of fortified string.h functions
Message-ID<uo882-2xy-5@gated-at.bofh.it>
Hi Kees, Daniel,

On Mon, Jun 19, 2017 at 10:26 PM, Kees Cook <keescook@chromium.org> wrote:
> From: Daniel Micay <danielmicay@gmail.com>
>
> This adds support for compiling with a rough equivalent to the glibc
> _FORTIFY_SOURCE=1 feature, providing compile-time and runtime buffer
> overflow checks for string.h functions when the compiler determines the
> size of the source or destination buffer at compile-time.  Unlike glibc,
> it covers buffer reads in addition to writes.

[...]

> Link: http://lkml.kernel.org/r/20170526095404.20439-1-danielmicay@gmail.com
> Signed-off-by: Daniel Micay <danielmicay@gmail.com>
> Acked-by: Kees Cook <keescook@chromium.org>
> Cc: Mark Rutland <mark.rutland@arm.com>
> Cc: Daniel Axtens <dja@axtens.net>
> Cc: Rasmus Villemoes <linux@rasmusvillemoes.dk>
> Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> Cc: Chris Metcalf <cmetcalf@ezchip.com>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: "H. Peter Anvin" <hpa@zytor.com>
> Cc: Ingo Molnar <mingo@elte.hu>
> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
> [kees: move from -mm, add ARCH_HAS_FORTIFY_SOURCE, tweak Kconfig help]
> Signed-off-by: Kees Cook <keescook@chromium.org>

This is now commit 6974f0c4555e285a upstream.

> --- a/include/linux/string.h
> +++ b/include/linux/string.h
> @@ -187,4 +187,204 @@ static inline const char *kbasename(const char *path)
>         return tail ? tail + 1 : path;
>  }
>
> +#define __FORTIFY_INLINE extern __always_inline __attribute__((gnu_inline))

With gcc-4.1.2, I now get zillions of:

    include/linux/string.h:439: warning: ‘gnu_inline’ attribute
directive ignored

This attribute seems to be supported as of gcc 4.2?

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

[toc] | [next] | [standalone]


#1729978

FromArnd Bergmann <arnd@arndb.de>
Date2017-09-10 16:00 +0200
Message-ID<uoaWe-4xL-15@gated-at.bofh.it>
In reply to#1729955
On Sun, Sep 10, 2017 at 12:55 PM, Geert Uytterhoeven
<geert@linux-m68k.org> wrote:
55e285a upstream.
>
>> --- a/include/linux/string.h
>> +++ b/include/linux/string.h
>> @@ -187,4 +187,204 @@ static inline const char *kbasename(const char *path)
>>         return tail ? tail + 1 : path;
>>  }
>>
>> +#define __FORTIFY_INLINE extern __always_inline __attribute__((gnu_inline))
>
> With gcc-4.1.2, I now get zillions of:
>
>     include/linux/string.h:439: warning: ‘gnu_inline’ attribute
> directive ignored
>
> This attribute seems to be supported as of gcc 4.2?
>

I think in older compilers this was the default, so we could add a macro in
compiler.h that makes becomes an empty string there. If we do that,
we should also address these new warning on gcc-4.3:

arch/x86/include/asm/string_32.h:30: warning: 'strlen' declared inline
after being called
arch/x86/include/asm/string_32.h:252: warning: 'strnlen' declared
inline after being called
arch/x86/include/asm/string_32.h:252: warning: previous declaration of
'strnlen' was here
arch/x86/include/asm/string_32.h:145: warning: 'memcpy' declared
inline after being called
include/linux/string.h:81: warning: 'strlen' declared inline after being called
include/linux/string.h:81: warning: previous declaration of 'strlen' was here
include/linux/string.h:84: warning: 'strnlen' declared inline after being called
include/linux/string.h:84: warning: previous declaration of 'strnlen' was here

      Arnd

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web