[PATCH rtw-next 0/3] wifi: rtlwifi: don't mark unencrypted frames as decrypted

Zhao Li posted 3 patches 2 days, 19 hours ago
.../wireless/realtek/rtlwifi/rtl8192ce/trx.c    | 17 +++++------------
.../wireless/realtek/rtlwifi/rtl8192cu/trx.c    | 14 ++++++++++----
.../wireless/realtek/rtlwifi/rtl8192se/trx.c    | 16 +++++-----------
3 files changed, 20 insertions(+), 27 deletions(-)
[PATCH rtw-next 0/3] wifi: rtlwifi: don't mark unencrypted frames as decrypted
Posted by Zhao Li 2 days, 19 hours ago
The SWDEC bit of an rtlwifi receive descriptor is set when a frame still
needs software decryption. It is also clear for a frame that was never
encrypted, so a driver that sets RX_FLAG_DECRYPTED from it alone tells
mac80211 that plaintext was decrypted. 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.

Patches 1 and 2 set the flag only for a protected frame that is not a
robust management frame in rtl8192ce and rtl8192se, as the newer rtlwifi
chips do, and replace the vendor comment above the test, which no longer
matches. Patch 3 does the same for rtl8192cu, which also set the flag
for protected robust management frames and so skipped their software
decryption and MIC verification. It reads the header only when the URB
holds the frame control field.

The other rtlwifi receive descriptor parsers do not mark plaintext
frames as decrypted. rtl8188ee, rtl8192ee, rtl8723ae, rtl8723be and
rtl8821ae already use the same test. rtlwifi's process_agg_start()
marks only the DELBA frame it builds itself. The usb_rx_hdl hook of
rtl8192cu, whose _rtl_rx_process() sets the flag from SWDEC alone, is
never called.

rtl8192d (rtl8192de/rtl8192du) is intentionally left untouched here:
it checks the cipher reported in the RX descriptor, so unencrypted
frames are not marked as decrypted. However, when a cipher is reported
and SWDEC is clear, it still sets RX_FLAG_DECRYPTED for protected
robust management frames. Ping-Ke, does RTL8192D decrypt those in
hardware (or set SWDEC / report no cipher for them), or does it need a
robust management frame exclusion too?

Zhao Li (3):
  wifi: rtlwifi: rtl8192ce: don't mark unencrypted frames as decrypted
  wifi: rtlwifi: rtl8192se: don't mark unencrypted frames as decrypted
  wifi: rtlwifi: rtl8192cu: don't mark undecrypted frames as decrypted

 .../wireless/realtek/rtlwifi/rtl8192ce/trx.c    | 17 +++++------------
 .../wireless/realtek/rtlwifi/rtl8192cu/trx.c    | 14 ++++++++++----
 .../wireless/realtek/rtlwifi/rtl8192se/trx.c    | 16 +++++-----------
 3 files changed, 20 insertions(+), 27 deletions(-)


base-commit: 0bdc579dbfc251a6b6838ee9459b6771b948c617
-- 
2.56.1
RE: [PATCH rtw-next 0/3] wifi: rtlwifi: don't mark unencrypted frames as decrypted
Posted by Ping-Ke Shih 1 day, 6 hours ago
Zhao Li <enderaoelyther@gmail.com> wrote:
> rtl8192d (rtl8192de/rtl8192du) is intentionally left untouched here:
> it checks the cipher reported in the RX descriptor, so unencrypted
> frames are not marked as decrypted. However, when a cipher is reported
> and SWDEC is clear, it still sets RX_FLAG_DECRYPTED for protected
> robust management frames. Ping-Ke, does RTL8192D decrypt those in
> hardware (or set SWDEC / report no cipher for them), or does it need a
> robust management frame exclusion too?

Per rtl92d_rx_query_desc()

	stats->decrypted = !get_rx_desc_swdec(pdesc) &&
			   get_rx_desc_enc_type(pdesc) != RX_DESC_ENC_NONE;
	if (stats->decrypted)
		rx_status->flag |= RX_FLAG_DECRYPTED;

I remember this chip doesn't support PMF. For PMF packets, sw desc should be 0, 
and enc type should be NONE. So original logic should handle this properly.

 
RE: [PATCH rtw-next 0/3] wifi: rtlwifi: don't mark unencrypted frames as decrypted
Posted by Ping-Ke Shih 1 day, 6 hours ago
Ping-Ke Shih <pkshih@realtek.com> wrote:
> Zhao Li <enderaoelyther@gmail.com> wrote:
> > rtl8192d (rtl8192de/rtl8192du) is intentionally left untouched here:
> > it checks the cipher reported in the RX descriptor, so unencrypted
> > frames are not marked as decrypted. However, when a cipher is reported
> > and SWDEC is clear, it still sets RX_FLAG_DECRYPTED for protected
> > robust management frames. Ping-Ke, does RTL8192D decrypt those in
> > hardware (or set SWDEC / report no cipher for them), or does it need a
> > robust management frame exclusion too?
> 
> Per rtl92d_rx_query_desc()
> 
> 	stats->decrypted = !get_rx_desc_swdec(pdesc) &&
> 			   get_rx_desc_enc_type(pdesc) != RX_DESC_ENC_NONE;
> 	if (stats->decrypted)
> 		rx_status->flag |= RX_FLAG_DECRYPTED;
> 
> I remember this chip doesn't support PMF. For PMF packets, sw desc should be 0,
> and enc type should be NONE. So original logic should handle this properly.
> 

Looking into patch 1/3, I'm not sure the sw dec part:

	/* hw will set stats->decrypted true, if it finds the
	 * frame is open data frame or mgmt frame.
	 * So hw will not decryption robust management frame
	 * for IEEE80211w but still set status->decrypted
	 * true, so here we should set it back to undecrypted
	 * for IEEE80211w frame, and mac80211 sw will help
	 * to decrypt it
	 */

I think a real hardware is needed to check the status.