lkml.org 
[lkml]   [2019]   [Mar]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: [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, 5 Mar 2019, Andreas Schwab wrote:

> On Mar 05 2019, Finn Thain <fthain@telegraphics.com.au> wrote:
>
> > interesting that the kernel's strlen implementation in
> > include/linux/string.h can't achieve this.
>
> This implementation is only available if ARCH_HAS_FORTIFY_SOURCE.
>

I see. Perhaps we could add another definition to that file:

#if !defined(__NO_FORTIFY) && defined(__OPTIMIZE__) && defined(CONFIG_FORTIFY_SOURCE)
...
#else
__FORTIFY_INLINE __kernel_size_t strlen(const char *p)
{
return __builtin_strlen(p);
}
#endif

I didn't test that. But the following patch seems to work...

diff --git a/arch/m68k/include/asm/string.h b/arch/m68k/include/asm/string.h
index f759d944c449..3cff6b128ed3 100644
--- a/arch/m68k/include/asm/string.h
+++ b/arch/m68k/include/asm/string.h
@@ -71,4 +71,6 @@ extern void *memset(void *, int, __kernel_size_t);
extern void *memcpy(void *, const void *, __kernel_size_t);
#define memcpy(d, s, n) __builtin_memcpy(d, s, n)

+#define strlen(s) __builtin_strlen(s)
+
#endif /* _M68K_STRING_H_ */
diff --git a/lib/string.c b/lib/string.c
index 38e4ca08e757..fe970f2160e5 100644
--- a/lib/string.c
+++ b/lib/string.c
@@ -472,6 +472,7 @@ char *strim(char *s)
EXPORT_SYMBOL(strim);

#ifndef __HAVE_ARCH_STRLEN
+#undef strlen
/**
* strlen - Find the length of a string
* @s: The string to be sized
--

> Andreas.
>
>

\
 
 \ /
  Last update: 2019-03-07 04:00    [W:0.091 / U:18.156 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site