Page MenuHomeFreeBSD

Disable -Wzero-length-bounds for the kernel for GCC 12.
ClosedPublic

Authored by jhb on Dec 7 2022, 8:37 PM.
Tags
None
Referenced Files
F111011632: D37630.diff
Wed, Feb 26, 4:48 AM
Unknown Object (File)
Mon, Feb 24, 11:06 AM
Unknown Object (File)
Thu, Feb 20, 5:11 AM
Unknown Object (File)
Mon, Feb 10, 6:20 AM
Unknown Object (File)
Wed, Jan 29, 9:08 PM
Unknown Object (File)
Jan 21 2025, 3:34 PM
Unknown Object (File)
Nov 15 2024, 8:53 PM
Unknown Object (File)
Oct 28 2024, 5:10 PM
Subscribers

Details

Summary

The mlx5 driver and some other OFED bits use a somewhat dubious
pattern of:

struct foo {
    uint64_t arg[0];
    /* Real members of a struct */
};

The code then treats 'arg' as if it were really a kind of union
to such that foo.arg[N] functions similarly to (uint64_t *)foo[N].

No real bugs were found by this warning though, so just turn it off
globally.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

jhb requested review of this revision.Dec 7 2022, 8:37 PM
jhb created this revision.

This is undefined behavior for sure.

This revision is now accepted and ready to land.Dec 8 2022, 1:54 AM

is there a problem disabling it just for the known problematic code?

In D37630#855698, @mjg wrote:

is there a problem disabling it just for the known problematic code?

There was a lot to disable, and I found no real bugs. That is, for amd64's GENERIC today it only yielded false positives.