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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:   Mon, 18 Mar 2019 13:53:51 +1100 (AEDT)
From:   Finn Thain <fthain@...egraphics.com.au>
To:     Geert Uytterhoeven <geert@...ux-m68k.org>
cc:     Andreas Schwab <schwab@...ux-m68k.org>,
        kbuild test robot <lkp@...el.com>, kbuild-all@...org,
        linux-m68k <linux-m68k@...ts.linux-m68k.org>,
        Arnd Bergmann <arnd@...db.de>,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: [m68k:master 1174/1174] arch/m68k/include/asm/string.h:72:25:
 warning: '__builtin_memcpy' forming offset 8 is out of the bounds [0, 7]

On Tue, 12 Mar 2019, I wrote:

> ... I did another experiment with the latter (forced inline) approach, 
> to see if some optimizations can still be used with -ffreestanding.
> 
> diff --git a/include/linux/string.h b/include/linux/string.h
> index 7927b875f80c..25b5bf689018 100644
> --- a/include/linux/string.h
> +++ b/include/linux/string.h
> @@ -436,6 +436,58 @@ __FORTIFY_INLINE char *strcpy(char *p, const char *q)
>  	return p;
>  }
>  
> +#else
> +
> +//__FORTIFY_INLINE char *strncpy(char *p, const char *q, __kernel_size_t size)
> +//{
> +//	return __builtin_strncpy(p, q, size);
> +//}
> +
> +__FORTIFY_INLINE char *strcat(char *p, const char *q)
> +{
> +	return __builtin_strcat(p, q);
> +}
> +
> +__FORTIFY_INLINE __kernel_size_t strlen(const char *p)
> +{
> +	return __builtin_strlen(p);
> +}
> +
> +__FORTIFY_INLINE char *strncat(char *p, const char *q, __kernel_size_t count)
> +{
> +	return __builtin_strncat(p, q, count);
> +}
> +
> +__FORTIFY_INLINE void *memset(void *p, int c, __kernel_size_t size)
> +{
> +	return __builtin_memset(p, c, size);
> +}
> +
> +//__FORTIFY_INLINE void *memcpy(void *p, const void *q, __kernel_size_t size)
> +//{
> +//	return __builtin_memcpy(p, q, size);
> +//}
> +
> +__FORTIFY_INLINE void *memmove(void *p, const void *q, __kernel_size_t size)
> +{
> +	return __builtin_memmove(p, q, size);
> +}
> +
> +__FORTIFY_INLINE int memcmp(const void *p, const void *q, __kernel_size_t size)
> +{
> +	return __builtin_memcmp(p, q, size);
> +}
> +
> +__FORTIFY_INLINE void *memchr(const void *p, int c, __kernel_size_t size)
> +{
> +	return __builtin_memchr(p, c, size);
> +}
> +
> +__FORTIFY_INLINE char *strcpy(char *p, const char *q)
> +{
> +	return __builtin_strcpy(p, q);
> +}
> +
>  #endif
>  
>  /**
> 
> 
> The result of this patch really is confusing. It still suppresses the 
> warning you raised:
> 
> arch/m68k/include/asm/string.h:72:25: warning: '__builtin_memcpy' forming
> offset 8 is out of the bounds [0, 7] [-Warray-bounds]
>     #define memcpy(d, s, n) __builtin_memcpy(d, s, n)
>                             ^~~~~~~~~~~~~~~~~~~~~~~~~
>    include/linux/string.h:456:3: note: in expansion of macro 'memcpy'
>       memcpy(dest, src, dest_len);
>       ^~~~~~
> 
> But it also causes new ones, because of __builtin_memset():
> 
> drivers/video/fbdev/core/fbcvt.c: In function 'fb_find_mode_cvt':
> drivers/video/fbdev/core/fbcvt.c:312:16: warning: 'cvt.flags' may be used uninit                                                                     ialized in this function [-Wmaybe-uninitialized]
>       cvt.flags |= FB_CVT_FLAG_MARGINS;
>                 ^~
> 
> Apparently the compiler doesn't understand that __builtin_memset() has 
> the effect of initialization. Weird.
> 

The other weird thing is that this warning doesn't show up when 
CONFIG_FORTIFY_SOURCE=y, even though the technique is much the same, that 
is, __builtin_memset() gets wrapped in a static inline memset() function.

Anyway, a quick and dirty microbenchmark under qemu-m68k shows that this 
patch reduces system time for 'time find / -false' by approx. 10%.

Interestingly, the -ffreestanding option doesn't make much difference to 
this particular microbenchmark.

-- 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ