From: Kalle Valo <kvalo@codeaurora.org>
To: Amitkumar Karwar <amitkarwar@gmail.com>
Cc: linux-wireless@vger.kernel.org,
Amitkumar Karwar <amit.karwar@redpinesignals.com>,
Siva Rebbagondla <siva.rebbagondla@redpinesignals.com>
Subject: Re: [PATCH 10/10] rsi: drop RX broadcast/multicast packets with invalid PN
Date: Tue, 13 Mar 2018 17:34:35 +0200 [thread overview]
Message-ID: <87r2ooyook.fsf@purkki.adurom.net> (raw)
In-Reply-To: <1520260620-4694-11-git-send-email-amitkarwar@gmail.com> (Amitkumar Karwar's message of "Mon, 5 Mar 2018 20:07:00 +0530")
Amitkumar Karwar <amitkarwar@gmail.com> writes:
> From: Siva Rebbagondla <siva.rebbagondla@redpinesignals.com>
>
> This patch adds a check to drop received broadcast/multicast frames if
> PN is invalid (i.e. not greater than last PN). bc_mc_pn
> variable added for each interface
>
> Signed-off-by: Siva Rebbagondla <siva.rebbagondla@redpinesignals.com>
> Signed-off-by: Amitkumar Karwar <amit.karwar@redpinesignals.com>
[...]
> +static int rsi_validate_pn(struct rsi_hw *adapter, struct ieee80211_hdr *hdr)
> +{
> + struct ieee80211_vif *vif;
> + struct ieee80211_bss_conf *bss;
> + struct vif_priv *vif_info = NULL;
> + u8 cur_pn[IEEE80211_CCMP_PN_LEN];
> + u8 *last_pn;
> + int i, hdrlen;
> +
> + if (!is_broadcast_ether_addr(hdr->addr1) &&
> + !is_multicast_ether_addr(hdr->addr1))
> + return 1;
> +
> + hdrlen = ieee80211_hdrlen(hdr->frame_control);
> + for (i = 0; i < adapter->sc_nvifs; i++) {
> + vif = adapter->vifs[i];
> +
> + if (!vif)
> + continue;
> + if (vif->type != NL80211_IFTYPE_STATION &&
> + vif->type != NL80211_IFTYPE_P2P_CLIENT)
> + continue;
> + bss = &vif->bss_conf;
> + if (!bss->assoc)
> + continue;
> + if (!ether_addr_equal(bss->bssid, hdr->addr2))
> + continue;
> + vif_info = (struct vif_priv *)vif->drv_priv;
> + if (!vif_info->key) {
> + vif_info = NULL;
> + continue;
> + }
> + if (!vif_info->rx_pn_valid) {
> + vif_info = NULL;
> + continue;
> + }
> + }
> + if (!vif_info)
> + return 1;
Why +1 here?
> + last_pn = vif_info->rx_bcmc_pn;
> + if (vif_info->key->cipher == WLAN_CIPHER_SUITE_CCMP) {
> + struct dot11_ccmp_hdr *ccmp =
> + (struct dot11_ccmp_hdr *)&((u8 *)hdr)[hdrlen];
> +
> + cur_pn[0] = ccmp->pn0;
> + cur_pn[1] = ccmp->pn1;
> + cur_pn[2] = ccmp->pn2;
> + cur_pn[3] = ccmp->pn3;
> + cur_pn[4] = ccmp->pn4;
> + cur_pn[5] = ccmp->pn5;
> + } else {
> + struct dot11_tkip_hdr *tkip =
> + (struct dot11_tkip_hdr *)&((u8 *)hdr)[hdrlen];
> +
> + cur_pn[0] = tkip->tsc0;
> + cur_pn[1] = tkip->tsc1;
> + cur_pn[2] = tkip->tsc2;
> + cur_pn[3] = tkip->tsc3;
> + cur_pn[4] = tkip->tsc4;
> + cur_pn[5] = tkip->tsc5;
> + }
> + for (i = (IEEE80211_CCMP_PN_LEN - 1); i >= 0; i--)
> + if (last_pn[i] ^ cur_pn[i])
> + break;
> + if (i < 0)
> + return -1;
And why -1 here? Please use real error codes (-EINVAL etc).
> @@ -1341,14 +1488,14 @@ static void rsi_fill_rx_status(struct ieee80211_hw *hw,
> }
> }
> if (!bss)
> - return;
> + return -1;
Here as well.
--
Kalle Valo
next prev parent reply other threads:[~2018-03-13 15:34 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-05 14:36 [PATCH 00/10] rsi driver enhancements Amitkumar Karwar
2018-03-05 14:36 ` [PATCH 01/10] rsi: add support for hardware scan offload Amitkumar Karwar
2018-03-13 15:16 ` Kalle Valo
2018-03-13 15:18 ` Kalle Valo
2018-03-15 7:10 ` Amitkumar Karwar
2018-03-15 7:08 ` Amitkumar Karwar
2018-03-15 9:00 ` Kalle Valo
2018-03-15 9:27 ` Amitkumar Karwar
2018-03-20 22:32 ` Johannes Berg
2018-03-23 14:50 ` Amitkumar Karwar
2018-03-27 13:22 ` Johannes Berg
2018-03-27 14:18 ` Kalle Valo
2018-03-27 14:31 ` Amitkumar Karwar
2018-03-05 14:36 ` [PATCH 02/10] rsi: move xtend_desc structure from rsi_main.h to rsi_mgmt.h Amitkumar Karwar
2018-03-05 14:36 ` [PATCH 03/10] rsi: move descriptor preparation to core Amitkumar Karwar
2018-03-05 14:36 ` [PATCH 04/10] rsi: enable 80MHz clock by default Amitkumar Karwar
2018-03-05 14:36 ` [PATCH 05/10] rsi: roaming enhancements Amitkumar Karwar
2018-03-13 15:24 ` Kalle Valo
2018-03-15 7:29 ` Amitkumar Karwar
2018-03-05 14:36 ` [PATCH 06/10] rsi: add module parameter rsi_reg Amitkumar Karwar
2018-03-13 15:25 ` Kalle Valo
2018-03-15 10:58 ` Amitkumar Karwar
2018-03-05 14:36 ` [PATCH 07/10] rsi: regulatory modifications for 'dlcar' mode Amitkumar Karwar
2018-03-05 14:36 ` [PATCH 08/10] rsi: device disconnect changes Amitkumar Karwar
2018-03-13 15:27 ` Kalle Valo
2018-03-15 11:45 ` Amitkumar Karwar
2018-03-05 14:36 ` [PATCH 09/10] rsi: tx improvements Amitkumar Karwar
2018-03-13 15:29 ` Kalle Valo
2018-03-15 11:46 ` Amitkumar Karwar
2018-03-05 14:37 ` [PATCH 10/10] rsi: drop RX broadcast/multicast packets with invalid PN Amitkumar Karwar
2018-03-13 15:34 ` Kalle Valo [this message]
2018-03-20 22:55 ` Johannes Berg
2018-03-23 14:57 ` Amitkumar Karwar
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=87r2ooyook.fsf@purkki.adurom.net \
--to=kvalo@codeaurora.org \
--cc=amit.karwar@redpinesignals.com \
--cc=amitkarwar@gmail.com \
--cc=linux-wireless@vger.kernel.org \
--cc=siva.rebbagondla@redpinesignals.com \
/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.