To work around a misbehavior of the compiler's ability to see into composite flexible array structs (as detailed in the coming memcpy() hardening series[1]), split the memcpy() of the header and the payload so no false positive run-time overflow warning will be generated. [1] https://lore.kernel.org/linux-hardening/20220901065914.1417829-2-keescook@chromium.org/
Unified · Split
| @@ -13265,7 +13265,9 @@ static int nl80211_parse_wowlan_tcp(struct cfg80211_registered_device *rdev, · 13264 unmodified lines | ||
| 13265 | 13265 | wake_mask_size); |
| 13266 | 13266 | if (tok) { |
| 13267 | 13267 | cfg->tokens_size = tokens_size; |
| 13268 | − memcpy(&cfg->payload_tok, tok, sizeof(*tok) + tokens_size); | |
| 13268 | + cfg->payload_tok = *tok; | |
| 13269 | + memcpy(cfg->payload_tok.token_stream, tok->token_stream, | |
| 13270 | + tokens_size); | |
| 13269 | 13271 | } |
| 13270 | 13272 | |
| 13271 | 13273 | trig->tcp = cfg; |