Skip to content

Commit 76a56eb

Browse files
jmalinenjmberg-intel
authored andcommitted
mac80211_hwsim: Fix radiotap header for ACK frames
The earlier addition of rt_tsft to struct hwsim_radiotap_hdr updated only mac80211_hwsim_monitor_tx() to fill in the new field. mac80211_hwsim_monitor_ack() did not set the rt_tsft field and as such, leaked eight bytes of kernel memory to user space. In addition, the resulting radiotap header is invalid since the field offsets do not match. Fix these issues by defining a separate radiotap header structure for the ACK frame case which does not use all the fields. Signed-off-by: Jouni Malinen <j@w1.fi> Signed-off-by: Johannes Berg <johannes.berg@intel.com>
1 parent 2d3db21 commit 76a56eb

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

‎drivers/net/wireless/mac80211_hwsim.c‎

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,14 @@ struct hwsim_radiotap_hdr {
383383
__le16 rt_chbitmask;
384384
} __packed;
385385

386+
struct hwsim_radiotap_ack_hdr {
387+
struct ieee80211_radiotap_header hdr;
388+
u8 rt_flags;
389+
u8 pad;
390+
__le16 rt_channel;
391+
__le16 rt_chbitmask;
392+
} __packed;
393+
386394
/* MAC80211_HWSIM netlinf family */
387395
static struct genl_family hwsim_genl_family = {
388396
.id = GENL_ID_GENERATE,
@@ -500,7 +508,7 @@ static void mac80211_hwsim_monitor_ack(struct ieee80211_channel *chan,
500508
const u8 *addr)
501509
{
502510
struct sk_buff *skb;
503-
struct hwsim_radiotap_hdr *hdr;
511+
struct hwsim_radiotap_ack_hdr *hdr;
504512
u16 flags;
505513
struct ieee80211_hdr *hdr11;
506514

@@ -511,14 +519,14 @@ static void mac80211_hwsim_monitor_ack(struct ieee80211_channel *chan,
511519
if (skb == NULL)
512520
return;
513521

514-
hdr = (struct hwsim_radiotap_hdr *) skb_put(skb, sizeof(*hdr));
522+
hdr = (struct hwsim_radiotap_ack_hdr *) skb_put(skb, sizeof(*hdr));
515523
hdr->hdr.it_version = PKTHDR_RADIOTAP_VERSION;
516524
hdr->hdr.it_pad = 0;
517525
hdr->hdr.it_len = cpu_to_le16(sizeof(*hdr));
518526
hdr->hdr.it_present = cpu_to_le32((1 << IEEE80211_RADIOTAP_FLAGS) |
519527
(1 << IEEE80211_RADIOTAP_CHANNEL));
520528
hdr->rt_flags = 0;
521-
hdr->rt_rate = 0;
529+
hdr->pad = 0;
522530
hdr->rt_channel = cpu_to_le16(chan->center_freq);
523531
flags = IEEE80211_CHAN_2GHZ;
524532
hdr->rt_chbitmask = cpu_to_le16(flags);

0 commit comments

Comments
 (0)