Re: [bug report] cpumask: gcc 13.x emits compilation error on PowerPC

From: Brian Norris
Date: Wed Nov 06 2024 - 13:00:46 EST


Hi,

On Wed, Nov 6, 2024 at 5:02 AM Nilay Shroff <nilay@xxxxxxxxxxxxx> wrote:
>
> Hi,
>
> Of late, I've been encountering the following compilation error while using GCC 13.x and latest upstream code:
>
> Compilation error:
> ==================
> <snip>
> CC kernel/padata.o
> In file included from ./include/linux/string.h:390,
> from ./arch/powerpc/include/asm/paca.h:16,
> from ./arch/powerpc/include/asm/current.h:13,
> from ./include/linux/thread_info.h:23,
> from ./include/asm-generic/preempt.h:5,
> from ./arch/powerpc/include/generated/asm/preempt.h:1,
> from ./include/linux/preempt.h:79,
> from ./include/linux/spinlock.h:56,
> from ./include/linux/swait.h:7,
> from ./include/linux/completion.h:12,
> from kernel/padata.c:14:
> In function ‘bitmap_copy’,
> inlined from ‘cpumask_copy’ at ./include/linux/cpumask.h:839:2,
> inlined from ‘__padata_set_cpumasks’ at kernel/padata.c:730:2:
> ./include/linux/fortify-string.h:114:33: error: ‘__builtin_memcpy’ reading between 257 and 536870904 bytes from a region of size 256 [-Werror=stringop-overread]
> 114 | #define __underlying_memcpy __builtin_memcpy
> | ^

FWIW, I think Kees already was fielding a similar report a few days ago:

Re: Fortify compilation warning in __padata_set_cpumask()
https://lore.kernel.org/all/202411021337.85E9BB06@keescook/

IIUC, he was hoping for better compiler diagnostics to help out there.

(Also, I imitated Thomas's .config notes from that report and couldn't
reproduce with my GCC 13.2.0.)

I also happen to see there are a few scattered instances of either
disabling or working around -Wstringop-overread false positives in the
tree today.

Brian