Re: [PATCH] wifi: cfg80211: don't allow negative key_len values

Johannes Berg <[email protected]>
Newsgroups gmane.linux.kernel,gmane.linux.kernel.wireless.general,gmane.linux.kernel.janitors
Message-ID <[email protected]>
On Thu, 2026-04-30 at 09:15 +0300, Dan Carpenter wrote:
> The ath6kl_cfg80211_add_key() function has an upper bounds check on
> params->key_len which ensures that it can't go over WLAN_MAX_KEY_LEN but
> it doesn't check for negatives.  This could potentially lead to memory
> corruption.
> 
> Put a bounds check on negative values in cfg80211_validate_key_settings()
> to prevent this sort of bug in the future.

Clearly this commit doesn't seem problematic, but I'm not sure I see the
path to it mattering? The key_len should only ever be set by
wext/nl80211, and that can't really end up with a negative length?

We should probably just make it a u8 there, no way it's ever bigger than
that, but I'm not seeing through why this would matter much right now.

johannes
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.