Skip to content

Commit 368556d

Browse files
committed
wifi: iwlwifi: mld: Work around Clang loop unrolling bug
The nested loop in iwl_mld_send_proto_offload() confuses Clang into thinking there could be a final loop iteration past the end of the "nsc" array (which is only 4 entries). The FORTIFY checking in memcmp() (via ipv6_addr_cmp()) notices this (due to the available bytes in the out-of-bounds position of &nsc[4] being 0), and errors out, failing the build. For some reason (likely due to architectural loop unrolling configurations), this is only exposed on ARM builds currently. Due to Clang's lack of inline tracking[1], the warning is not very helpful: include/linux/fortify-string.h:719:4: error: call to '__read_overflow' declared with 'error' attribute: detected read beyond size of object (1st parameter) 719 | __read_overflow(); | ^ 1 error generated. But this was tracked down to iwl_mld_send_proto_offload()'s ipv6_addr_cmp() call. An upstream Clang bug has been filed[2] to track this. For now fix the build by explicitly bounding the inner loop by "n_nsc", which is what "c" is already limited to. Reported-by: Nathan Chancellor <[email protected]> Closes: ClangBuiltLinux#2076 Link: llvm/llvm-project#73552 [1] Link: llvm/llvm-project#136603 [2] Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Kees Cook <[email protected]>
1 parent f0cd601 commit 368556d

File tree

1 file changed

+1
-1
lines changed
  • drivers/net/wireless/intel/iwlwifi/mld

1 file changed

+1
-1
lines changed

drivers/net/wireless/intel/iwlwifi/mld/d3.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1757,7 +1757,7 @@ iwl_mld_send_proto_offload(struct iwl_mld *mld,
17571757

17581758
addrconf_addr_solict_mult(&wowlan_data->target_ipv6_addrs[i],
17591759
&solicited_addr);
1760-
for (j = 0; j < c; j++)
1760+
for (j = 0; j < n_nsc && j < c; j++)
17611761
if (ipv6_addr_cmp(&nsc[j].dest_ipv6_addr,
17621762
&solicited_addr) == 0)
17631763
break;

0 commit comments

Comments
 (0)