* [PATCH 42/46] mm/kasan, lto: Mark kasan mem{cpy,move,set} as __used
[not found] <20221114114344.18650-1-jirislaby@kernel.org>
@ 2022-11-14 11:43 ` Jiri Slaby (SUSE)
2022-11-14 11:43 ` [PATCH 45/46] kasan, lto: remove extra BUILD_BUG() in memory_is_poisoned Jiri Slaby (SUSE)
1 sibling, 0 replies; 3+ messages in thread
From: Jiri Slaby (SUSE) @ 2022-11-14 11:43 UTC (permalink / raw)
To: linux-kernel
Cc: Martin Liska, Andrey Ryabinin, Alexander Potapenko,
Andrey Konovalov, Dmitry Vyukov, Vincenzo Frascino,
Andrew Morton, kasan-dev, linux-mm, Jiri Slaby
From: Martin Liska <mliska@suse.cz>
gcc doesn't always recognize that memcpy/set/move called through
__builtins are referenced because the reference happens too late in the
RTL expansion phase. This can make LTO to drop them, leading to
undefined symbols. Mark them as __used to avoid that.
Cc: Andrey Ryabinin <ryabinin.a.a@gmail.com>
Cc: Alexander Potapenko <glider@google.com>
Cc: Andrey Konovalov <andreyknvl@gmail.com>
Cc: Dmitry Vyukov <dvyukov@google.com>
Cc: Vincenzo Frascino <vincenzo.frascino@arm.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: kasan-dev@googlegroups.com
Cc: linux-mm@kvack.org
Signed-off-by: Martin Liska <mliska@suse.cz>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
mm/kasan/shadow.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/mm/kasan/shadow.c b/mm/kasan/shadow.c
index 0e3648b603a6..94c98feea9c8 100644
--- a/mm/kasan/shadow.c
+++ b/mm/kasan/shadow.c
@@ -39,7 +39,7 @@ bool __kasan_check_write(const volatile void *p, unsigned int size)
EXPORT_SYMBOL(__kasan_check_write);
#undef memset
-void *memset(void *addr, int c, size_t len)
+__used void *memset(void *addr, int c, size_t len)
{
if (!kasan_check_range((unsigned long)addr, len, true, _RET_IP_))
return NULL;
@@ -49,7 +49,7 @@ void *memset(void *addr, int c, size_t len)
#ifdef __HAVE_ARCH_MEMMOVE
#undef memmove
-void *memmove(void *dest, const void *src, size_t len)
+__used void *memmove(void *dest, const void *src, size_t len)
{
if (!kasan_check_range((unsigned long)src, len, false, _RET_IP_) ||
!kasan_check_range((unsigned long)dest, len, true, _RET_IP_))
@@ -60,7 +60,7 @@ void *memmove(void *dest, const void *src, size_t len)
#endif
#undef memcpy
-void *memcpy(void *dest, const void *src, size_t len)
+__used void *memcpy(void *dest, const void *src, size_t len)
{
if (!kasan_check_range((unsigned long)src, len, false, _RET_IP_) ||
!kasan_check_range((unsigned long)dest, len, true, _RET_IP_))
--
2.38.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 45/46] kasan, lto: remove extra BUILD_BUG() in memory_is_poisoned
[not found] <20221114114344.18650-1-jirislaby@kernel.org>
2022-11-14 11:43 ` [PATCH 42/46] mm/kasan, lto: Mark kasan mem{cpy,move,set} as __used Jiri Slaby (SUSE)
@ 2022-11-14 11:43 ` Jiri Slaby (SUSE)
2022-11-26 17:07 ` Andrey Konovalov
1 sibling, 1 reply; 3+ messages in thread
From: Jiri Slaby (SUSE) @ 2022-11-14 11:43 UTC (permalink / raw)
To: linux-kernel
Cc: Martin Liska, Andrey Ryabinin, Alexander Potapenko,
Andrey Konovalov, Dmitry Vyukov, Vincenzo Frascino,
Andrew Morton, kasan-dev, linux-mm, Jiri Slaby
From: Martin Liska <mliska@suse.cz>
The function memory_is_poisoned() can handle any size which can be
propagated by LTO later on. So we can end up with a constant that is not
handled in the switch. Thus just break and call memory_is_poisoned_n()
which handles arbitrary size to avoid build errors with gcc LTO.
Cc: Andrey Ryabinin <ryabinin.a.a@gmail.com>
Cc: Alexander Potapenko <glider@google.com>
Cc: Andrey Konovalov <andreyknvl@gmail.com>
Cc: Dmitry Vyukov <dvyukov@google.com>
Cc: Vincenzo Frascino <vincenzo.frascino@arm.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: kasan-dev@googlegroups.com
Cc: linux-mm@kvack.org
Signed-off-by: Martin Liska <mliska@suse.cz>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
mm/kasan/generic.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/mm/kasan/generic.c b/mm/kasan/generic.c
index d8b5590f9484..d261f83c6687 100644
--- a/mm/kasan/generic.c
+++ b/mm/kasan/generic.c
@@ -152,7 +152,7 @@ static __always_inline bool memory_is_poisoned(unsigned long addr, size_t size)
case 16:
return memory_is_poisoned_16(addr);
default:
- BUILD_BUG();
+ break;
}
}
--
2.38.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 45/46] kasan, lto: remove extra BUILD_BUG() in memory_is_poisoned
2022-11-14 11:43 ` [PATCH 45/46] kasan, lto: remove extra BUILD_BUG() in memory_is_poisoned Jiri Slaby (SUSE)
@ 2022-11-26 17:07 ` Andrey Konovalov
0 siblings, 0 replies; 3+ messages in thread
From: Andrey Konovalov @ 2022-11-26 17:07 UTC (permalink / raw)
To: Jiri Slaby (SUSE)
Cc: linux-kernel, Martin Liska, Andrey Ryabinin, Alexander Potapenko,
Dmitry Vyukov, Vincenzo Frascino, Andrew Morton, kasan-dev,
linux-mm, Jiri Slaby
On Mon, Nov 14, 2022 at 12:45 PM Jiri Slaby (SUSE) <jirislaby@kernel.org> wrote:
>
> From: Martin Liska <mliska@suse.cz>
>
> The function memory_is_poisoned() can handle any size which can be
> propagated by LTO later on. So we can end up with a constant that is not
> handled in the switch. Thus just break and call memory_is_poisoned_n()
> which handles arbitrary size to avoid build errors with gcc LTO.
>
> Cc: Andrey Ryabinin <ryabinin.a.a@gmail.com>
> Cc: Alexander Potapenko <glider@google.com>
> Cc: Andrey Konovalov <andreyknvl@gmail.com>
> Cc: Dmitry Vyukov <dvyukov@google.com>
> Cc: Vincenzo Frascino <vincenzo.frascino@arm.com>
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Cc: kasan-dev@googlegroups.com
> Cc: linux-mm@kvack.org
> Signed-off-by: Martin Liska <mliska@suse.cz>
> Signed-off-by: Jiri Slaby <jslaby@suse.cz>
> ---
> mm/kasan/generic.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/mm/kasan/generic.c b/mm/kasan/generic.c
> index d8b5590f9484..d261f83c6687 100644
> --- a/mm/kasan/generic.c
> +++ b/mm/kasan/generic.c
> @@ -152,7 +152,7 @@ static __always_inline bool memory_is_poisoned(unsigned long addr, size_t size)
> case 16:
> return memory_is_poisoned_16(addr);
> default:
> - BUILD_BUG();
> + break;
> }
> }
>
> --
> 2.38.1
>
Reviewed-by: Andrey Konovalov <andreyknvl@gmail.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-11-26 17:08 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <20221114114344.18650-1-jirislaby@kernel.org>
2022-11-14 11:43 ` [PATCH 42/46] mm/kasan, lto: Mark kasan mem{cpy,move,set} as __used Jiri Slaby (SUSE)
2022-11-14 11:43 ` [PATCH 45/46] kasan, lto: remove extra BUILD_BUG() in memory_is_poisoned Jiri Slaby (SUSE)
2022-11-26 17:07 ` Andrey Konovalov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox