From: Mathy Vanhoef <Mathy.Vanhoef@kuleuven.be>
To: Johannes Berg <johannes@sipsolutions.net>,
linux-wireless@vger.kernel.org
Cc: mathy.vanhoef@nyu.edu
Subject: [PATCH] mac80211: keep non-zero sequence counter of injected frames
Date: Sun, 28 Jun 2020 22:05:12 +0400 [thread overview]
Message-ID: <20200628220512.28535ebc@mathy-work.localhost> (raw)
The sequence number of injected frames is being overwritten by the
function ieee80211_tx_h_sequence when the following two conditions
are met:
1. The frame is injected on a virtual interface, and a second virtual
interface on this device is operating in managed/AP/.. mode.
2. The sender MAC address of the injected frame matches the MAC
address of the second interface operating in managed/AP/.. mode.
In some cases this may be desired, for instance when hostap is
configured to send certain frames using a monitor interface, in which
case the user-space will not assign a sequence number and instead
injects frames with a sequence number of zero.
However, in case the user-space does assign a non-zero sequence
number, this number should not be overwritten by the kernel. This
patch adds a check to see if injected frames have already been assigned
a non-zero sequence number, and if so, this sequence number will not
be overwritten by the kernel.
Signed-off-by: Mathy Vanhoef <mathy.vanhoef@nyu.edu>
---
net/mac80211/tx.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c
index 1a2941e52..8bb8c548c 100644
--- a/net/mac80211/tx.c
+++ b/net/mac80211/tx.c
@@ -808,11 +808,14 @@ ieee80211_tx_h_sequence(struct ieee80211_tx_data *tx)
int tid;
/*
- * Packet injection may want to control the sequence
- * number, if we have no matching interface then we
- * neither assign one ourselves nor ask the driver to.
+ * Packet injection may want to control the sequence number.
+ * Do not assign one ourselves, and do not ask the driver to,
+ * if there is no matching interface or if the injected frame
+ * was already assigned a non-zero sequence number.
*/
- if (unlikely(info->control.vif->type == NL80211_IFTYPE_MONITOR))
+ if (unlikely(info->control.vif->type == NL80211_IFTYPE_MONITOR ||
+ (info->flags & IEEE80211_TX_CTL_INJECTED != 0 &&
+ hdr->seq_ctrl != 0)))
return TX_CONTINUE;
if (unlikely(ieee80211_is_ctl(hdr->frame_control)))
--
2.20.1
next reply other threads:[~2020-06-28 18:13 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-28 18:05 Mathy Vanhoef [this message]
2020-06-28 18:59 ` [PATCH] mac80211: keep non-zero sequence counter of injected frames Johannes Berg
2020-07-01 7:32 ` Mathy Vanhoef
2020-06-29 9:38 ` kernel test robot
2020-06-29 9:38 ` kernel test robot
2020-06-29 11:19 ` kernel test robot
2020-06-29 11:19 ` kernel test robot
2020-06-29 12:30 ` kernel test robot
2020-06-29 12:30 ` kernel test robot
2020-07-07 13:45 ` Dan Carpenter
2020-07-07 13:45 ` Dan Carpenter
2020-07-07 13:45 ` Dan Carpenter
2020-07-07 13:55 ` Mathy Vanhoef
-- strict thread matches above, loose matches on Subject: below --
2020-07-02 16:17 kernel test robot
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=20200628220512.28535ebc@mathy-work.localhost \
--to=mathy.vanhoef@kuleuven.be \
--cc=johannes@sipsolutions.net \
--cc=linux-wireless@vger.kernel.org \
--cc=mathy.vanhoef@nyu.edu \
/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.