Commit Graph

1203182 Commits

Author SHA1 Message Date
Yue Haibing a3d9c4f7c4 wifi: mac80211: mesh: Remove unused function declaration mesh_ids_set_default()
Commit ccf80ddfe4 ("mac80211: mesh function and data structures
definitions") introducted this but never implemented it.

Signed-off-by: Yue Haibing <yuehaibing@huawei.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Link: https://lore.kernel.org/r/20230731140712.1204-1-yuehaibing@huawei.com
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2023-08-22 21:40:40 +02:00
Yue Haibing f14cef0045 wifi: mac80211: Remove unused function declarations
Commit 685429623f ("mac80211: Fix circular locking dependency in
ARP filter handling") left the ieee80211_set_arp_filter() declaration
unused.
And commit 164eb02d07 ("mac80211: add radar detection command/event")
introducted ieee80211_dfs_cac_timer() declaration but never implemented
it.

Signed-off-by: Yue Haibing <yuehaibing@huawei.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Link: https://lore.kernel.org/r/20230801134337.24452-1-yuehaibing@huawei.com
[reword commit message]
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2023-08-22 21:40:40 +02:00
Yue Haibing 7bdfda42f0 wifi: wext: Remove unused declaration dev_get_wireless_info()
Commit 5568296573 ("[NL80211]: add netlink interface to cfg80211")
declared but never implemented this, remove it.
Commit 11433ee450 ("[WEXT]: Move to net/wireless") rename net/core/wireless.c
to net/wireless/wext.c, then commit 3d23e349d8 ("wext: refactor") refactor
wext.c to wext-core.c, fix the wext comment.

Signed-off-by: Yue Haibing <yuehaibing@huawei.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Link: https://lore.kernel.org/r/20230807145032.44768-1-yuehaibing@huawei.com
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2023-08-22 21:40:40 +02:00
Lin Ma 218d690c49 wifi: nl80211/cfg80211: add forgotten nla_policy for BSS color attribute
The previous commit dd3e4fc75b ("nl80211/cfg80211: add BSS color to
NDP ranging parameters") adds a parameter for NDP ranging by introducing
a new attribute type named NL80211_PMSR_FTM_REQ_ATTR_BSS_COLOR.

However, the author forgot to also describe the nla_policy at
nl80211_pmsr_ftm_req_attr_policy (net/wireless/nl80211.c). Just
complement it to avoid malformed attribute that causes out-of-attribute
access.

Fixes: dd3e4fc75b ("nl80211/cfg80211: add BSS color to NDP ranging parameters")
Signed-off-by: Lin Ma <linma@zju.edu.cn>
Reviewed-by: Simon Horman <horms@kernel.org>
Link: https://lore.kernel.org/r/20230809033151.768910-1-linma@zju.edu.cn
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2023-08-22 21:40:40 +02:00
EN-WEI WU d40de0ad3d wifi: mac80211_hwsim: avoid calling nlmsg_free() in IRQ or IRQ disabled
The nlmsg_free() ends up calling kfree_skb(), and kfree_skb() is not allowed to be called
from hardware interrupt context or with hardware interrupts being disabled. Replace the
mistaken usage of nlmsg_free() by dev_kfree_skb_irq(), which is safe in both cases.

Signed-off-by: EN-WEI WU <enweiwu@FreeBSD.org>
Link: https://lore.kernel.org/r/20230815095427.13589-1-enweiwu@FreeBSD.org
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2023-08-22 21:40:40 +02:00
Johannes Berg 927521170c wifi: mac80211: fix puncturing bitmap handling in CSA
Code inspection reveals that we switch the puncturing bitmap
before the real channel switch, since that happens only in
the second round of the worker after the channel context is
switched by ieee80211_link_use_reserved_context().

Fixes: 2cc25e4b2a ("wifi: mac80211: configure puncturing bitmap")
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2023-08-22 21:40:39 +02:00
Johannes Berg fba360a047 wifi: mac80211_hwsim: drop short frames
While technically some control frames like ACK are shorter and
end after Address 1, such frames shouldn't be forwarded through
wmediumd or similar userspace, so require the full 3-address
header to avoid accessing invalid memory if shorter frames are
passed in.

Reported-by: syzbot+b2645b5bf1512b81fa22@syzkaller.appspotmail.com
Reviewed-by: Jeff Johnson <quic_jjohnson@quicinc.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2023-08-22 21:40:39 +02:00
Johannes Berg 67dfa589aa wifi: mac80211: check for station first in client probe
When probing a client, first check if we have it, and then
check for the channel context, otherwise you can trigger
the warning there easily by probing when the AP isn't even
started yet. Since a client existing means the AP is also
operating, we can then keep the warning.

Also simplify the moved code a bit.

Reported-by: syzbot+999fac712d84878a7379@syzkaller.appspotmail.com
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2023-08-22 21:40:39 +02:00
Johannes Berg abc76cf552 wifi: cfg80211: ocb: don't leave if not joined
If there's no OCB state, don't ask the driver/mac80211 to
leave, since that's just confusing. Since set/clear the
chandef state, that's a simple check.

Reported-by: syzbot+09d1cd2f71e6dd3bfd2c@syzkaller.appspotmail.com
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2023-08-22 21:40:39 +02:00
Johannes Berg 5d4e04bf3a wifi: cfg80211: reject auth/assoc to AP with our address
If the AP uses our own address as its MLD address or BSSID, then
clearly something's wrong. Reject such connections so we don't
try and fail later.

Reported-by: syzbot+2676771ed06a6df166ad@syzkaller.appspotmail.com
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2023-08-22 21:40:10 +02:00
Johannes Berg 19e4a47ee7 wifi: mac80211: check S1G action frame size
Before checking the action code, check that it even
exists in the frame.

Reported-by: syzbot+be9c824e6f269d608288@syzkaller.appspotmail.com
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2023-08-22 14:01:18 +02:00
Avraham Stern 6d2c360b4b wifi: iwlmei: don't send nic info with invalid mac address
In case the SAP connection is established before the interface is
added, the mac address is still not set. Don't send the nic info
SAP message in this case since it will result in sending an invalid
mac address. The nic info message will be sent with a valid mac
address when the interface is added.

Signed-off-by: Avraham Stern <avraham.stern@intel.com>
Signed-off-by: Gregory Greenman <gregory.greenman@intel.com>
Link: https://lore.kernel.org/r/20230822103048.a49436bed387.I0ca88d72456e6e9f939bbc2e0c52ffb173fbc97e@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2023-08-22 13:19:53 +02:00
Avraham Stern a7d9ac48a6 wifi: iwlmei: send driver down SAP message only if wiamt is enabled
When wiamt is disabled the driver up SAP message is not sent, so
there is no need to send the driver down message as well.

Signed-off-by: Avraham Stern <avraham.stern@intel.com>
Signed-off-by: Gregory Greenman <gregory.greenman@intel.com>
Link: https://lore.kernel.org/r/20230822103048.100f41b84656.I583d3e18ea65793f53aa710af13e47f8af82b53d@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2023-08-22 13:19:53 +02:00
Avraham Stern 3243aee1cb wifi: iwlmei: send HOST_GOES_DOWN message even if wiamt is disabled
The HOST_GOES_DOWN message should be sent even if wiamt is disabled.
Otherwise wiamt may still use the shared memory (e.g. if enabled
later) while it's no longer valid.

Signed-off-by: Avraham Stern <avraham.stern@intel.com>
Signed-off-by: Gregory Greenman <gregory.greenman@intel.com>
Link: https://lore.kernel.org/r/20230822103048.2baad50eb1c3.If7b7c1dc2d6bfc6bacf7f6c72972f19714d9d973@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2023-08-22 13:19:53 +02:00
Avraham Stern ef030ab17e wifi: iwlmei: don't send SAP messages if AMT is disabled
SAP messages should not be sent when AMT is disabled.

Signed-off-by: Avraham Stern <avraham.stern@intel.com>
Signed-off-by: Gregory Greenman <gregory.greenman@intel.com>
Link: https://lore.kernel.org/r/20230822103048.db16b55c27c1.I48834c14f5af8d31792f5048b3023509cba191dd@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2023-08-22 13:19:52 +02:00
Avraham Stern 057381ddac wifi: iwlwifi: pcie: avoid a warning in case prepare card failed
In case CSME holds the NIC and SAP connection is already established,
iwl_pcie_prepare_card_hw() during iwl_pci_probe() will fail
(which is fine since CSME will release the nic later when asked with
a SAP message). In this case tring to grab nic access to read the
crf ids will fail with a warning.
Avoid the warning by only trying to read the crf ids in case prepare
card succeeded.

Signed-off-by: Avraham Stern <avraham.stern@intel.com>
Signed-off-by: Gregory Greenman <gregory.greenman@intel.com>
Link: https://lore.kernel.org/r/20230822103048.9b026fa7b97e.I12bea7e6eef54eeeaf916b68d71583e92ff310fd@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2023-08-22 13:19:52 +02:00
Mukesh Sisodiya d166a5c977 wifi: iwlwifi: remove memory check for LMAC error address
LMAC error table address was checked against UMAC
error table minimum address defined. Because of that,
the LMAC error table was not read, since both addresses
belong to different ranges. As addresses are updated from
FW alive message and should be correct, this check is not
needed.

Still keep the check for address 0 to avoid NULL address read.

Signed-off-by: Mukesh Sisodiya <mukesh.sisodiya@intel.com>
Signed-off-by: Gregory Greenman <gregory.greenman@intel.com>
Link: https://lore.kernel.org/r/20230816104355.08ab1497904d.I270d4c5bcc23c5ecd0b7db475501032c450852ad@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2023-08-22 13:19:25 +02:00
Johannes Berg d09d290ae3 wifi: iwlwifi: mvm: support flush on AP interfaces
Support TX flush on AP interfaces so that we will do a
proper flush for frames on the queue before keys are
removed.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Gregory Greenman <gregory.greenman@intel.com>
Link: https://lore.kernel.org/r/20230816104355.f4b749b91ec2.Ia8381bd4f7d47592e74387c564739798a01c4049@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2023-08-22 13:19:24 +02:00
Johannes Berg 0922a71079 wifi: iwlwifi: mvm: enable HE TX/RX <242 tone RU on new RFs
Two new RFs were added in the code, but we forgot to
add them to the list here that enables HE TX/RX 1024
QAM less than 242 tone RU.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Gregory Greenman <gregory.greenman@intel.com>
Link: https://lore.kernel.org/r/20230816104355.ddb090c86c8c.Ic630aa579e3dc52069758d8698069480d555eefe@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2023-08-22 13:19:24 +02:00
Gregory Greenman 533d930862 wifi: iwlwifi: add Razer to ppag approved list
Add a new vendor (Razer) to PPAG approved list.

Signed-off-by: Gregory Greenman <gregory.greenman@intel.com>
Link: https://lore.kernel.org/r/20230816104355.f586a86fa644.I97408afb20bd7c46fcff8c3561ead8ed9c60b37e@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2023-08-22 13:19:24 +02:00
Johannes Berg c83031afaa wifi: iwlwifi: pcie: point invalid TFDs to invalid data
There are occasionally bugs which cause the device to try
to use a TFD that it wasn't supposed to, and these are
very hard to diagnose. Fill all unused TFDs with a debug
command that immediately causes an error to be detected
in these cases.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Gregory Greenman <gregory.greenman@intel.com>
Link: https://lore.kernel.org/r/20230816104355.10a9af1ca91f.Ifc790d62c52b4bc9a74c9581610af498509f5759@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2023-08-22 13:19:24 +02:00
Johannes Berg 80fa8377f5 wifi: iwlwifi: queue: move iwl_txq_gen2_set_tb() up
We need this earlier in the file next, move it up to have
an easier to read change, since this moves other things
in the diff git generates by default.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Gregory Greenman <gregory.greenman@intel.com>
Link: https://lore.kernel.org/r/20230816104355.c6d798b600bb.I9b891ee3d3dc67822a28e44941409f5b7cb637cf@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2023-08-22 13:19:24 +02:00
Johannes Berg c522948a47 wifi: iwlwifi: pcie: move gen1 TB handling to header
We will need this in another place soon in reclaim and init,
so add this function to the queue header file instead.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Gregory Greenman <gregory.greenman@intel.com>
Link: https://lore.kernel.org/r/20230816104355.52b6f66de219.Ic8403fd098c187fac067977808c0129d96514c91@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2023-08-22 13:19:24 +02:00
Johannes Berg d5050543f1 wifi: iwlwifi: remove 'def_rx_queue' struct member
This is only ever initialized to zero, use a new define
for the default RX queue instead.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Gregory Greenman <gregory.greenman@intel.com>
Link: https://lore.kernel.org/r/20230816104355.e0c6fa57c162.I907bbb428cf99725f06a348c8dbce5d3dd877136@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2023-08-22 13:19:24 +02:00
Johannes Berg a06320044a wifi: iwlwifi: pcie: clean up gen1/gen2 TFD unmap
This is a bit messy right now, there are functions for both,
but then gen1 function can actually deal with both gen1 and
gen2, due to the confusion about use_tfh/gen2 cleaned up in
the previous patch.

Fix the common paths to call the right functions and remove
handling of gen2 from the gen1 function.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Gregory Greenman <gregory.greenman@intel.com>
Link: https://lore.kernel.org/r/20230816104355.baf23841ec5c.I40702e94b25db05e82f935f14548316f8c6429b9@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2023-08-22 13:19:23 +02:00
Johannes Berg d9d115fed6 wifi: iwlwifi: remove WARN from read_mem32()
There's no reason to warn here, it's not an internal consistency
issue, we even use this to check if the device is dead, and if it
read_mem() returns an error that's either because grab NIC access
or memory allocation failed, both of which are already noisy.

Just remove the warning entirely.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Gregory Greenman <gregory.greenman@intel.com>
Link: https://lore.kernel.org/r/20230816104355.5f4e80eb63cc.Iffd88f63f95575f28e503da13b473724e3341aee@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2023-08-22 13:19:23 +02:00
Johannes Berg 0c2f92f6a5 wifi: iwlwifi: api: fix a small upper/lower-case typo
The structure name in the docs should be given in all
lower case matching the actual C declaration.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Gregory Greenman <gregory.greenman@intel.com>
Link: https://lore.kernel.org/r/20230816104355.c06f98055dbb.Ie9267108c57edcbb913f0d0f349eac85ca39409b@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2023-08-22 13:19:23 +02:00
Johannes Berg b336633070 wifi: iwlwifi: mvm: advertise MLO only if EHT is enabled
If 11ax/EHT is disabled, then we shouldn't advertise MLO
support either.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Gregory Greenman <gregory.greenman@intel.com>
Link: https://lore.kernel.org/r/20230816104355.ae4f9151440e.I6ce0b98d063d5005fd7a613454fcdb8b866a417a@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2023-08-22 13:19:23 +02:00
Kees Cook 545d3523df wifi: cfg80211: Annotate struct cfg80211_tid_config with __counted_by
Prepare for the coming implementation by GCC and Clang of the __counted_by
attribute. Flexible array members annotated with __counted_by can have
their accesses bounds-checked at run-time checking via CONFIG_UBSAN_BOUNDS
(for array indexing) and CONFIG_FORTIFY_SOURCE (for strcpy/memcpy-family
functions).

As found with Coccinelle[1], add __counted_by for struct cfg80211_tid_config.

[1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci

Cc: Johannes Berg <johannes@sipsolutions.net>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Eric Dumazet <edumazet@google.com>
Cc: Jakub Kicinski <kuba@kernel.org>
Cc: Paolo Abeni <pabeni@redhat.com>
Cc: linux-wireless@vger.kernel.org
Cc: netdev@vger.kernel.org
Signed-off-by: Kees Cook <keescook@chromium.org>
Reviewed-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Reviewed-by: Jeff Johnson <quic_jjohnson@quicinc.com>
Link: https://lore.kernel.org/r/20230817211531.4193219-7-keescook@chromium.org
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2023-08-22 13:18:16 +02:00
Kees Cook e3eac9f32e wifi: cfg80211: Annotate struct cfg80211_scan_request with __counted_by
Prepare for the coming implementation by GCC and Clang of the __counted_by
attribute. Flexible array members annotated with __counted_by can have
their accesses bounds-checked at run-time checking via CONFIG_UBSAN_BOUNDS
(for array indexing) and CONFIG_FORTIFY_SOURCE (for strcpy/memcpy-family
functions).

As found with Coccinelle[1], add __counted_by for struct cfg80211_scan_request.
Additionally, since the element count member must be set before accessing
the annotated flexible array member, move its initialization earlier.

[1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci

Cc: Johannes Berg <johannes@sipsolutions.net>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Eric Dumazet <edumazet@google.com>
Cc: Jakub Kicinski <kuba@kernel.org>
Cc: Paolo Abeni <pabeni@redhat.com>
Cc: linux-wireless@vger.kernel.org
Cc: netdev@vger.kernel.org
Signed-off-by: Kees Cook <keescook@chromium.org>
Reviewed-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Reviewed-by: Jeff Johnson <quic_jjohnson@quicinc.com>
Link: https://lore.kernel.org/r/20230817211531.4193219-6-keescook@chromium.org
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2023-08-22 13:18:16 +02:00
Kees Cook 7b6d708703 wifi: cfg80211: Annotate struct cfg80211_rnr_elems with __counted_by
Prepare for the coming implementation by GCC and Clang of the __counted_by
attribute. Flexible array members annotated with __counted_by can have
their accesses bounds-checked at run-time checking via CONFIG_UBSAN_BOUNDS
(for array indexing) and CONFIG_FORTIFY_SOURCE (for strcpy/memcpy-family
functions).

As found with Coccinelle[1], add __counted_by for struct cfg80211_rnr_elems.
Additionally, since the element count member must be set before accessing
the annotated flexible array member, move its initialization earlier.

[1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci

Cc: Johannes Berg <johannes@sipsolutions.net>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Eric Dumazet <edumazet@google.com>
Cc: Jakub Kicinski <kuba@kernel.org>
Cc: Paolo Abeni <pabeni@redhat.com>
Cc: linux-wireless@vger.kernel.org
Cc: netdev@vger.kernel.org
Signed-off-by: Kees Cook <keescook@chromium.org>
Reviewed-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Reviewed-by: Jeff Johnson <quic_jjohnson@quicinc.com>
Link: https://lore.kernel.org/r/20230817211531.4193219-5-keescook@chromium.org
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2023-08-22 13:18:16 +02:00
Kees Cook 342bc7c9e8 wifi: cfg80211: Annotate struct cfg80211_pmsr_request with __counted_by
Prepare for the coming implementation by GCC and Clang of the __counted_by
attribute. Flexible array members annotated with __counted_by can have
their accesses bounds-checked at run-time checking via CONFIG_UBSAN_BOUNDS
(for array indexing) and CONFIG_FORTIFY_SOURCE (for strcpy/memcpy-family
functions).

As found with Coccinelle[1], add __counted_by for struct cfg80211_pmsr_request.
Additionally, since the element count member must be set before accessing
the annotated flexible array member, move its initialization earlier.

[1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci

Cc: Johannes Berg <johannes@sipsolutions.net>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Eric Dumazet <edumazet@google.com>
Cc: Jakub Kicinski <kuba@kernel.org>
Cc: Paolo Abeni <pabeni@redhat.com>
Cc: linux-wireless@vger.kernel.org
Cc: netdev@vger.kernel.org
Signed-off-by: Kees Cook <keescook@chromium.org>
Reviewed-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Reviewed-by: Jeff Johnson <quic_jjohnson@quicinc.com>
Link: https://lore.kernel.org/r/20230817211531.4193219-4-keescook@chromium.org
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2023-08-22 13:18:16 +02:00
Kees Cook c14679d700 wifi: cfg80211: Annotate struct cfg80211_mbssid_elems with __counted_by
Prepare for the coming implementation by GCC and Clang of the __counted_by
attribute. Flexible array members annotated with __counted_by can have
their accesses bounds-checked at run-time checking via CONFIG_UBSAN_BOUNDS
(for array indexing) and CONFIG_FORTIFY_SOURCE (for strcpy/memcpy-family
functions).

As found with Coccinelle[1], add __counted_by for struct cfg80211_mbssid_elems.
Additionally, since the element count member must be set before accessing
the annotated flexible array member, move its initialization earlier.

[1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci

Cc: Johannes Berg <johannes@sipsolutions.net>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Eric Dumazet <edumazet@google.com>
Cc: Jakub Kicinski <kuba@kernel.org>
Cc: Paolo Abeni <pabeni@redhat.com>
Cc: linux-wireless@vger.kernel.org
Cc: netdev@vger.kernel.org
Signed-off-by: Kees Cook <keescook@chromium.org>
Reviewed-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Reviewed-by: Jeff Johnson <quic_jjohnson@quicinc.com>
Link: https://lore.kernel.org/r/20230817211531.4193219-3-keescook@chromium.org
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2023-08-22 13:18:16 +02:00
Kees Cook d4d3aaf25a wifi: cfg80211: Annotate struct cfg80211_cqm_config with __counted_by
Prepare for the coming implementation by GCC and Clang of the __counted_by
attribute. Flexible array members annotated with __counted_by can have
their accesses bounds-checked at run-time checking via CONFIG_UBSAN_BOUNDS
(for array indexing) and CONFIG_FORTIFY_SOURCE (for strcpy/memcpy-family
functions).

As found with Coccinelle[1], add __counted_by for struct cfg80211_cqm_config.

[1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci

Cc: Johannes Berg <johannes@sipsolutions.net>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Eric Dumazet <edumazet@google.com>
Cc: Jakub Kicinski <kuba@kernel.org>
Cc: Paolo Abeni <pabeni@redhat.com>
Cc: linux-wireless@vger.kernel.org
Cc: netdev@vger.kernel.org
Signed-off-by: Kees Cook <keescook@chromium.org>
Reviewed-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Reviewed-by: Jeff Johnson <quic_jjohnson@quicinc.com>
Link: https://lore.kernel.org/r/20230817211531.4193219-2-keescook@chromium.org
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2023-08-22 13:18:16 +02:00
Kees Cook 93ca82447c wifi: cfg80211: Annotate struct cfg80211_acl_data with __counted_by
Prepare for the coming implementation by GCC and Clang of the __counted_by
attribute. Flexible array members annotated with __counted_by can have
their accesses bounds-checked at run-time checking via CONFIG_UBSAN_BOUNDS
(for array indexing) and CONFIG_FORTIFY_SOURCE (for strcpy/memcpy-family
functions).

As found with Coccinelle[1], add __counted_by for struct cfg80211_acl_data.
Additionally, since the element count member must be set before accessing
the annotated flexible array member, move its initialization earlier.

[1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci

Cc: Johannes Berg <johannes@sipsolutions.net>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Eric Dumazet <edumazet@google.com>
Cc: Jakub Kicinski <kuba@kernel.org>
Cc: Paolo Abeni <pabeni@redhat.com>
Cc: linux-wireless@vger.kernel.org
Cc: netdev@vger.kernel.org
Signed-off-by: Kees Cook <keescook@chromium.org>
Reviewed-by: Justin Stitt <justinstitt@google.com>
Reviewed-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Reviewed-by: Jeff Johnson <quic_jjohnson@quicinc.com>
Link: https://lore.kernel.org/r/20230817211531.4193219-1-keescook@chromium.org
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2023-08-22 13:18:15 +02:00
Zong-Zhe Yang f585f4ab0b wifi: rtw89: regd: update regulatory map to R64-R43
Sync Realtek Regulatory R43 and Realtek Channel Plan R64.

1. add entry for XK (Kosovo)
2. change TH (Thailand) to Realtek regd world-wide
3. configures Realtek 6 GHz regd for below countries
   * AR, MX, HT -> FCC
   * LB, ZA, BF, LA, MN -> ETSI

Signed-off-by: Zong-Zhe Yang <kevin_yang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20230815120253.9901-1-pkshih@realtek.com
2023-08-21 19:14:59 +03:00
Dan Carpenter e2a61151ff wifi: rtw89: fix a width vs precision bug
The "buf" is skb->data that comes from the firmware.  We want to print
"len" number of bytes.  But there is a missing period so the "len"
variable is used for formatting (width) instead of limiting the output
(precision).

Fixes: cad2bd8a13 ("wifi: rtw89: support firmware log with formatted text")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/0700c7b9-bfd3-4aa6-82bf-5bf3c74644e1@moroto.mountain
2023-08-21 19:14:00 +03:00
Shiji Yang 186f243274 wifi: rt2x00: correct MAC_SYS_CTRL register RX mask in R-Calibration
For MAC_SYS_CTRL register, Bit[2] controls MAC_TX_EN and Bit[3]
controls MAC_RX_EN (Bit index starts from 0). Therefore, 0x08 is
the correct mask for RX.

Signed-off-by: Shiji Yang <yangshiji66@outlook.com>
Acked-by: Stanislaw Gruszka <stf_xl@wp.pl>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/TYAP286MB03150B571B67B896A504AC34BC0EA@TYAP286MB0315.JPNP286.PROD.OUTLOOK.COM
2023-08-21 19:13:21 +03:00
Yang Yingliang 66311106b2 wifi: rtlwifi: use eth_broadcast_addr() to assign broadcast address
Use eth_broadcast_addr() to assign broadcast address instead
of memcpy().

Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
Acked-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20230804090120.1332091-1-yangyingliang@huawei.com
2023-08-21 19:13:00 +03:00
Kuan-Chung Chen eb2624f55a wifi: rtw89: Introduce Time Averaged SAR (TAS) feature
Time Averaged SAR (TAS) tracks the amount of transmit power over a
period of time and adjusts the power accordingly. Two thresholds are
used to determine when to increase or reduce transmit power: Dynamic
Power Reduction (DPR) on/off. Compared to Static SAR, which has a
constant transmit power, TAS can improve the user experience or
range extension.

TAS can be enabled through BIOS, and the driver will evaluate
Realtek ACPI DSM with RTW89_ACPI_DSM_FUNC_TAS_EN to determine
whether TAS should be enabled.

Signed-off-by: Kuan-Chung Chen <damon.chen@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20230804053458.31492-1-pkshih@realtek.com
2023-08-21 19:11:05 +03:00
Ping-Ke Shih b3bfc4fb1e wifi: rtw89: 8852b: rfk: fine tune IQK parameters to improve performance on 2GHz band
A few samples get bad performance on 2GHz band, so use proper IQK command
code and select another group to have wider range of calibration value.

Fixes: f2abe804e8 ("wifi: rtw89: 8852b: rfk: add IQK")
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20230803110150.8457-1-pkshih@realtek.com
2023-08-21 19:10:35 +03:00
Justin Stitt 8767774946 wifi: ipw2x00: refactor to use kstrtoul
The current implementation seems to reinvent what `kstrtoul` already does
in terms of functionality and error handling. Remove uses of `simple_strtoul()`
in favor of `kstrtoul()`.

There is the following note at `lib/vsprintf.c:simple_strtoull()` which
further backs this change:
| * This function has caveats. Please use kstrtoull (or kstrtoul) instead.

And here, simple_str* are explicitly deprecated [3].

This patch also removes an instance of the deprecated `strncpy` which helps [2].

Compile tested only.

Link: https://lore.kernel.org/all/202308011602.3CC1C0244C@keescook/ [1]
Link: https://github.com/KSPP/linux/issues/90 [2]
Link: https://docs.kernel.org/process/deprecated.html#simple-strtol-simple-strtoll-simple-strtoul-simple-strtoull [3]
Cc: linux-hardening@vger.kernel.org
Suggested-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Justin Stitt <justinstitt@google.com>
Reviewed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20230802-wifi-ipw2x00-refactor-v2-1-d33f765e9cd5@google.com
2023-08-21 19:10:02 +03:00
Dmitry Antipov ab55a97609 wifi: mwifiex: fix comment typos in SDIO module
Fix comment typos around ' mwifiex_deaggr_sdio_pkt()'
and 'mwifiex_host_to_card_mp_aggr()'.

Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20230814142101.60308-2-dmantipov@yandex.ru
2023-08-21 18:58:11 +03:00
Dmitry Antipov 0e6ccd25e0 wifi: mwifiex: cleanup adapter data
Remove unused and set but unused 'dfs_workqueue', 'dfs_work', and
'scan_channels' members of 'struct mwifiex_adapter', adjust users.

Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>
Acked-by: Brian Norris <briannorris@chromium.org>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20230814142101.60308-1-dmantipov@yandex.ru
2023-08-21 18:58:11 +03:00
Polaris Pi 2785851c62 wifi: mwifiex: Fix missed return in oob checks failed path
Add missed return in mwifiex_uap_queue_bridged_pkt() and
mwifiex_process_rx_packet().

Fixes: 1195852816 ("wifi: mwifiex: Fix OOB and integer underflow when rx packets")
Signed-off-by: Polaris Pi <pinkperfect2021@gmail.com>
Reported-by: Dmitry Antipov <dmantipov@yandex.ru>
Acked-by: Brian Norris <briannorris@chromium.org>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20230810083911.3725248-1-pinkperfect2021@gmail.com
2023-08-21 18:57:39 +03:00
Ruan Jinjie a9be18642a wifi: mwifiex: use is_zero_ether_addr() instead of ether_addr_equal()
Use is_zero_ether_addr() instead of ether_addr_equal()
to check if the ethernet address is all zeros.

Signed-off-by: Ruan Jinjie <ruanjinjie@huawei.com>
Acked-by: Brian Norris <briannorris@chromium.org>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20230808081023.2303423-1-ruanjinjie@huawei.com
2023-08-21 18:57:03 +03:00
Dmitry Antipov 359838758c wifi: mwifiex: drop BUG_ON from TX paths
In 'mwifiex_process_sta_txpd()' and 'mwifiex_process_uap_txpd()',
replace 'BUG_ON()' with runtime check, and move all these checks
to 'mwifiex_process_tx()'. This way, both callees may be converted
to 'void', and the caller may be simplified as well.

Suggested-by: Brian Norris <briannorris@chromium.org>
Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>
Acked-by: Brian Norris <briannorris@chromium.org>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20230802160726.85545-5-dmantipov@yandex.ru
2023-08-21 18:56:27 +03:00
Dmitry Antipov a6b3a0169a wifi: mwifiex: handle possible mwifiex_write_reg() errors
Return -1 on possible 'mwifiex_write_reg()' errors in
'mwifiex_init_sdio_ioport()', do not ignore the value
returned by the latter in 'mwifiex_init_sdio()' and
'mwifiex_sdio_up_dev()' as well.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Acked-by: Brian Norris <briannorris@chromium.org>
Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20230802160726.85545-4-dmantipov@yandex.ru
2023-08-21 18:56:27 +03:00
Dmitry Antipov 968d02c613 wifi: mwifiex: handle possible sscanf() errors
Return -EINVAL on possible 'sscanf()' errors in
'mwifiex_regrdwr_write()' and 'mwifiex_rdeeprom_write()'.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Acked-by: Brian Norris <briannorris@chromium.org>
Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20230802160726.85545-3-dmantipov@yandex.ru
2023-08-21 18:56:27 +03:00
Dmitry Antipov 9b1cd8266f wifi: mwifiex: cleanup private data structures
Drop unused fields 'status_code' of 'struct mwifiex_txinfo',
'dfs_chan_switch_timer', 'sleep_params' (including related data
type 'struct mwifiex_sleep_params') of 'struct mwifiex_adapter',
adjust related code.

Acked-by: Brian Norris <briannorris@chromium.org>
Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20230802160726.85545-2-dmantipov@yandex.ru
2023-08-21 18:56:26 +03:00