|
| 1 | +From 368556dd234dc4a506a35a0c99c0eee2ab475c77 Mon Sep 17 00:00:00 2001 |
| 2 | +From: Kees Cook < [email protected]> |
| 3 | +Date: Mon, 21 Apr 2025 13:41:57 -0700 |
| 4 | +Subject: wifi: iwlwifi: mld: Work around Clang loop unrolling bug |
| 5 | + |
| 6 | +The nested loop in iwl_mld_send_proto_offload() confuses Clang into |
| 7 | +thinking there could be a final loop iteration past the end of the |
| 8 | +"nsc" array (which is only 4 entries). The FORTIFY checking in memcmp() |
| 9 | +(via ipv6_addr_cmp()) notices this (due to the available bytes in the |
| 10 | +out-of-bounds position of &nsc[4] being 0), and errors out, failing |
| 11 | +the build. For some reason (likely due to architectural loop unrolling |
| 12 | +configurations), this is only exposed on ARM builds currently. Due to |
| 13 | +Clang's lack of inline tracking[1], the warning is not very helpful: |
| 14 | + |
| 15 | +include/linux/fortify-string.h:719:4: error: call to '__read_overflow' declared with 'error' attribute: detected read beyond size of object (1st parameter) |
| 16 | + 719 | __read_overflow(); |
| 17 | + | ^ |
| 18 | +1 error generated. |
| 19 | + |
| 20 | +But this was tracked down to iwl_mld_send_proto_offload()'s |
| 21 | +ipv6_addr_cmp() call. |
| 22 | + |
| 23 | +An upstream Clang bug has been filed[2] to track this. For now fix the |
| 24 | +build by explicitly bounding the inner loop by "n_nsc", which is what |
| 25 | +"c" is already limited to. |
| 26 | + |
| 27 | +Reported-by: Nathan Chancellor < [email protected]> |
| 28 | +Closes: https://github.com/ClangBuiltLinux/linux/issues/2076 |
| 29 | +Link: https://github.com/llvm/llvm-project/pull/73552 [1] |
| 30 | +Link: https://github.com/llvm/llvm-project/issues/136603 [2] |
| 31 | +Link: https://lore.kernel.org/r/ [email protected] |
| 32 | +Signed-off-by: Kees Cook < [email protected]> |
| 33 | +--- |
| 34 | +Link: https://git.kernel.org/linus/368556dd234dc4a506a35a0c99c0eee2ab475c77 |
| 35 | +--- |
| 36 | + drivers/net/wireless/intel/iwlwifi/mld/d3.c | 2 +- |
| 37 | + 1 file changed, 1 insertion(+), 1 deletion(-) |
| 38 | + |
| 39 | +diff --git a/drivers/net/wireless/intel/iwlwifi/mld/d3.c b/drivers/net/wireless/intel/iwlwifi/mld/d3.c |
| 40 | +index ee99298eebf595..7ce01ad3608e18 100644 |
| 41 | +--- a/drivers/net/wireless/intel/iwlwifi/mld/d3.c |
| 42 | ++++ b/drivers/net/wireless/intel/iwlwifi/mld/d3.c |
| 43 | +@@ -1757,7 +1757,7 @@ iwl_mld_send_proto_offload(struct iwl_mld *mld, |
| 44 | + |
| 45 | + addrconf_addr_solict_mult(&wowlan_data->target_ipv6_addrs[i], |
| 46 | + &solicited_addr); |
| 47 | +- for (j = 0; j < c; j++) |
| 48 | ++ for (j = 0; j < n_nsc && j < c; j++) |
| 49 | + if (ipv6_addr_cmp(&nsc[j].dest_ipv6_addr, |
| 50 | + &solicited_addr) == 0) |
| 51 | + break; |
| 52 | +-- |
| 53 | +cgit 1.2.3-korg |
| 54 | + |
0 commit comments