Re: [GIT PULL] Enable -Wstringop-overflow globally

From: Arnd Bergmann
Date: Fri Feb 02 2024 - 02:53:24 EST


On Fri, Jan 26, 2024, at 22:22, Linus Torvalds wrote:
> On Mon, 22 Jan 2024 at 07:29, Gustavo A. R. Silva <gustavoars@xxxxxxxxxx> wrote:
>>
>> Enable -Wstringop-overflow globally
>
> I suspect I'll have to revert this.
>
> On arm64, I get a "writing 16 bytes into a region of size 0" in the Xe driver
>
> drivers/gpu/drm/xe/xe_gt_pagefault.c:340
>
> but I haven't looked into it much yet.
>
> It's not some gcc-11 issue, though, this is with gcc version 13.2.1
>
> It looks like the kernel test robot reported this too (for s390), at
>
> https://lore.kernel.org/all/202401161031.hjGJHMiJ-lkp@xxxxxxxxx/T/
>
> and in that case it was gcc-13.2.0.
>
> So I don't think the issue is about gcc-11 at all, but about other
> random details.

I did a creduce pass on this warning when it first showed up
and opened a gcc bug report as well as a driver workaround:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113214
https://lore.kernel.org/lkml/20240103114819.2913937-1-arnd@xxxxxxxxxx/#r

The reply in bugzilla is that sanitizers are expected to randomly
produce false-positive warnings like this one. In this case it's
-fsanitize=thread (KCSAN) that triggers it. There are other
warnings that have similar problems, so I guess we could work
around it by having certain warnings moved back to W=1 when
any sanitizers are enabled.

Arnd