summaryrefslogtreecommitdiff
path: root/lib/fdt_empty_tree.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2021-09-20 10:26:21 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2021-09-21 08:36:48 -0700
commitd5f6545934c47e97c0b48a645418e877b452a992 (patch)
treefde779dcaac1c639fad9427cc4bd1a1d35647bbf /lib/fdt_empty_tree.c
parentd9fb678414c048e185eaddadd18d75f5e8832ff3 (diff)
downloadlwn-d5f6545934c47e97c0b48a645418e877b452a992.tar.gz
lwn-d5f6545934c47e97c0b48a645418e877b452a992.zip
qnx4: work around gcc false positive warning bug
In commit b7213ffa0e58 ("qnx4: avoid stringop-overread errors") I tried to teach gcc about how the directory entry structure can be two different things depending on a status flag. It made the code clearer, and it seemed to make gcc happy. However, Arnd points to a gcc bug, where despite using two different members of a union, gcc then gets confused, and uses the size of one of the members to decide if a string overrun happens. And not necessarily the rigth one. End result: with some configurations, gcc-11 will still complain about the source buffer size being overread: fs/qnx4/dir.c: In function 'qnx4_readdir': fs/qnx4/dir.c:76:32: error: 'strnlen' specified bound [16, 48] exceeds source size 1 [-Werror=stringop-overread] 76 | size = strnlen(name, size); | ^~~~~~~~~~~~~~~~~~~ fs/qnx4/dir.c:26:22: note: source object declared here 26 | char de_name; | ^~~~~~~ because gcc will get confused about which union member entry is actually getting accessed, even when the source code is very clear about it. Gcc internally will have combined two "redundant" pointers (pointing to different union elements that are at the same offset), and takes the size checking from one or the other - not necessarily the right one. This is clearly a gcc bug, but we can work around it fairly easily. The biggest thing here is the big honking comment about why we do what we do. Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99578#c6 Reported-and-tested-by: Arnd Bergmann <arnd@kernel.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'lib/fdt_empty_tree.c')
0 files changed, 0 insertions, 0 deletions