* [PATCH] wifi: rtw88: allow key removal when the CAM table is full
@ 2026-10-19 16:51 Hungyu Lin
2026-10-19 19:01 ` Luka Gejak
0 siblings, 1 reply; 2+ messages in thread
From: Hungyu Lin @ 2026-10-19 16:51 UTC (permalink / raw)
To: pkshih; +Cc: linux-wireless, linux-kernel, reza1234khan1234, Hungyu Lin
rtw_ops_set_key() looks for a free CAM entry before checking the
command. When all pairwise entries are in use, DISABLE_KEY returns
-ENOSPC without clearing the existing entry.
Move the allocation and bounds check into SET_KEY. DISABLE_KEY uses
the existing key->hw_key_idx.
Fixes: 10d58823cb44 ("wifi: rtw88: fix out-of-bounds CAM write when key table is full")
Signed-off-by: Hungyu Lin <dennylin0707@gmail.com>
---
drivers/net/wireless/realtek/rtw88/mac80211.c | 24 +++++++++----------
1 file changed, 12 insertions(+), 12 deletions(-)
diff --git a/drivers/net/wireless/realtek/rtw88/mac80211.c b/drivers/net/wireless/realtek/rtw88/mac80211.c
index 2a9b09fa76e7..5e40cf06a9e3 100644
--- a/drivers/net/wireless/realtek/rtw88/mac80211.c
+++ b/drivers/net/wireless/realtek/rtw88/mac80211.c
@@ -598,20 +598,20 @@ static int rtw_ops_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
rtw_leave_lps_deep(rtwdev);
- if (key->flags & IEEE80211_KEY_FLAG_PAIRWISE) {
- hw_key_idx = rtw_sec_get_free_cam(sec);
- } else {
- /* multiple interfaces? */
- hw_key_idx = key->keyidx;
- }
-
- if (hw_key_idx >= sec->total_cam_num) {
- ret = -ENOSPC;
- goto out;
- }
-
switch (cmd) {
case SET_KEY:
+ if (key->flags & IEEE80211_KEY_FLAG_PAIRWISE) {
+ hw_key_idx = rtw_sec_get_free_cam(sec);
+ } else {
+ /* multiple interfaces? */
+ hw_key_idx = key->keyidx;
+ }
+
+ if (hw_key_idx >= sec->total_cam_num) {
+ ret = -ENOSPC;
+ goto out;
+ }
+
/* need sw generated IV */
key->flags |= IEEE80211_KEY_FLAG_GENERATE_IV;
key->hw_key_idx = hw_key_idx;
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] wifi: rtw88: allow key removal when the CAM table is full
2026-10-19 16:51 [PATCH] wifi: rtw88: allow key removal when the CAM table is full Hungyu Lin
@ 2026-10-19 19:01 ` Luka Gejak
0 siblings, 0 replies; 2+ messages in thread
From: Luka Gejak @ 2026-10-19 19:01 UTC (permalink / raw)
To: Hungyu Lin, pkshih
Cc: linux-wireless, linux-kernel, reza1234khan1234, Hungyu Lin
October 19, 2026 at 6:51 PM, "Hungyu Lin" <dennylin0707@gmail.com> wrote:
>
> rtw_ops_set_key() looks for a free CAM entry before checking the
> command. When all pairwise entries are in use, DISABLE_KEY returns
> -ENOSPC without clearing the existing entry.
>
> Move the allocation and bounds check into SET_KEY. DISABLE_KEY uses
> the existing key->hw_key_idx.
>
> Fixes: 10d58823cb44 ("wifi: rtw88: fix out-of-bounds CAM write when key table is full")
> Signed-off-by: Hungyu Lin <dennylin0707@gmail.com>
> ---
Looking good to me.
Reviewed-by: Luka Gejak <luka.gejak@linux.dev>
Best regards,
Luka Gejak
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-10-19 19:01 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-19 16:51 [PATCH] wifi: rtw88: allow key removal when the CAM table is full Hungyu Lin
2026-10-19 19:01 ` Luka Gejak
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox