Commit Graph
17 Commits
Author SHA1 Message Date
Felix Fietkau abd7d86939 mt76: clear skb pointers from rx aggregation reorder buffer during cleanup
During the cleanup of the aggregation session, a rx handler (or release timer)
on another CPU might still hold a pointer to the reorder buffer and could
attempt to release some packets.
Clearing pointers during cleanup avoids a theoretical use-after-free bug here.

Signed-off-by: Felix Fietkau <[email protected]>
2019-12-14 00:18:54 +01:00
Felix Fietkau d94cc81d39 mt76: drop rcu read lock in mt76_rx_aggr_stop
A rcu read locked section is not allowed to sleep, and the rcu lock here
isn't actually necessary, because we're holding dev->mutex.
Fixes an issue when the tid work item is still running while freeing
a station or stopping the aggregation session

Signed-off-by: Felix Fietkau <[email protected]>
2019-10-07 15:31:26 +02:00
Felix Fietkau 71c2ef0420 mt76: fix aggregation stop issue
Cancel the workqueue after the tid has been cleaned up, in order to
avoid a possible rescheduling from within the work function.

Signed-off-by: Felix Fietkau <[email protected]>
2019-10-07 12:31:48 +02:00
Felix Fietkau 0efbc5d1c2 mt76: use cancel_delayed_work_sync in mt76_rx_aggr_shutdown
The workqueue item needs to be fully shut down before the struct can be
freed.

Signed-off-by: Felix Fietkau <[email protected]>
2019-09-15 18:44:01 +02:00
Ryder LeeandFelix Fietkau 37673a4181 mt76: fix some checkpatch warnings
This fixes the following checkpatch warnings:
CHECK: Alignment should match open parenthesis
CHECK: No space is necessary after a cast

Signed-off-by: Ryder Lee <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2019-08-22 09:26:30 +02:00
Ryder LeeandFelix Fietkau f625afcedc mt76: switch to SPDX tag instead of verbose boilerplate text
No functional change intended.

Add SPDX identifiers to all remaining files in /mt76.

Signed-off-by: Ryder Lee <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2019-08-20 15:22:20 +02:00
Ryder LeeandFelix Fietkau 355c07904d mt76: use macro for sn and seq_ctrl conversion
Use macro to convert sn and seq_ctrl for better readability.

Signed-off-by: Roy Luo <[email protected]>
Signed-off-by: Ryder Lee <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2019-04-25 12:04:34 +02:00
Kees CookandFelix Fietkau df11092b19 treewide: Use struct_size() for kmalloc()-family
One of the more common cases of allocation size calculations is finding
the size of a structure that has a zero-sized array at the end, along
with memory for some number of elements for that array. For example:

struct foo {
    int stuff;
    void *entry[];
};

instance = kmalloc(sizeof(struct foo) + sizeof(void *) * count, GFP_KERNEL);

Instead of leaving these open-coded and prone to type mistakes, we can
now use the new struct_size() helper:

instance = kmalloc(struct_size(instance, entry, count), GFP_KERNEL);

This patch makes the changes for kmalloc()-family (and kvmalloc()-family)
uses. It was done via automatic conversion with manual review for the
"CHECKME" non-standard cases noted below, using the following Coccinelle
script:

// pkey_cache = kmalloc(sizeof *pkey_cache + tprops->pkey_tbl_len *
//                      sizeof *pkey_cache->table, GFP_KERNEL);
@@
identifier alloc =~ "kmalloc|kzalloc|kvmalloc|kvzalloc";
expression GFP;
identifier VAR, ELEMENT;
expression COUNT;
@@

- alloc(sizeof(*VAR) + COUNT * sizeof(*VAR->ELEMENT), GFP)
+ alloc(struct_size(VAR, ELEMENT, COUNT), GFP)

// mr = kzalloc(sizeof(*mr) + m * sizeof(mr->map[0]), GFP_KERNEL);
@@
identifier alloc =~ "kmalloc|kzalloc|kvmalloc|kvzalloc";
expression GFP;
identifier VAR, ELEMENT;
expression COUNT;
@@

- alloc(sizeof(*VAR) + COUNT * sizeof(VAR->ELEMENT[0]), GFP)
+ alloc(struct_size(VAR, ELEMENT, COUNT), GFP)

// Same pattern, but can't trivially locate the trailing element name,
// or variable name.
@@
identifier alloc =~ "kmalloc|kzalloc|kvmalloc|kvzalloc";
expression GFP;
expression SOMETHING, COUNT, ELEMENT;
@@

- alloc(sizeof(SOMETHING) + COUNT * sizeof(ELEMENT), GFP)
+ alloc(CHECKME_struct_size(&SOMETHING, ELEMENT, COUNT), GFP)

Signed-off-by: Kees Cook <[email protected]>
2018-09-12 13:18:26 +02:00
Lorenzo BianconiandFelix Fietkau 730b86c73a mt76x2: add napi struct to mt76_rx_poll_complete/mt76_rx_complete signatures
in order to reuse mt76_rx_complete routine supporting mt76x2u based
devices add napi struct to mt76_rx_poll_complete and mt76_rx_complete
routine signatures and do not fetch it according to the rx queue index

Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Kalle Valo <[email protected]>
2018-09-11 13:49:19 +02:00
Felix Fietkau d9e5da36e2 mt76: add rcu locking in tid reorder function
Avoids having the tid or station entry disappear prematurely.
Also cancel the reorder work earlier

Signed-off-by: Felix Fietkau <[email protected]>
2018-04-14 21:48:35 +02:00
Felix Fietkau ffa2069e78 mt76: fix potential sleep in atomic context
Use cancel_delayed_work instead of cancel_delayed_work_sync

Signed-off-by: Felix Fietkau <[email protected]>
2018-02-27 16:04:08 +01:00
Felix Fietkau 62d52e940b mt76: set RX_FLAG_DUP_VALIDATED for A-MPDU reordered packets
Required for fast-rx and allows mac80211 to skip an unnnecessary check.

Signed-off-by: Felix Fietkau <[email protected]>
2018-02-09 16:28:09 +01:00
Felix Fietkau 8693864cd5 mt76: check qos ack policy before reordering packets
Do not attempt to reorder packets not part of a BA session

Signed-off-by: Felix Fietkau <[email protected]>
2018-01-29 09:35:39 +01:00
Felix Fietkau c5209db332 mt76: avoid re-queueing A-MPDU rx reorder work if no frames are pending
Signed-off-by: Felix Fietkau <[email protected]>
2018-01-26 13:16:25 +01:00
Felix Fietkau 974142c098 mt76: implement processing of BlockAckReq frames
Avoids timeouts on reordered A-MPDU rx frames

Signed-off-by: Felix Fietkau <[email protected]>
2018-01-26 12:34:49 +01:00
Felix Fietkau cf3cfc43af mt76: split mt76_rx_complete
Add a separate function for processing frames after A-MPDU reordering,
reduce code duplication

Signed-off-by: Felix Fietkau <[email protected]>
2018-01-22 10:43:22 +01:00
Felix Fietkau b0508d3044 mt76: implement A-MPDU rx reordering in the driver code
This is required for performing CCMP PN validation in software

Signed-off-by: Felix Fietkau <[email protected]>
2018-01-22 10:43:21 +01:00