Re: [PATCH 45/46] kasan, lto: remove extra BUILD_BUG() in memory_is_poisoned

From: Andrey Konovalov
Date: Sat Nov 26 2022 - 12:08:25 EST


On Mon, Nov 14, 2022 at 12:45 PM Jiri Slaby (SUSE) <jirislaby@xxxxxxxxxx> wrote:
>
> From: Martin Liska <mliska@xxxxxxx>
>
> 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@xxxxxxxxx>
> Cc: Alexander Potapenko <glider@xxxxxxxxxx>
> Cc: Andrey Konovalov <andreyknvl@xxxxxxxxx>
> Cc: Dmitry Vyukov <dvyukov@xxxxxxxxxx>
> Cc: Vincenzo Frascino <vincenzo.frascino@xxxxxxx>
> Cc: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
> Cc: kasan-dev@xxxxxxxxxxxxxxxx
> Cc: linux-mm@xxxxxxxxx
> Signed-off-by: Martin Liska <mliska@xxxxxxx>
> Signed-off-by: Jiri Slaby <jslaby@xxxxxxx>
> ---
> 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@xxxxxxxxx>