Re: [bug report] cpumask: gcc 13.x emits compilation error on PowerPC
From: Nilay Shroff
Date: Thu Nov 07 2024 - 08:39:46 EST
On 11/6/24 23:30, Brian Norris wrote:
> 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/
>
Thanks for this pointer! This one appears exactly similar to what I encountered on PowerPC.
> IIUC, he was hoping for better compiler diagnostics to help out there.
Hmm ok
>
> (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.
>
So shall we wait until we get better diagnostics from GCC or can we bypass this
error temporarily with either using __NO_FORTIFY (as I proposed in my another
email) or disable -Wstringop-overread for kernel/padata.c file? Later when we
find a better fix, we may then revert this change.
Thanks,
--Nilay