All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ping-Ke Shih <pkshih@realtek.com>
To: Zhao Li <enderaoelyther@gmail.com>
Cc: Hemanth Selam <hemanth.selam@gmail.com>,
	Morning Star <alexbestoso@gmail.com>,
	"linux-wireless@vger.kernel.org" <linux-wireless@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"stable@vger.kernel.org" <stable@vger.kernel.org>
Subject: RE: [PATCH rtw-next 3/3] wifi: rtlwifi: rtl8192cu: don't mark undecrypted frames as decrypted
Date: Mon, 23 Nov 2026 06:22:21 +0000	[thread overview]
Message-ID: <8954a1c1913d4f1bbc8c5bb52acf8b1c@realtek.com> (raw)
In-Reply-To: <20261121163547.37019-4-enderaoelyther@gmail.com>

Zhao Li <enderaoelyther@gmail.com> wrote:
> The receive descriptor's SWDEC bit is set when a frame still needs
> software decryption. It is also clear for a frame that was never
> encrypted, and for a protected robust management frame, which the
> hardware leaves for software to decrypt. rtl92cu_rx_query_desc()
> nevertheless sets RX_FLAG_DECRYPTED for every frame with SWDEC clear,
> in two places.
> 
> mac80211 then accepts an unprotected unicast data frame although a
> pairwise key is installed, and unprotected deauthentication and
> disassociation frames on a connection that uses management frame
> protection. For a protected robust management frame it skips software
> decryption and MIC verification, so a forged frame is accepted and a
> genuine encrypted one, such as an SA Query from the peer, reaches
> mac80211 still encrypted. A station in radio range can therefore inject
> plaintext data into an encrypted connection, or end a protected one, by
> spoofing the peer's address.
> 
> Set the flag only for a protected frame that is not a robust management
> frame, as the rtl8188ee, rtl8192ee, rtl8723ae, rtl8723be and rtl8821ae
> drivers do. rtl8xxxu, which supports the same chip, stopped trusting
> SWDEC alone in commit cbfbb4ddbc85 ("wifi: rtl8xxxu: enable MFP support
> with security flag of RX descriptor"). The header is read before the
> receive path strips the driver info, so test the Protected bit first,
> which needs only the frame control field, and read that only when the
> URB holds it. When Protected is set, _ieee80211_is_robust_mgmt_frame()
> also reads only frame_control.

Need to reduce commit message generated by LLM. 

> 
> Found by code review. Compile-tested with W=1.
> 
> Fixes: 29d00a3e46bb ("rtlwifi: rtl8192cu: Add routine trx")
> Cc: stable@vger.kernel.org
> Signed-off-by: Zhao Li <enderaoelyther@gmail.com>
> ---
> No new W=1, sparse or smatch warnings.
> 
> AI assistance was used.
> 
>  .../net/wireless/realtek/rtlwifi/rtl8192cu/trx.c   | 14 ++++++++++----
>  1 file changed, 10 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/trx.c
> b/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/trx.c
> index d6c35e8d02a5..aceedc37e5d2 100644
> --- a/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/trx.c
> +++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/trx.c
> @@ -295,11 +295,14 @@ bool rtl92cu_rx_query_desc(struct ieee80211_hw *hw,
>         struct rx_desc_92c *p_desc = (struct rx_desc_92c *)pdesc8;
>         __le32 *pdesc = (__le32 *)pdesc8;
>         u32 phystatus = get_rx_desc_phy_status(pdesc);
> +       struct ieee80211_hdr *hdr;
> +       unsigned int hdr_off;
> 
>         stats->length = (u16)get_rx_desc_pkt_len(pdesc);
>         stats->rx_drvinfo_size = (u8)get_rx_desc_drvinfo_size(pdesc) *
>                                  RX_DRV_INFO_SIZE_UNIT;
>         stats->rx_bufshift = (u8)(get_rx_desc_shift(pdesc) & 0x03);
> +       hdr_off = stats->rx_drvinfo_size + stats->rx_bufshift;
>         stats->icv = (u16)get_rx_desc_icv(pdesc);
>         stats->crc = (u16)get_rx_desc_crc32(pdesc);
>         stats->hwerror = (stats->crc | stats->icv);
> @@ -316,15 +319,18 @@ bool rtl92cu_rx_query_desc(struct ieee80211_hw *hw,
>         rx_status->band = hw->conf.chandef.chan->band;
>         if (get_rx_desc_crc32(pdesc))
>                 rx_status->flag |= RX_FLAG_FAILED_FCS_CRC;
> -       if (!get_rx_desc_swdec(pdesc))
> -               rx_status->flag |= RX_FLAG_DECRYPTED;
>         if (get_rx_desc_bw(pdesc))
>                 rx_status->bw = RATE_INFO_BW_40;
>         if (get_rx_desc_rx_ht(pdesc))
>                 rx_status->encoding = RX_ENC_HT;
>         rx_status->flag |= RX_FLAG_MACTIME_START;
> -       if (stats->decrypted)
> -               rx_status->flag |= RX_FLAG_DECRYPTED;
> +       if (stats->decrypted &&
> +           skb->len >= hdr_off + sizeof(hdr->frame_control)) {
> +               hdr = (struct ieee80211_hdr *)(skb->data + hdr_off);

Use the same style as other:

	hdr = (struct ieee80211_hdr *)(skb->data + status->rx_drvinfo_size
			+ status->rx_bufshift);

> +               if (ieee80211_has_protected(hdr->frame_control) &&
> +                   !_ieee80211_is_robust_mgmt_frame(hdr))
> +                       rx_status->flag |= RX_FLAG_DECRYPTED;
> +       }
>         rx_status->rate_idx = rtlwifi_rate_mapping(hw, stats->is_ht,
>                                                    false, stats->rate);
>         rx_status->mactime = get_rx_desc_tsfl(pdesc);
> --
> 2.56.1

pw-bot: cr


  reply	other threads:[~2026-11-23  6:22 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-21 16:35 [PATCH rtw-next 0/3] wifi: rtlwifi: don't mark unencrypted frames as decrypted Zhao Li
2026-11-21 16:35 ` [PATCH rtw-next 1/3] wifi: rtlwifi: rtl8192ce: " Zhao Li
2026-11-23  6:14   ` Ping-Ke Shih
2026-11-21 16:35 ` [PATCH rtw-next 2/3] wifi: rtlwifi: rtl8192se: " Zhao Li
2026-11-21 16:35 ` [PATCH rtw-next 3/3] wifi: rtlwifi: rtl8192cu: don't mark undecrypted " Zhao Li
2026-11-23  6:22   ` Ping-Ke Shih [this message]
2026-11-23  5:43 ` [PATCH rtw-next 0/3] wifi: rtlwifi: don't mark unencrypted " Ping-Ke Shih
2026-11-23  5:47   ` Ping-Ke Shih

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8954a1c1913d4f1bbc8c5bb52acf8b1c@realtek.com \
    --to=pkshih@realtek.com \
    --cc=alexbestoso@gmail.com \
    --cc=enderaoelyther@gmail.com \
    --cc=hemanth.selam@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.