History

wifi: nl80211: Split memcpy() of struct nl80211_wowlan_tcp_data_token flexible array

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/

Kees Cook committed 4 years ago

Commit 10d5ea51 parent e3e6e1d1 file · +3 −1Browse files

Unified · Split

net/wireless/nl80211.c+3−1
@@ -13265,7 +13265,9 @@ static int nl80211_parse_wowlan_tcp(struct cfg80211_registered_device *rdev, · 13264 unmodified lines
13265 wake_mask_size);13265 wake_mask_size);
13266 if (tok) {13266 if (tok) {
13267 cfg->tokens_size = tokens_size;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 trig->tcp = cfg;13273 trig->tcp = cfg;