| 0/0 |
2026/09/04 14:13 |
flow |
assessment-security |
7m
Results: map[DenialOfService:false Explanation:The bug is caused by `ieee80211_parse_tx_radiotap()` failing to find a valid
rate in the injected radiotap header and leaving `info->control.rates[0].idx`
set to `-1`. Later, when the frame is transmitted, `mac80211_hwsim` calls
`ieee80211_get_tx_rate()`, which checks `WARN_ON_ONCE(c->control.rates[0].idx <
0)` and returns `NULL`. The caller properly handles the `NULL` return value, so
this does not lead to any memory corruption, information leak, or crash.
In production builds, `WARN_ON_ONCE` simply logs a warning and continues
execution without halting the kernel. Therefore, this bug does not cause a
Denial of Service (DoS).
While some physical drivers (like `cw1200`) might trigger a `BUG_ON` if they
encounter a negative rate index, triggering this requires injecting frames into
that specific physical device. Frame injection requires a monitor interface,
which can only be created by a user with `CAP_NET_ADMIN` in the network
namespace where the device resides. Physical devices are typically restricted to
the initial network namespace, meaning only a privileged user (root) could
trigger the crash on such hardware.
However, the bug can be reached from an unprivileged user namespace by
leveraging the `mac80211_hwsim` module. The `hwsim_genl_family` allows creating
virtual radios from non-initial network namespaces (`.netnsok = true`). An
unprivileged user can create a user namespace, obtain `CAP_NET_ADMIN` within it,
create a virtual `mac80211_hwsim` radio, set up a monitor interface, and inject
a malformed frame to trigger the warning. Since it only results in a handled
warning, it has no security impact.
**Conclusion:**
- **Exploitable:** No. The negative index is either properly handled or checked
before use in most drivers, and the `mac80211` core handles it gracefully.
- **Denial of Service:** No. The `WARN_ON_ONCE` does not crash the kernel in
production.
- **Accessible From User Namespaces:** Yes. An unprivileged user can create a
user namespace, instantiate a `mac80211_hwsim` device, and trigger the warning. Exploitable:false FilesystemTrigger:false NetworkTrigger:false PeripheralTrigger:false RemoteTrigger:false Unprivileged:false UserNamespace:true VMGuestTrigger:false VMHostTrigger:false]
|
| 1/1 |
2026/09/04 14:13 |
action |
syz-repro-to-c-repro |
0m
Results:
|
| 2/1 |
2026/09/04 14:13 |
action |
kernel-checkouter |
0m
Results: map[KernelSrc:/app/workdir/cache/src/3e9556fdea5ea68aeb007d973d2ad74d50ccef20]
|
| 3/1 |
2026/09/04 14:13 |
action |
kernel-builder |
0m
Results: map[KernelObj:/app/workdir/cache/build/558279590f301114bd3ba2da13d47e12b038656e]
|
| 4/1 |
2026/09/04 14:13 |
action |
codesearch-prepare |
0m
Results: map[Index:codesearch-index]
|
| 5/1 |
2026/09/04 14:13 |
agent |
expert |
6m
Model:
Results: map[DenialOfService:false Exploitable:false FilesystemTrigger:false NetworkTrigger:false PeripheralTrigger:false RemoteTrigger:false Unprivileged:false UserNamespace:true VMGuestTrigger:false VMHostTrigger:false]
Instruction: You are an experienced Linux kernel security engineer. Your task is to analyze given kernel bug report
and determine its security impact based on the following dimensions.
Use the provided tools to examine the source code, check for capability checks (e.g., capable(), ns_capable()),
and understand the nature of the bug. Analyze the given kernel build and configuration.
You can check the kernel config by grepping ".config" file; you can check kernel cmdline by grepping
".config" file for "CONFIG_CMDLINE=". Assume sysctl parameters have default values.
But analyze for the corresponding production build w/o debugging tools enabled (like KASAN, KMSAN, UBSAN).
Try different strategies when analyzing the bug:
- think of ways in which the vulnerable code is unreachable
- or the other way around: try to come up with different ideas of how an unprivileged user can reach the bug
If still unsure err on the side of the bug being non-exploitable/not-accessible.
In the final reply, provide a reasoning for your assessment.
Analysis dimensions:
* Exploitable:
Determine if the bug can result in memory corruption, elevated privileges, or an information leak.
Memory safety issues are almost always exploitable (KASAN or UBSAN reports for use-after-free, out-of-bounds;
refcounting issues, corrupted lists, etc). When kernel is crashing on a completely wild pointer access
(e.g. user-space address, or non-canonical address, but not on NULL or address corresponding to KASAN shadow
for NULL address), including both data accesses and control transfers, that also usually implies possibility
of exploitation. Such reports usually say "unable to handle kernel paging request".
Uses of uninitialized values detected by KMSAN may be exploitable b/c attacker frequently can affect uninit
values with spraying techniques. However, for these exploitability depends on how exactly the uninit value
is used in the code, and what it affects.
Information leaks are exploitable on their own and should be classified as such. A bug that copies kernel
memory contents to userspace (e.g. an out-of-bounds read whose result is returned to the caller, or
uninitialized stack/heap bytes written to a user buffer) is exploitable: it can reveal kernel pointer
values and defeat KASLR, expose sensitive data such as cryptographic keys or other processes' memory, and
serves as a necessary building block in most modern kernel privilege-escalation exploit chains. Do not classify
an information leak as non-exploitable solely because it does not directly cause a memory write or control-flow
hijack; the leak itself is the exploit primitive.
Think of what happens after the bug is triggered. Some bugs cause kernel panic and halt execution,
they are harder to exploit. For example, BUG reports halts the kernel. However, WARNING reports don't halt
execution in production builds. Debug bug detection tools (like KASAN, KMSAN, KCSAN, UBSAN) are also not enabled
in production builds, so attacker can freely exploit these bugs w/o being detected by these tools.
If you see an integer overflow, think how the overflowed value used later (if it's used as allocation size,
or an array index). If you see an out-of-bounds read, think if it's followed by an out-of-bounds write as well.
Some KCSAN data-races may be exploitable by skilled attackers as well. Think what data structures got corrupted
as the result of data races and how. However, note that kernel has lots of "benign" data races that don't lead
to any runtime misbehavior at all.
* Denial Of Service:
Determine if the bug can result in denial-of-service. Most bugs can, since they cause system crash,
hangs, deadlocks, or resource leaks. This is mostly applicable to WARNING bugs that won't cause system crash
in production. For these think what will be consequences of the violation of the kernel assumptions flagged
by the WARNING. In some cases the unexpected condition is also properly handled by the normal control flow
(e.g. with "if (WARN_ON(...))"), these won't cause denial-of-service. If the condition is not handled,
then it may or may not cause denial-of-service.
* Accessible From Unprivileged Processes:
Determine if the bug can be reached from a typical (non-root) user process that does NOT have any special capabilities
(like CAP_SYS_ADMIN, CAP_NET_ADMIN, CAP_NET_RAW, CAP_PERFMON) or access to device nodes restricted to root.
Assume that unprivileged_bpf_disabled=1, that is eBPF loading is not accessible. However, cBPF (classical BPF)
is still accessible to non-root processes.
Assume that user namespaces are not accessible, that is, the process cannot get the mentioned capabilities even
within a new user namespace (checked by ns_capable() function in the kernel sources).
* Accessible From User Namespaces:
Determine if the bug can be reached within a user-namespace where the process has all capabilities
(including CAP_SYS_ADMIN, CAP_NET_ADMIN, CAP_NET_RAW, CAP_PERFMON). Such capabilities are checked with ns_capable()
function in the kernel sources.
* VM Guest Trigger:
Determine if the bug can be triggered from the context of a typical KVM guest (e.g., set up by a QEMU VMM).
Consider accesses to standard Linux host paravirtualized features (virtio-blk, virtio-net, etc.),
and handling of VM exits in the KVM code.
* VM Host Trigger in The Confidential Computing Context:
Determine if the bug can be triggered in a confidential computing guest kernel from the context of a KVM host.
Consider access to standard Linux guest paravirtualized features (virtio-blk, virtio-net, etc.).
* Ethernet Network Trigger:
Determine if the bug can be triggered by processing ingress network Ethernet traffic, either directly (network stack)
or via drivers exposed to network data.
* Other Remote Trigger:
Determine if the bug can be triggered by processing remote traffic other than Ethernet (Wifi, Bluetooth, NFC, etc).
* Peripheral Trigger:
Determine if the bug can be triggered via an untrusted peripheral device that can be physically plugged
into a system, such as a USB device or a niche hardware driver handling external hardware inputs.
This is particularly important for mobile and desktop environments where users can plug in unknown devices.
* Malicious Filesystem Trigger:
Determine if the bug can be triggered by the kernel mounting and parsing a malicious filesystem image.
This is highly critical for Desktop and Mobile environments where external media or downloaded images
might be auto-mounted.
Don't make assumptions about the kernel source code (it may be different from what you assume it is).
Extensively use the provided code access tools (codesearch-*, git-*, grepper, etc)
to examine the actual source code, and confirm any assumptions.
Prefer calling several tools at the same time to save round-trips.
Use set-results tool to provide results of the analysis.
It must be called exactly once before the final reply.
Ignore results of this tool.
Prompt:
The kernel bug report is:
netlink: 80 bytes leftover after parsing attributes in process `syz.4.6946'.
------------[ cut here ]------------
c->control.rates[0].idx < 0
WARNING: ./include/net/mac80211.h:3413 at ieee80211_get_tx_rate include/net/mac80211.h:3413 [inline], CPU#1: syz.4.6946/31565
WARNING: ./include/net/mac80211.h:3413 at mac80211_hwsim_get_tx_rate drivers/net/wireless/virtual/mac80211_hwsim_main.c:1335 [inline], CPU#1: syz.4.6946/31565
WARNING: ./include/net/mac80211.h:3413 at mac80211_hwsim_write_tsf+0x4ca/0x6b0 drivers/net/wireless/virtual/mac80211_hwsim_main.c:1617, CPU#1: syz.4.6946/31565
Modules linked in:
CPU: 1 UID: 0 PID: 31565 Comm: syz.4.6946 Tainted: G L syzkaller #0 PREEMPT(full)
Tainted: [L]=SOFTLOCKUP
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 07/24/2026
RIP: 0010:ieee80211_get_tx_rate include/net/mac80211.h:3413 [inline]
RIP: 0010:mac80211_hwsim_get_tx_rate drivers/net/wireless/virtual/mac80211_hwsim_main.c:1335 [inline]
RIP: 0010:mac80211_hwsim_write_tsf+0x4ca/0x6b0 drivers/net/wireless/virtual/mac80211_hwsim_main.c:1617
Code: 41 5c 41 5d 41 5e 41 5f 5d e9 32 cd ab 04 e8 8d e8 8c fa 66 bd 64 00 4d 8d bc 24 a8 49 00 00 e9 18 fc ff ff e8 77 e8 8c fa 90 <0f> 0b 90 e9 86 fc ff ff 89 d9 80 e1 07 38 c1 0f 8c be fb ff ff be
RSP: 0018:ffffc90003eb6d78 EFLAGS: 00010283
RAX: ffffffff873ad2a9 RBX: ffff888058132a30 RCX: 0000000000080000
RDX: ffffc90005c19000 RSI: 000000000000023a RDI: 000000000000023b
RBP: ffff88805ae00f40 R08: 0000000000000003 R09: 0000000000000004
R10: dffffc0000000000 R11: fffff520007d6da0 R12: ffff88805ae03220
R13: ffff888058132a00 R14: dffffc0000000000 R15: ffffffffffffffff
FS: 00007f213d4426c0(0000) GS:ffff888124dda000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000001b2d723ffc CR3: 0000000039eac000 CR4: 00000000003526f0
Call Trace:
<TASK>
mac80211_hwsim_tx_frame_no_nl+0x16b/0x1760 drivers/net/wireless/virtual/mac80211_hwsim_main.c:1913
mac80211_hwsim_tx+0x18cb/0x2580 drivers/net/wireless/virtual/mac80211_hwsim_main.c:2276
drv_tx net/mac80211/driver-ops.h:38 [inline]
ieee80211_tx_frags+0x3df/0x890 net/mac80211/tx.c:1753
__ieee80211_tx+0x267/0x580 net/mac80211/tx.c:1808
ieee80211_tx+0x312/0x4b0 net/mac80211/tx.c:1991
ieee80211_monitor_start_xmit+0xb33/0x1280 net/mac80211/tx.c:2486
__netdev_start_xmit include/linux/netdevice.h:5429 [inline]
netdev_start_xmit include/linux/netdevice.h:5438 [inline]
xmit_one net/core/dev.c:3937 [inline]
dev_hard_start_xmit+0x2cd/0x830 net/core/dev.c:3953
__dev_queue_xmit+0x14c0/0x3820 net/core/dev.c:4926
packet_snd net/packet/af_packet.c:3110 [inline]
packet_sendmsg+0x3d0d/0x4f80 net/packet/af_packet.c:3142
sock_sendmsg_nosec+0x13a/0x180 net/socket.c:800
__sock_sendmsg net/socket.c:815 [inline]
__sys_sendto+0x408/0x5a0 net/socket.c:2281
__do_sys_sendto net/socket.c:2288 [inline]
__se_sys_sendto net/socket.c:2284 [inline]
__x64_sys_sendto+0xde/0x100 net/socket.c:2284
do_syscall_x64 arch/x86/entry/syscall_64.c:61 [inline]
do_syscall_64+0x166/0x520 arch/x86/entry/syscall_64.c:84
entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7f213c59e159
Code: ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 44 00 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 e8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007f213d442028 EFLAGS: 00000246 ORIG_RAX: 000000000000002c
RAX: ffffffffffffffda RBX: 00007f213c825fa0 RCX: 00007f213c59e159
RDX: 000000000000002b RSI: 0000200000000540 RDI: 000000000000000b
RBP: 00007f213c635024 R08: 0000200000000380 R09: 0000000000000014
R10: 0000000004000000 R11: 0000000000000246 R12: 0000000000000000
R13: 00007f213c826038 R14: 00007f213c825fa0 R15: 00007f213c94fa48
</TASK>
Reply: The bug is caused by `ieee80211_parse_tx_radiotap()` failing to find a valid rate in the injected radiotap header and leaving `info->control.rates[0].idx` set to `-1`. Later, when the frame is transmitted, `mac80211_hwsim` calls `ieee80211_get_tx_rate()`, which checks `WARN_ON_ONCE(c->control.rates[0].idx < 0)` and returns `NULL`. The caller properly handles the `NULL` return value, so this does not lead to any memory corruption, information leak, or crash.
In production builds, `WARN_ON_ONCE` simply logs a warning and continues execution without halting the kernel. Therefore, this bug does not cause a Denial of Service (DoS).
While some physical drivers (like `cw1200`) might trigger a `BUG_ON` if they encounter a negative rate index, triggering this requires injecting frames into that specific physical device. Frame injection requires a monitor interface, which can only be created by a user with `CAP_NET_ADMIN` in the network namespace where the device resides. Physical devices are typically restricted to the initial network namespace, meaning only a privileged user (root) could trigger the crash on such hardware.
However, the bug can be reached from an unprivileged user namespace by leveraging the `mac80211_hwsim` module. The `hwsim_genl_family` allows creating virtual radios from non-initial network namespaces (`.netnsok = true`). An unprivileged user can create a user namespace, obtain `CAP_NET_ADMIN` within it, create a virtual `mac80211_hwsim` radio, set up a monitor interface, and inject a malformed frame to trigger the warning. Since it only results in a handled warning, it has no security impact.
**Conclusion:**
- **Exploitable:** No. The negative index is either properly handled or checked before use in most drivers, and the `mac80211` core handles it gracefully.
- **Denial of Service:** No. The `WARN_ON_ONCE` does not crash the kernel in production.
- **Accessible From User Namespaces:** Yes. An unprivileged user can create a user namespace, instantiate a `mac80211_hwsim` device, and trigger the warning.
|
| 6/2 |
2026/09/04 14:13 |
llm |
expert |
0m
Model:
Tokens:
input: 8283
output: 49
thoughts: 71
Thoughts: Here's my thinking process:
**Investigating a mac80211 TX Rate Warning**
Okay, I've got a `WARNING` flag related to `ieee80211_get_tx_rate`, specifically in `include/net/mac80211.h` line 3413. The warning says `c->control.rates[0].idx < 0`. Immediately, this screams potential index-out-of-bounds issue within the rate control data structure. `rates[0]` implies we're dealing with an array, and a negative index is a definite error. This suggests a problem within the rate selection logic, potentially a bug in how rates are being assigned or validated before being accessed. I need to dive into that function, *now*. I need to see *why* the index could be negative. My focus is going to be tracing where `c->control.rates[0].idx` is set, and under what conditions. What data structures is `c` part of? Are there race conditions, or incorrect initialization paths leading to this negative index? This could be a symptom of a larger problem. Let's dig in and figure out the root cause.
|
| 7/2 |
2026/09/04 14:13 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:include/net/mac80211.h Name:ieee80211_get_tx_rate]
Results: map[SourceCode:3409: static inline struct ieee80211_rate *
3410: ieee80211_get_tx_rate(const struct ieee80211_hw *hw,
3411: const struct ieee80211_tx_info *c)
3412: {
3413: if (WARN_ON_ONCE(c->control.rates[0].idx < 0))
3414: return NULL;
3415:
3416: if (c->band >= NUM_NL80211_BANDS)
3417: return NULL;
3418:
3419: return &hw->wiphy->bands[c->band]->bitrates[c->control.rates[0].idx];
3420: }
SourceFile:include/net/mac80211.h]
|
| 8/2 |
2026/09/04 14:14 |
llm |
expert |
0m
Model:
Tokens:
input: 8912
output: 60
thoughts: 82
Thoughts: Okay, here's my interpretation of this code snippet, filtered through my expert lens:
**Analyzing a Potential Issue in the mac80211-based HWSIM module**
Alright, so I've got a warning flag, `WARN_ON_ONCE(c->control.rates[0].idx < 0)`. That immediately screams "index out of bounds" to me. Specifically, it looks like there's a potential for the first rate index (`idx`) within a control structure (`c->control`) to go negative. The fact that the code specifically uses `WARN_ON_ONCE` indicates that this is probably a fairly rare condition, but one that warrants investigation because it could lead to much more serious problems down the line – corrupted data, crashes, the whole nine yards.
The code's returning NULL if this negative index happens. This tells me that wherever this is happening, the program relies on the null pointer to figure out that the rate requested isn't valid. The fact that it's returning `NULL` immediately raises a flag. We need to look more closely where this situation occurs and evaluate the consequence.
I need to understand the implications of this. I'll check where the warning is generated and how it's handled. `mac80211_hwsim_get_tx_rate` and `mac80211_hwsim_write_tsf` are the two functions that call it. The name suggests this is related to tx rate calculation or the TSF timer. This is important to understand in the context of `mac80211`. Now, I have to go through the code to understand the potential scenario when the `c->control.rates[0].idx < 0` is true, and the consequent handling and the effects it could have on the entire system.
|
| 9/2 |
2026/09/04 14:14 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/net/wireless/virtual/mac80211_hwsim_main.c Name:mac80211_hwsim_get_tx_rate]
Results: map[SourceCode:1327: static struct ieee80211_rate *
1328: mac80211_hwsim_get_tx_rate(struct ieee80211_hw *hw,
1329: struct ieee80211_tx_info *info)
1330: {
1331: if (info->control.rates[0].flags &
1332: (IEEE80211_TX_RC_MCS | IEEE80211_TX_RC_VHT_MCS))
1333: return NULL;
1334:
1335: return ieee80211_get_tx_rate(hw, info);
1336: }
SourceFile:drivers/net/wireless/virtual/mac80211_hwsim_main.c]
|
| 10/2 |
2026/09/04 14:14 |
llm |
expert |
0m
Model:
Tokens:
input: 9682
output: 59
thoughts: 17
Thoughts: Okay, here's my attempt at summarizing the thought process, as if it were my own, assuming I'm an expert in the field:
**Decoding the `mac80211_hwsim_write_tsf` Function**
Alright, let's break down `mac80211_hwsim_write_tsf`. From what I see here, this likely involves manipulating the Time Synchronization Function (TSF) within the hardware simulation environment, specifically for the mac80211 framework. I'm immediately thinking about the impact this has on emulating accurate timing behaviors, particularly for aspects of 802.11 like beacon intervals, DTIM delivery, and general clock drift within the simulated wireless environment.
The fact that this is a *write* function suggests we're setting or modifying the TSF counter value. This is crucial for synchronizing virtual devices. Depending on how the simulation is set up, this counter probably needs to be maintained, or adjusted, to allow for correct operation of the simulated 802.11 networks. I need to consider potential race conditions, atomicity requirements if there are multiple virtual devices trying to interact.
I need to understand what events trigger this function, and if it's tied into the standard mac80211 hardware abstraction layer (HAL) interface. Is this triggered from a simulated hardware interrupt? Or is the simulation proactively writing to the TSF? Are there any data structures this function updates, and if so, what are their implications? Are there any hooks that might be implemented in mac80211 core?
I'm thinking about the various corner cases. What happens when the TSF counter wraps around? How does the simulation handle the transition? Are there any error conditions that need to be checked? Does the simulated TSF value get exposed somehow, to be read back or manipulated by the simulation itself, or external monitoring tools?
This function is a small piece of a much larger puzzle, and I'd need to consider the broader context of the hardware simulation environment to have a clear understanding of its operation. It all relates to the accurate time emulation and the correctness of the virtual Wi-Fi behavior.
|
| 11/2 |
2026/09/04 14:14 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/net/wireless/virtual/mac80211_hwsim_main.c Name:mac80211_hwsim_write_tsf]
Results: map[SourceCode:1605: static void mac80211_hwsim_write_tsf(struct mac80211_hwsim_data *data,
1606: struct sk_buff *skb, u64 sim_time)
1607: {
1608: struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
1609: struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
1610: struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *)skb->data;
1611: struct ieee80211_rate *txrate;
1612: /* TODO: get MCS */
1613: int bitrate = 100;
1614:
1615: spin_lock_bh(&data->tsf_offset_lock);
1616:
1617: txrate = mac80211_hwsim_get_tx_rate(data->hw, info);
1618: if (txrate)
1619: bitrate = txrate->bitrate;
1620:
1621: if (skb->len >= offsetofend(typeof(*mgmt), u.probe_resp.timestamp) &&
1622: ieee80211_is_probe_resp(hdr->frame_control)) {
1623: mgmt->u.probe_resp.timestamp =
1624: cpu_to_le64(sim_time + data->tsf_offset +
1625: 24 * 8 * 10 / bitrate);
1626: } else if (skb->len >= offsetofend(typeof(*mgmt), u.beacon.timestamp) &&
1627: ieee80211_is_beacon(mgmt->frame_control)) {
1628: mgmt->u.beacon.timestamp = cpu_to_le64(sim_time +
1629: data->tsf_offset +
1630: 24 * 8 * 10 /
1631: bitrate);
1632: } else if (skb->len >= offsetofend(struct ieee80211_ext,
1633: u.s1g_beacon.timestamp) &&
1634: ieee80211_is_s1g_beacon(mgmt->frame_control)) {
1635: struct ieee80211_ext *ext = (void *)mgmt;
1636:
1637: ext->u.s1g_beacon.timestamp = cpu_to_le32(sim_time +
1638: data->tsf_offset +
1639: 10 * 8 * 10 /
1640: bitrate);
1641: }
1642:
1643: spin_unlock_bh(&data->tsf_offset_lock);
1644: }
SourceFile:drivers/net/wireless/virtual/mac80211_hwsim_main.c]
|
| 12/2 |
2026/09/04 14:14 |
llm |
expert |
0m
Model:
Tokens:
input: 11080
output: 50
thoughts: 717
Thoughts: **Analyzing a Warning in mac80211_hwsim**
Okay, so I'm looking at this `WARN_ON_ONCE` in `mac80211_hwsim`. It's checking if `c->control.rates[0].idx` is negative. If it *is*, it returns `NULL`. My initial thought was, "Uh oh, potential crash or undefined behavior?". But then I saw that in `mac80211_hwsim_write_tsf`, if `txrate` is `NULL`, the `bitrate` just defaults to 100. So, the code *does* handle the `NULL` return gracefully, which is good. That makes the warning seem benign – it's just a heads-up, not a critical bug.
But... why is `c->control.rates[0].idx` negative in the first place? That's the real question. `c` is the `ieee80211_tx_info` struct, obtained via `IEEE80211_SKB_CB(skb)`. Let's dig into where `info->control.rates[0].idx` gets set.
The call trace... hmm... looks like this packet is coming from userspace via AF_PACKET, hitting `mac80211_monitor_start_xmit`. Okay, that's interesting. I need to trace this back, it looks like there's some issue coming from the userspace, potentially with how the packet is being constructed or injected into the driver.
|
| 13/2 |
2026/09/04 14:14 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:net/mac80211/tx.c Name:ieee80211_monitor_start_xmit]
Results: map[SourceCode:2324: netdev_tx_t ieee80211_monitor_start_xmit(struct sk_buff *skb,
2325: struct net_device *dev)
2326: {
2327: struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
2328: struct ieee80211_chanctx_conf *chanctx_conf;
2329: struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
2330: struct ieee80211_hdr *hdr;
2331: struct ieee80211_sub_if_data *tmp_sdata, *sdata;
2332: struct cfg80211_chan_def *chandef;
2333: u16 len_rthdr;
2334: int hdrlen;
2335:
2336: sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2337: if (unlikely(!ieee80211_sdata_running(sdata)))
2338: goto fail;
2339:
2340: memset(info, 0, sizeof(*info));
2341: info->flags = IEEE80211_TX_CTL_REQ_TX_STATUS |
2342: IEEE80211_TX_CTL_INJECTED;
2343:
2344: /* Sanity-check the length of the radiotap header */
2345: if (!ieee80211_validate_radiotap_len(skb))
2346: goto fail;
2347:
2348: /* we now know there is a radiotap header with a length we can use */
2349: len_rthdr = ieee80211_get_radiotap_len(skb->data);
2350:
2351: /*
2352: * fix up the pointers accounting for the radiotap
2353: * header still being in there. We are being given
2354: * a precooked IEEE80211 header so no need for
2355: * normal processing
2356: */
2357: skb_set_mac_header(skb, len_rthdr);
2358: /*
2359: * these are just fixed to the end of the rt area since we
2360: * don't have any better information and at this point, nobody cares
2361: */
2362: skb_set_network_header(skb, len_rthdr);
2363: skb_set_transport_header(skb, len_rthdr);
2364:
2365: if (skb->len < len_rthdr + 2)
2366: goto fail;
2367:
2368: hdr = (struct ieee80211_hdr *)(skb->data + len_rthdr);
2369: hdrlen = ieee80211_hdrlen(hdr->frame_control);
2370:
2371: if (skb->len < len_rthdr + hdrlen)
2372: goto fail;
2373:
2374: /*
2375: * Initialize skb->protocol if the injected frame is a data frame
2376: * carrying a rfc1042 header
2377: */
2378: if (ieee80211_is_data(hdr->frame_control) &&
2379: skb->len >= len_rthdr + hdrlen + sizeof(rfc1042_header) + 2) {
2380: u8 *payload = (u8 *)hdr + hdrlen;
2381:
2382: if (ether_addr_equal(payload, rfc1042_header))
2383: skb->protocol = cpu_to_be16((payload[6] << 8) |
2384: payload[7]);
2385: }
2386:
2387: rcu_read_lock();
2388:
2389: /*
2390: * We process outgoing injected frames that have a local address
2391: * we handle as though they are non-injected frames.
2392: * This code here isn't entirely correct, the local MAC address
2393: * isn't always enough to find the interface to use; for proper
2394: * VLAN support we have an nl80211-based mechanism.
2395: *
2396: * This is necessary, for example, for old hostapd versions that
2397: * don't use nl80211-based management TX/RX.
2398: */
2399: list_for_each_entry_rcu(tmp_sdata, &local->interfaces, list) {
2400: if (!ieee80211_sdata_running(tmp_sdata))
2401: continue;
2402: if (tmp_sdata->vif.type == NL80211_IFTYPE_MONITOR ||
2403: tmp_sdata->vif.type == NL80211_IFTYPE_AP_VLAN)
2404: continue;
2405: if (ether_addr_equal(tmp_sdata->vif.addr, hdr->addr2)) {
2406: sdata = tmp_sdata;
2407: break;
2408: }
2409: }
2410:
2411: chanctx_conf = rcu_dereference(sdata->vif.bss_conf.chanctx_conf);
2412: if (!chanctx_conf) {
2413: tmp_sdata = rcu_dereference(local->monitor_sdata);
2414: if (tmp_sdata)
2415: chanctx_conf =
2416: rcu_dereference(tmp_sdata->vif.bss_conf.chanctx_conf);
2417: }
2418:
2419: if (!chanctx_conf) {
2420: struct ieee80211_chanctx *ctx;
2421: bool first = true;
2422:
2423: list_for_each_entry_rcu(ctx, &local->chanctx_list, list) {
2424: if (!first)
2425: goto fail_rcu;
2426: chanctx_conf = &ctx->conf;
2427: first = false;
2428: }
2429: }
2430:
2431: if (chanctx_conf)
2432: chandef = &chanctx_conf->def;
2433: else
2434: goto fail_rcu;
2435:
2436: /*
2437: * If driver/HW supports IEEE80211_CHAN_CAN_MONITOR we still
2438: * shouldn't transmit on disabled channels.
2439: */
2440: if (!cfg80211_chandef_usable(local->hw.wiphy, chandef,
2441: IEEE80211_CHAN_DISABLED))
2442: goto fail_rcu;
2443:
2444: /*
2445: * Frame injection is not allowed if beaconing is not allowed
2446: * or if we need radar detection. Beaconing is usually not allowed when
2447: * the mode or operation (Adhoc, AP, Mesh) does not support DFS.
2448: * Passive scan is also used in world regulatory domains where
2449: * your country is not known and as such it should be treated as
2450: * NO TX unless the channel is explicitly allowed in which case
2451: * your current regulatory domain would not have the passive scan
2452: * flag.
2453: *
2454: * Since AP mode uses monitor interfaces to inject/TX management
2455: * frames we can make AP mode the exception to this rule once it
2456: * supports radar detection as its implementation can deal with
2457: * radar detection by itself. We can do that later by adding a
2458: * monitor flag interfaces used for AP support.
2459: */
2460: if (!cfg80211_reg_can_beacon(local->hw.wiphy, chandef,
2461: sdata->vif.type))
2462: goto fail_rcu;
2463:
2464: info->band = chandef->chan->band;
2465:
2466: /* Initialize skb->priority according to frame type and TID class,
2467: * with respect to the sub interface that the frame will actually
2468: * be transmitted on. If the DONT_REORDER flag is set, the original
2469: * skb-priority is preserved to assure frames injected with this
2470: * flag are not reordered relative to each other.
2471: */
2472: ieee80211_select_queue_80211(sdata, skb, hdr);
2473: skb_set_queue_mapping(skb, ieee80211_ac_from_tid(skb->priority));
2474:
2475: /*
2476: * Process the radiotap header. This will now take into account the
2477: * selected chandef above to accurately set injection rates and
2478: * retransmissions.
2479: */
2480: if (!ieee80211_parse_tx_radiotap(skb, dev))
2481: goto fail_rcu;
2482:
2483: /* remove the injection radiotap header */
2484: skb_pull(skb, len_rthdr);
2485:
2486: ieee80211_xmit(sdata, NULL, skb);
2487: rcu_read_unlock();
2488:
2489: return NETDEV_TX_OK;
2490:
2491: fail_rcu:
2492: rcu_read_unlock();
2493: fail:
2494: dev_kfree_skb(skb);
2495: return NETDEV_TX_OK; /* meaning, we dealt with the skb */
2496: }
SourceFile:net/mac80211/tx.c]
|
| 14/2 |
2026/09/04 14:14 |
llm |
expert |
0m
Model:
Tokens:
input: 15149
output: 51
thoughts: 40
Thoughts: Here's my summary, as though I were thinking through the process:
**Diving into the 802.11 TX Radiotap Parsing**
Okay, so `ieee80211_parse_tx_radiotap` is being called. That immediately tells me we're dealing with the outgoing side of things – transmitting a frame. My job, right now, is to dissect this Radiotap header. This is where all the interesting metadata about the transmission is packed, and I need to extract the relevant details. The primary focus right now is probably the transmission rates. I need to pull out that information and store it where I can readily use it. Specifically, I'm setting `info->control.rates[0].idx`. That `idx` field tells me the index of the first transmission rate that will be used for this particular frame. Got it; that's the starting point. Time to examine the Radiotap data and pull out that index value!
|
| 15/2 |
2026/09/04 14:14 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:net/mac80211/tx.c Name:ieee80211_parse_tx_radiotap]
Results: map[SourceCode:2106: bool ieee80211_parse_tx_radiotap(struct sk_buff *skb,
2107: struct net_device *dev)
2108: {
2109: struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
2110: struct ieee80211_radiotap_iterator iterator;
2111: struct ieee80211_radiotap_header *rthdr =
2112: (struct ieee80211_radiotap_header *) skb->data;
2113: struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
2114: int ret = ieee80211_radiotap_iterator_init(&iterator, rthdr, skb->len,
2115: NULL);
2116: u16 txflags;
2117: u16 rate = 0;
2118: bool rate_found = false;
2119: u8 rate_retries = 0;
2120: u16 rate_flags = 0;
2121: u8 mcs_known, mcs_flags, mcs_bw;
2122: u16 vht_known;
2123: u8 vht_mcs = 0, vht_nss = 0;
2124: int i;
2125:
2126: if (!ieee80211_validate_radiotap_len(skb))
2127: return false;
2128:
2129: info->flags |= IEEE80211_TX_INTFL_DONT_ENCRYPT |
2130: IEEE80211_TX_CTL_DONTFRAG;
2131:
2132: /*
2133: * for every radiotap entry that is present
2134: * (ieee80211_radiotap_iterator_next returns -ENOENT when no more
2135: * entries present, or -EINVAL on error)
2136: */
2137:
2138: while (!ret) {
2139: ret = ieee80211_radiotap_iterator_next(&iterator);
2140:
2141: if (ret)
2142: continue;
2143:
2144: /* see if this argument is something we can use */
2145: switch (iterator.this_arg_index) {
2146: /*
2147: * You must take care when dereferencing iterator.this_arg
2148: * for multibyte types... the pointer is not aligned. Use
2149: * get_unaligned((type *)iterator.this_arg) to dereference
2150: * iterator.this_arg for type "type" safely on all arches.
2151: */
2152: case IEEE80211_RADIOTAP_FLAGS:
2153: if (*iterator.this_arg & IEEE80211_RADIOTAP_F_FCS) {
2154: /*
2155: * this indicates that the skb we have been
2156: * handed has the 32-bit FCS CRC at the end...
2157: * we should react to that by snipping it off
2158: * because it will be recomputed and added
2159: * on transmission
2160: */
2161: if (skb->len < (iterator._max_length + FCS_LEN))
2162: return false;
2163:
2164: skb_trim(skb, skb->len - FCS_LEN);
2165: }
2166: if (*iterator.this_arg & IEEE80211_RADIOTAP_F_WEP)
2167: info->flags &= ~IEEE80211_TX_INTFL_DONT_ENCRYPT;
2168: if (*iterator.this_arg & IEEE80211_RADIOTAP_F_FRAG)
2169: info->flags &= ~IEEE80211_TX_CTL_DONTFRAG;
2170: break;
2171:
2172: case IEEE80211_RADIOTAP_TX_FLAGS:
2173: txflags = get_unaligned_le16(iterator.this_arg);
2174: if (txflags & IEEE80211_RADIOTAP_F_TX_NOACK)
2175: info->flags |= IEEE80211_TX_CTL_NO_ACK;
2176: if (txflags & IEEE80211_RADIOTAP_F_TX_NOSEQNO)
2177: info->control.flags |= IEEE80211_TX_CTRL_NO_SEQNO;
2178: if (txflags & IEEE80211_RADIOTAP_F_TX_ORDER)
2179: info->control.flags |=
2180: IEEE80211_TX_CTRL_DONT_REORDER;
2181: break;
2182:
2183: case IEEE80211_RADIOTAP_RATE:
2184: rate = *iterator.this_arg;
2185: rate_flags = 0;
2186: rate_found = true;
2187: break;
2188:
2189: case IEEE80211_RADIOTAP_ANTENNA:
2190: /* this can appear multiple times, keep a bitmap */
2191: /* control.antennas is only a 2-bit bitmap */
2192: if (*iterator.this_arg < 2)
2193: info->control.antennas |= BIT(*iterator.this_arg);
2194: break;
2195:
2196: case IEEE80211_RADIOTAP_DATA_RETRIES:
2197: rate_retries = *iterator.this_arg;
2198: break;
2199:
2200: case IEEE80211_RADIOTAP_MCS:
2201: mcs_known = iterator.this_arg[0];
2202: mcs_flags = iterator.this_arg[1];
2203: if (!(mcs_known & IEEE80211_RADIOTAP_MCS_HAVE_MCS))
2204: break;
2205:
2206: rate_found = true;
2207: rate = iterator.this_arg[2];
2208: rate_flags = IEEE80211_TX_RC_MCS;
2209:
2210: if (mcs_known & IEEE80211_RADIOTAP_MCS_HAVE_GI &&
2211: mcs_flags & IEEE80211_RADIOTAP_MCS_SGI)
2212: rate_flags |= IEEE80211_TX_RC_SHORT_GI;
2213:
2214: mcs_bw = mcs_flags & IEEE80211_RADIOTAP_MCS_BW_MASK;
2215: if (mcs_known & IEEE80211_RADIOTAP_MCS_HAVE_BW &&
2216: mcs_bw == IEEE80211_RADIOTAP_MCS_BW_40)
2217: rate_flags |= IEEE80211_TX_RC_40_MHZ_WIDTH;
2218:
2219: if (mcs_known & IEEE80211_RADIOTAP_MCS_HAVE_FEC &&
2220: mcs_flags & IEEE80211_RADIOTAP_MCS_FEC_LDPC)
2221: info->flags |= IEEE80211_TX_CTL_LDPC;
2222:
2223: if (mcs_known & IEEE80211_RADIOTAP_MCS_HAVE_STBC) {
2224: u8 stbc = u8_get_bits(mcs_flags,
2225: IEEE80211_RADIOTAP_MCS_STBC_MASK);
2226:
2227: info->flags |=
2228: u32_encode_bits(stbc,
2229: IEEE80211_TX_CTL_STBC);
2230: }
2231: break;
2232:
2233: case IEEE80211_RADIOTAP_VHT:
2234: vht_known = get_unaligned_le16(iterator.this_arg);
2235: rate_found = true;
2236:
2237: rate_flags = IEEE80211_TX_RC_VHT_MCS;
2238: if ((vht_known & IEEE80211_RADIOTAP_VHT_KNOWN_GI) &&
2239: (iterator.this_arg[2] &
2240: IEEE80211_RADIOTAP_VHT_FLAG_SGI))
2241: rate_flags |= IEEE80211_TX_RC_SHORT_GI;
2242: if (vht_known &
2243: IEEE80211_RADIOTAP_VHT_KNOWN_BANDWIDTH) {
2244: if (iterator.this_arg[3] == 1)
2245: rate_flags |=
2246: IEEE80211_TX_RC_40_MHZ_WIDTH;
2247: else if (iterator.this_arg[3] == 4)
2248: rate_flags |=
2249: IEEE80211_TX_RC_80_MHZ_WIDTH;
2250: else if (iterator.this_arg[3] == 11)
2251: rate_flags |=
2252: IEEE80211_TX_RC_160_MHZ_WIDTH;
2253: }
2254:
2255: vht_mcs = iterator.this_arg[4] >> 4;
2256: if (vht_mcs > 11)
2257: vht_mcs = 0;
2258: vht_nss = iterator.this_arg[4] & 0xF;
2259: if (!vht_nss || vht_nss > 8)
2260: vht_nss = 1;
2261: break;
2262:
2263: /*
2264: * Please update the file
2265: * Documentation/networking/mac80211-injection.rst
2266: * when parsing new fields here.
2267: */
2268:
2269: default:
2270: break;
2271: }
2272: }
2273:
2274: if (ret != -ENOENT) /* ie, if we didn't simply run out of fields */
2275: return false;
2276:
2277: if (rate_found) {
2278: struct ieee80211_supported_band *sband =
2279: local->hw.wiphy->bands[info->band];
2280:
2281: info->control.flags |= IEEE80211_TX_CTRL_RATE_INJECT;
2282:
2283: for (i = 0; i < IEEE80211_TX_MAX_RATES; i++) {
2284: info->control.rates[i].idx = -1;
2285: info->control.rates[i].flags = 0;
2286: info->control.rates[i].count = 0;
2287: }
2288:
2289: if (rate_flags & IEEE80211_TX_RC_MCS) {
2290: /* reset antennas if not enough */
2291: if (IEEE80211_HT_MCS_CHAINS(rate) >
2292: hweight8(info->control.antennas))
2293: info->control.antennas = 0;
2294:
2295: info->control.rates[0].idx = rate;
2296: } else if (rate_flags & IEEE80211_TX_RC_VHT_MCS) {
2297: /* reset antennas if not enough */
2298: if (vht_nss > hweight8(info->control.antennas))
2299: info->control.antennas = 0;
2300:
2301: ieee80211_rate_set_vht(info->control.rates, vht_mcs,
2302: vht_nss);
2303: } else if (sband) {
2304: for (i = 0; i < sband->n_bitrates; i++) {
2305: if (rate * 5 != sband->bitrates[i].bitrate)
2306: continue;
2307:
2308: info->control.rates[0].idx = i;
2309: break;
2310: }
2311: }
2312:
2313: if (info->control.rates[0].idx < 0)
2314: info->control.flags &= ~IEEE80211_TX_CTRL_RATE_INJECT;
2315:
2316: info->control.rates[0].flags = rate_flags;
2317: info->control.rates[0].count = min_t(u8, rate_retries + 1,
2318: local->hw.max_rate_tries);
2319: }
2320:
2321: return true;
2322: }
SourceFile:net/mac80211/tx.c]
|
| 16/2 |
2026/09/04 14:14 |
llm |
expert |
0m
Model:
Tokens:
input: 19322
output: 60
thoughts: 918
Thoughts: **Analyzing a Potential Rate Injection Bug**
Okay, so I'm looking at this code snippet, and my initial thought is: this looks like a potential issue with how we're handling rate injection, particularly when a suitable rate isn't found. The core of it revolves around setting the `info->control.rates[0].idx` field.
If `rate_found` is true, it seems we're entering a rate injection scenario. We first initialize the rate array, clear the flags and retry counts, and then attempt to select a specific rate index based on whether it's MCS, VHT_MCS, or a standard bitrate. The interesting part is the handling of the case where a matching rate isn't located. It sets `info->control.rates[0].idx` to -1, which is fine, and then *unconditionally* clears the `IEEE80211_TX_CTRL_RATE_INJECT` flag.
My immediate concern is: we're leaving `info->control.rates[0].idx` at -1. My intuition tells me that having a rate index of -1 when `IEEE80211_TX_CTRL_RATE_INJECT` is unset is a problem. The rate injection logic seems designed to *only* take effect when that flag is set. The rate index should likely be considered undefined if the injection isn't active.
I recall a warning being triggered, and I suspect this might be the source. The code I'm thinking of is `mac80211_hwsim_write_tsf`, which calls `mac80211_hwsim_get_tx_rate`, and that calls `ieee80211_get_tx_rate`. `ieee80211_get_tx_rate` checks the `c->control.rates[0].idx` field, and I'm guessing that it's probably complaining if it's less than zero. I need to confirm this quickly.
Okay, confirming that `mac80211_hwsim_write_tsf` *does* call `mac80211_hwsim_get_tx_rate` unconditionally, it looks like it does. Now, I have to go back and figure out how `ieee80211_get_tx_rate` is supposed to be used. If the rate injection flag is *not* set, is the rate index valid? I need to review where this function is called, and what the assumptions around the `info->control.rates[0].idx` value are. I'm going to have to dive into the call stack of `ieee80211_get_tx_rate` to see where else it's used and what the invariants around the `idx` field are.
|
| 17/2 |
2026/09/04 14:14 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/net/wireless/virtual/mac80211_hwsim_main.c Name:mac80211_hwsim_get_tx_rate]
Results: map[SourceCode:1327: static struct ieee80211_rate *
1328: mac80211_hwsim_get_tx_rate(struct ieee80211_hw *hw,
1329: struct ieee80211_tx_info *info)
1330: {
1331: if (info->control.rates[0].flags &
1332: (IEEE80211_TX_RC_MCS | IEEE80211_TX_RC_VHT_MCS))
1333: return NULL;
1334:
1335: return ieee80211_get_tx_rate(hw, info);
1336: }
SourceFile:drivers/net/wireless/virtual/mac80211_hwsim_main.c]
|
| 18/2 |
2026/09/04 14:14 |
llm |
expert |
0m
Model:
Tokens:
input: 21149
output: 62
thoughts: 413
Thoughts: **Analyzing a Potential Bug in mac80211**
Okay, so I'm looking at this `ieee80211_get_tx_rate` function and I've noticed something potentially problematic. Specifically, if `info->control.rates[0].idx` is -1, it's going to trigger a `WARN_ON_ONCE`. My initial thought is, is this a bug in `mac80211_hwsim_get_tx_rate`? Shouldn't that function be checking if the rate is injected or at least validating that `info->control.rates[0].idx` is a valid positive value?
Then I went back and realized, hold on, `info->control.rates[0].idx` is initialized to 0 within `ieee80211_monitor_start_xmit`. However, `ieee80211_parse_tx_radiotap` is the culprit, because it's setting this index to -1 if it finds an invalid rate. If no rate is found, the value stays at zero. So, essentially, an invalid rate in a radiotap header is causing the -1 condition.
Now, the important question - is this exploitable? The warning is `WARN_ON_ONCE(c->control.rates[0].idx < 0)`, but what actually happens when that warning is triggered? Well, the function just returns `NULL`. The calling function, `mac80211_hwsim_write_tsf`, handles a `NULL` return by using a default bitrate of 100. So, it doesn't crash, it doesn't corrupt anything, and it doesn't leak any sensitive info.
Okay, so is there a possibility of denial of service? In a production environment, `WARN_ON_ONCE` just prints a warning message and keeps going. It doesn't trigger a panic unless `panic_on_warn` is enabled, which is not the default. That said, it doesn't seem to have any effect in terms of disrupting operation. So, it's nothing beyond a warning.
I think I'll need to double check other usages of this variable, though.
|
| 19/2 |
2026/09/04 14:14 |
tool |
codesearch-find-references |
0m
Args: map[ContextFile:include/net/mac80211.h IncludeSnippetLines:0 Name:ieee80211_tx_info::control SourceTreePrefix:]
Results: map[References:<nil> TruncatedOutput:false]
|
| 20/2 |
2026/09/04 14:14 |
llm |
expert |
0m
Model:
Tokens:
input: 22123
output: 26
thoughts: 12
Thoughts: Here's my attempt at summarizing the thought process, tailored for an expert audience:
**Analyzing Indexed Rate Data**
Okay, so I'm diving into this `rates` data structure, and the first thing that jumps out is the need to access the index of the initial rate. My instinct is to directly address the first element, `rates[0]`, and from there, pinpoint the desired index field, which seems to be labeled as `.idx`. This suggests the data is likely an array or list-like object, where the initial rate information resides at index zero. I want to quickly understand the structure, and pulling the index from the first rate is my starting point for navigating this data. I'm assuming that the index serves as a unique identifier or a key for a specific rate within the dataset.
|
| 21/2 |
2026/09/04 14:14 |
tool |
grepper |
0m
Args: map[Expression:rates\[0\]\.idx PathPrefix:]
Results: map[Output:drivers/net/wireless/ath/ath10k/htt_rx.c=3787=ath10k_update_per_peer_tx_stats(struct ath10k *ar,
--
drivers/net/wireless/ath/ath10k/htt_rx.c-3849- if (conf && conf->def.chan->band == NL80211_BAND_5GHZ)
drivers/net/wireless/ath/ath10k/htt_rx.c:3850: arsta->tx_info.status.rates[0].idx = rate_idx - 4;
drivers/net/wireless/ath/ath10k/htt_rx.c-3851- break;
drivers/net/wireless/ath/ath10k/htt_rx.c-3852- case WMI_RATE_PREAMBLE_CCK:
drivers/net/wireless/ath/ath10k/htt_rx.c:3853: arsta->tx_info.status.rates[0].idx = rate_idx;
drivers/net/wireless/ath/ath10k/htt_rx.c-3854- if (sgi)
--
drivers/net/wireless/ath/ath10k/htt_rx.c-3859- case WMI_RATE_PREAMBLE_HT:
drivers/net/wireless/ath/ath10k/htt_rx.c:3860: arsta->tx_info.status.rates[0].idx =
drivers/net/wireless/ath/ath10k/htt_rx.c-3861- txrate.mcs + ((txrate.nss - 1) * 8);
--
drivers/net/wireless/ath/ath10k/txrx.c=43=int ath10k_txrx_tx_unref(struct ath10k_htt *htt,
--
drivers/net/wireless/ath/ath10k/txrx.c-100- memset(&info->status, 0, sizeof(info->status));
drivers/net/wireless/ath/ath10k/txrx.c:101: info->status.rates[0].idx = -1;
drivers/net/wireless/ath/ath10k/txrx.c-102-
--
drivers/net/wireless/ath/ath11k/dp_tx.c=551=static void ath11k_dp_tx_complete_msdu(struct ath11k *ar,
--
drivers/net/wireless/ath/ath11k/dp_tx.c-586- /* skip tx rate update from ieee80211_status*/
drivers/net/wireless/ath/ath11k/dp_tx.c:587: info->status.rates[0].idx = -1;
drivers/net/wireless/ath/ath11k/dp_tx.c-588-
--
drivers/net/wireless/ath/ath11k/wmi.c=6014=static int wmi_process_mgmt_tx_comp(struct ath11k *ar,
--
drivers/net/wireless/ath/ath11k/wmi.c-6039- memset(&info->status, 0, sizeof(info->status));
drivers/net/wireless/ath/ath11k/wmi.c:6040: info->status.rates[0].idx = -1;
drivers/net/wireless/ath/ath11k/wmi.c-6041-
--
drivers/net/wireless/ath/ath12k/wifi7/dp_tx.c=737=static void ath12k_wifi7_dp_tx_complete_msdu(struct ath12k_pdev_dp *dp_pdev,
--
drivers/net/wireless/ath/ath12k/wifi7/dp_tx.c-797- /* skip tx rate update from ieee80211_status*/
drivers/net/wireless/ath/ath12k/wifi7/dp_tx.c:798: info->status.rates[0].idx = -1;
drivers/net/wireless/ath/ath12k/wifi7/dp_tx.c-799-
--
drivers/net/wireless/ath/ath12k/wmi.c=6436=static int wmi_process_mgmt_tx_comp(struct ath12k *ar, u32 desc_id,
--
drivers/net/wireless/ath/ath12k/wmi.c-6463- /* skip tx rate update from ieee80211_status*/
drivers/net/wireless/ath/ath12k/wmi.c:6464: info->status.rates[0].idx = -1;
drivers/net/wireless/ath/ath12k/wmi.c-6465-
--
drivers/net/wireless/ath/ath5k/base.c=730=static bool ath5k_merge_ratetbl(struct ieee80211_sta *sta,
--
drivers/net/wireless/ath/ath5k/base.c-743-
drivers/net/wireless/ath/ath5k/base.c:744: if (tx_info->control.rates[0].idx < 0 ||
drivers/net/wireless/ath/ath5k/base.c-745- tx_info->control.rates[0].count == 0)
--
drivers/net/wireless/ath/ath9k/beacon.c=112=static struct ath_buf *ath9k_beacon_generate(struct ieee80211_hw *hw,
--
drivers/net/wireless/ath/ath9k/beacon.c-186-
drivers/net/wireless/ath/ath9k/beacon.c:187: ath9k_beacon_setup(sc, vif, bf, info->control.rates[0].idx);
drivers/net/wireless/ath/ath9k/beacon.c-188-
--
drivers/net/wireless/ath/ath9k/link.c=201=static bool ath_paprd_send_frame(struct ath_softc *sc, struct sk_buff *skb, int chain)
--
drivers/net/wireless/ath/ath9k/link.c-215- tx_info->flags |= IEEE80211_TX_CTL_NO_ACK;
drivers/net/wireless/ath/ath9k/link.c:216: tx_info->control.rates[0].idx = 0;
drivers/net/wireless/ath/ath9k/link.c-217- tx_info->control.rates[0].count = 1;
--
drivers/net/wireless/ath/ath9k/xmit.c=162=static bool ath_merge_ratetbl(struct ieee80211_sta *sta, struct ath_buf *bf,
--
drivers/net/wireless/ath/ath9k/xmit.c-174-
drivers/net/wireless/ath/ath9k/xmit.c:175: if (tx_info->control.rates[0].idx < 0 ||
drivers/net/wireless/ath/ath9k/xmit.c-176- tx_info->control.rates[0].count == 0)
--
drivers/net/wireless/ath/ath9k/xmit.c=867=static int ath_compute_num_delims(struct ath_softc *sc, struct ath_atx_tid *tid,
--
drivers/net/wireless/ath/ath9k/xmit.c-911-
drivers/net/wireless/ath/ath9k/xmit.c:912: rix = bf->rates[0].idx;
drivers/net/wireless/ath/ath9k/xmit.c-913- flags = bf->rates[0].flags;
--
drivers/net/wireless/intel/iwlegacy/3945-rs.c=427=il3945_rs_tx_status(void *il_rate, struct ieee80211_supported_band *sband,
--
drivers/net/wireless/intel/iwlegacy/3945-rs.c-444-
drivers/net/wireless/intel/iwlegacy/3945-rs.c:445: first_idx = sband->bitrates[info->status.rates[0].idx].hw_value;
drivers/net/wireless/intel/iwlegacy/3945-rs.c-446- if (first_idx < 0 || first_idx >= RATE_COUNT_3945) {
--
drivers/net/wireless/intel/iwlegacy/3945-rs.c=600=il3945_rs_get_rate(void *il_r, struct ieee80211_sta *sta, void *il_sta,
--
drivers/net/wireless/intel/iwlegacy/3945-rs.c-786- rs_sta->last_txrate_idx = idx;
drivers/net/wireless/intel/iwlegacy/3945-rs.c:787: info->control.rates[0].idx = idx - IL_FIRST_OFDM_RATE;
drivers/net/wireless/intel/iwlegacy/3945-rs.c-788- } else {
drivers/net/wireless/intel/iwlegacy/3945-rs.c-789- rs_sta->last_txrate_idx = idx;
drivers/net/wireless/intel/iwlegacy/3945-rs.c:790: info->control.rates[0].idx = rs_sta->last_txrate_idx;
drivers/net/wireless/intel/iwlegacy/3945-rs.c-791- }
--
drivers/net/wireless/intel/iwlegacy/3945.c=298=il3945_hdl_tx(struct il_priv *il, struct il_rx_buf *rxb)
--
drivers/net/wireless/intel/iwlegacy/3945.c-341-
drivers/net/wireless/intel/iwlegacy/3945.c:342: info->status.rates[0].idx = rate_idx;
drivers/net/wireless/intel/iwlegacy/3945.c-343- info->status.rates[0].count = fail + 1; /* add final attempt */
--
drivers/net/wireless/intel/iwlegacy/4965-mac.c=1538=il4965_tx_cmd_build_rate(struct il_priv *il,
--
drivers/net/wireless/intel/iwlegacy/4965-mac.c-1572- */
drivers/net/wireless/intel/iwlegacy/4965-mac.c:1573: rate_idx = info->control.rates[0].idx;
drivers/net/wireless/intel/iwlegacy/4965-mac.c-1574- if ((info->control.rates[0].flags & IEEE80211_TX_RC_MCS) || rate_idx < 0
--
drivers/net/wireless/intel/iwlegacy/4965-rs.c=785=il4965_rs_tx_status(void *il_r, struct ieee80211_supported_band *sband,
--
drivers/net/wireless/intel/iwlegacy/4965-rs.c-835- mac_flags = info->status.rates[0].flags;
drivers/net/wireless/intel/iwlegacy/4965-rs.c:836: mac_idx = info->status.rates[0].idx;
drivers/net/wireless/intel/iwlegacy/4965-rs.c-837- /* For HT packets, map MCS to PLCP */
--
drivers/net/wireless/intel/iwlegacy/4965-rs.c=2176=il4965_rs_get_rate(void *il_r, struct ieee80211_sta *sta, void *il_sta,
--
drivers/net/wireless/intel/iwlegacy/4965-rs.c-2241- }
drivers/net/wireless/intel/iwlegacy/4965-rs.c:2242: info->control.rates[0].idx = rate_idx;
drivers/net/wireless/intel/iwlegacy/4965-rs.c-2243- info->control.rates[0].count = 1;
--
drivers/net/wireless/intel/iwlwifi/dvm/main.c=180=int iwlagn_send_beacon_cmd(struct iwl_priv *priv)
--
drivers/net/wireless/intel/iwlwifi/dvm/main.c-233- */
drivers/net/wireless/intel/iwlwifi/dvm/main.c:234: if (info->control.rates[0].idx < 0 ||
drivers/net/wireless/intel/iwlwifi/dvm/main.c-235- info->control.rates[0].flags & IEEE80211_TX_RC_MCS)
--
drivers/net/wireless/intel/iwlwifi/dvm/main.c-237- else
drivers/net/wireless/intel/iwlwifi/dvm/main.c:238: rate = info->control.rates[0].idx;
drivers/net/wireless/intel/iwlwifi/dvm/main.c-239-
--
drivers/net/wireless/intel/iwlwifi/dvm/rs.c=845=static void rs_tx_status(void *priv_r, struct ieee80211_supported_band *sband,
--
drivers/net/wireless/intel/iwlwifi/dvm/rs.c-898- mac_flags = info->status.rates[0].flags;
drivers/net/wireless/intel/iwlwifi/dvm/rs.c:899: mac_index = info->status.rates[0].idx;
drivers/net/wireless/intel/iwlwifi/dvm/rs.c-900- /* For HT packets, map MCS to PLCP */
--
drivers/net/wireless/intel/iwlwifi/dvm/rs.c=2660=static void rs_get_rate(void *priv_r, struct ieee80211_sta *sta, void *priv_sta,
--
drivers/net/wireless/intel/iwlwifi/dvm/rs.c-2719- }
drivers/net/wireless/intel/iwlwifi/dvm/rs.c:2720: info->control.rates[0].idx = rate_idx;
drivers/net/wireless/intel/iwlwifi/dvm/rs.c-2721- info->control.rates[0].count = 1;
--
drivers/net/wireless/intel/iwlwifi/dvm/tx.c=105=static void iwlagn_tx_cmd_build_rate(struct iwl_priv *priv,
--
drivers/net/wireless/intel/iwlwifi/dvm/tx.c-152- */
drivers/net/wireless/intel/iwlwifi/dvm/tx.c:153: rate_idx = info->control.rates[0].idx;
drivers/net/wireless/intel/iwlwifi/dvm/tx.c-154- if (info->control.rates[0].flags & IEEE80211_TX_RC_MCS ||
--
drivers/net/wireless/intel/iwlwifi/mvm/tx.c=294=static u32 iwl_mvm_get_inject_tx_rate(struct iwl_mvm *mvm,
--
drivers/net/wireless/intel/iwlwifi/mvm/tx.c-331- } else {
drivers/net/wireless/intel/iwlwifi/mvm/tx.c:332: int rate_idx = info->control.rates[0].idx;
drivers/net/wireless/intel/iwlwifi/mvm/tx.c-333-
--
drivers/net/wireless/intel/iwlwifi/mvm/tx.c=346=static u32 iwl_mvm_get_tx_rate(struct iwl_mvm *mvm,
--
drivers/net/wireless/intel/iwlwifi/mvm/tx.c-359- info->control.rates[0].flags,
drivers/net/wireless/intel/iwlwifi/mvm/tx.c:360: info->control.rates[0].idx,
drivers/net/wireless/intel/iwlwifi/mvm/tx.c-361- le16_to_cpu(fc),
--
drivers/net/wireless/intel/iwlwifi/mvm/tx.c-363-
drivers/net/wireless/intel/iwlwifi/mvm/tx.c:364: rate_idx = info->control.rates[0].idx;
drivers/net/wireless/intel/iwlwifi/mvm/tx.c-365-
--
drivers/net/wireless/marvell/mwl8k.c=1681=mwl8k_txq_reclaim(struct ieee80211_hw *hw, int index, int limit, int force)
--
drivers/net/wireless/marvell/mwl8k.c-1762- */
drivers/net/wireless/marvell/mwl8k.c:1763: info->status.rates[0].idx = -1;
drivers/net/wireless/marvell/mwl8k.c-1764- info->status.rates[0].count = 1;
--
drivers/net/wireless/mediatek/mt76/mt7603/mac.c=1248=mt7603_mac_add_txs_skb(struct mt7603_dev *dev, struct mt7603_sta *sta, int pid,
--
drivers/net/wireless/mediatek/mt76/mt7603/mac.c-1266- info->status.rates[0].count = 0;
drivers/net/wireless/mediatek/mt76/mt7603/mac.c:1267: info->status.rates[0].idx = -1;
drivers/net/wireless/mediatek/mt76/mt7603/mac.c-1268- }
--
drivers/net/wireless/mediatek/mt76/mt7615/mac.c=1437=static bool mt7615_mac_add_txs_skb(struct mt7615_dev *dev,
--
drivers/net/wireless/mediatek/mt76/mt7615/mac.c-1456- info->status.rates[0].count = 0;
drivers/net/wireless/mediatek/mt76/mt7615/mac.c:1457: info->status.rates[0].idx = -1;
drivers/net/wireless/mediatek/mt76/mt7615/mac.c-1458- }
--
drivers/net/wireless/mediatek/mt76/mt76_connac_mac.c=749=bool mt76_connac2_mac_add_txs_skb(struct mt76_dev *dev, struct mt76_wcid *wcid,
--
drivers/net/wireless/mediatek/mt76/mt76_connac_mac.c-768- !!(info->flags & IEEE80211_TX_STAT_ACK);
drivers/net/wireless/mediatek/mt76/mt76_connac_mac.c:769: info->status.rates[0].idx = -1;
drivers/net/wireless/mediatek/mt76/mt76_connac_mac.c-770-
--
drivers/net/wireless/mediatek/mt76/mt76x02_mac.c=440=mt76x02_tx_rate_fallback(struct ieee80211_tx_rate *rates, int idx, int phy)
--
drivers/net/wireless/mediatek/mt76/mt76x02_mac.c-463- /* MCS 8 falls back to MCS 0 */
drivers/net/wireless/mediatek/mt76/mt76x02_mac.c:464: if (rates[0].idx == 8) {
drivers/net/wireless/mediatek/mt76/mt76x02_mac.c-465- rates[1].idx = 0;
--
drivers/net/wireless/mediatek/mt76/mt76x02_mac.c-469- default:
drivers/net/wireless/mediatek/mt76/mt76x02_mac.c:470: rates[1].idx = max_t(int, rates[0].idx - 1, 0);
drivers/net/wireless/mediatek/mt76/mt76x02_mac.c-471- break;
--
drivers/net/wireless/mediatek/mt76/mt7925/mac.c=924=mt7925_mac_add_txs_skb(struct mt792x_dev *dev, struct mt76_wcid *wcid,
--
drivers/net/wireless/mediatek/mt76/mt7925/mac.c-951-
drivers/net/wireless/mediatek/mt76/mt7925/mac.c:952: info->status.rates[0].idx = -1;
drivers/net/wireless/mediatek/mt76/mt7925/mac.c-953-
--
drivers/net/wireless/mediatek/mt76/mt7925/mac.c=1061=mt7928_mac_add_txs_skb_msg(struct mt792x_dev *dev, struct mt76_wcid *wcid,
--
drivers/net/wireless/mediatek/mt76/mt7925/mac.c-1087-
drivers/net/wireless/mediatek/mt76/mt7925/mac.c:1088: info->status.rates[0].idx = -1;
drivers/net/wireless/mediatek/mt76/mt7925/mac.c-1089-
--
drivers/net/wireless/mediatek/mt76/mt7996/mac.c=1472=mt7996_mac_add_txs_skb(struct mt7996_dev *dev, struct mt76_wcid *wcid,
--
drivers/net/wireless/mediatek/mt76/mt7996/mac.c-1501-
drivers/net/wireless/mediatek/mt76/mt7996/mac.c:1502: info->status.rates[0].idx = -1;
drivers/net/wireless/mediatek/mt76/mt7996/mac.c-1503- }
--
drivers/net/wireless/mediatek/mt76/tx.c=89=__mt76_tx_status_skb_done(struct mt76_dev *dev, struct sk_buff *skb, u8 flags,
--
drivers/net/wireless/mediatek/mt76/tx.c-105- info->status.rates[0].count = 0;
drivers/net/wireless/mediatek/mt76/tx.c:106: info->status.rates[0].idx = -1;
drivers/net/wireless/mediatek/mt76/tx.c-107- info->flags |= IEEE80211_TX_STAT_ACK;
--
drivers/net/wireless/mediatek/mt7601u/tx.c=102=void mt7601u_tx_status(struct mt7601u_dev *dev, struct sk_buff *skb)
--
drivers/net/wireless/mediatek/mt7601u/tx.c-108- ieee80211_tx_info_clear_status(info);
drivers/net/wireless/mediatek/mt7601u/tx.c:109: info->status.rates[0].idx = -1;
drivers/net/wireless/mediatek/mt7601u/tx.c-110- info->flags |= IEEE80211_TX_STAT_ACK;
--
drivers/net/wireless/morsemicro/mm81x/rc.c=191=static void mm81x_rc_sta_fill_basic_rates(struct mm81x_skb_tx_info *tx_info,
--
drivers/net/wireless/morsemicro/mm81x/rc.c-210-
drivers/net/wireless/morsemicro/mm81x/rc.c:211: info->control.rates[0].idx = 0;
drivers/net/wireless/morsemicro/mm81x/rc.c-212- info->control.rates[0].count = tx_info->rates[0].count;
--
drivers/net/wireless/ralink/rt2x00/rt2x00queue.c=599=int rt2x00queue_write_tx_frame(struct data_queue *queue, struct sk_buff *skb,
--
drivers/net/wireless/ralink/rt2x00/rt2x00queue.c-621- tx_info = IEEE80211_SKB_CB(skb);
drivers/net/wireless/ralink/rt2x00/rt2x00queue.c:622: rate_idx = tx_info->control.rates[0].idx;
drivers/net/wireless/ralink/rt2x00/rt2x00queue.c-623- rate_flags = tx_info->control.rates[0].flags;
--
drivers/net/wireless/realtek/rtl8xxxu/core.c=5149=static void rtl8xxxu_tx_complete(struct urb *urb)
--
drivers/net/wireless/realtek/rtl8xxxu/core.c-5164- ieee80211_tx_info_clear_status(tx_info);
drivers/net/wireless/realtek/rtl8xxxu/core.c:5165: tx_info->status.rates[0].idx = -1;
drivers/net/wireless/realtek/rtl8xxxu/core.c-5166- tx_info->status.rates[0].count = 0;
--
drivers/net/wireless/realtek/rtlwifi/base.c=1228=void rtl_get_tcb_desc(struct ieee80211_hw *hw,
--
drivers/net/wireless/realtek/rtlwifi/base.c-1264- */
drivers/net/wireless/realtek/rtlwifi/base.c:1265: if (info->control.rates[0].idx == 0 ||
drivers/net/wireless/realtek/rtlwifi/base.c-1266- ieee80211_is_nullfunc(fc)) {
--
drivers/net/wireless/realtek/rtlwifi/base.c=2434=int rtl_send_smps_action(struct ieee80211_hw *hw,
--
drivers/net/wireless/realtek/rtlwifi/base.c-2472-
drivers/net/wireless/realtek/rtlwifi/base.c:2473: info->control.rates[0].idx = 0;
drivers/net/wireless/realtek/rtlwifi/base.c-2474- info->band = hw->conf.chandef.chan->band;
--
drivers/net/wireless/realtek/rtw89/core.c=1226=static void rtw89_core_tx_update_injection(struct rtw89_dev *rtwdev,
--
drivers/net/wireless/realtek/rtw89/core.c-1233- const struct rtw89_chan *chan;
drivers/net/wireless/realtek/rtw89/core.c:1234: u8 idx = info->control.rates[0].idx;
drivers/net/wireless/realtek/rtw89/core.c-1235- u8 nss, mcs;
--
drivers/net/wireless/silabs/wfx/data_tx.c=46=static void wfx_tx_policy_build(struct wfx_vif *wvif, struct wfx_tx_policy *policy,
--
drivers/net/wireless/silabs/wfx/data_tx.c-52-
drivers/net/wireless/silabs/wfx/data_tx.c:53: WARN(rates[0].idx < 0, "invalid rate policy");
drivers/net/wireless/silabs/wfx/data_tx.c-54- memset(policy, 0, sizeof(*policy));
--
drivers/net/wireless/st/cw1200/txrx.c=65=static void tx_policy_build(const struct cw1200_common *priv,
--
drivers/net/wireless/st/cw1200/txrx.c-71- unsigned total = 0;
drivers/net/wireless/st/cw1200/txrx.c:72: BUG_ON(rates[0].idx < 0);
drivers/net/wireless/st/cw1200/txrx.c-73- memset(policy, 0, sizeof(*policy));
--
drivers/net/wireless/st/cw1200/txrx.c-124- if (count == 2 && !(rates[0].flags & IEEE80211_TX_RC_MCS) &&
drivers/net/wireless/st/cw1200/txrx.c:125: rates[0].idx > 4 && rates[0].count > 2 &&
drivers/net/wireless/st/cw1200/txrx.c-126- rates[1].idx < 2) {
drivers/net/wireless/st/cw1200/txrx.c:127: int mid_rate = (rates[0].idx + 4) >> 1;
drivers/net/wireless/st/cw1200/txrx.c-128-
--
drivers/net/wireless/st/cw1200/txrx.c-189- count,
drivers/net/wireless/st/cw1200/txrx.c:190: rates[0].idx, rates[0].count,
drivers/net/wireless/st/cw1200/txrx.c-191- rates[1].idx, rates[1].count,
--
drivers/net/wireless/ti/wlcore/ps.c=77=static void wl1271_ps_filter_frames(struct wl1271 *wl, u8 hlid)
--
drivers/net/wireless/ti/wlcore/ps.c-96- info->flags |= IEEE80211_TX_STAT_TX_FILTERED;
drivers/net/wireless/ti/wlcore/ps.c:97: info->status.rates[0].idx = -1;
drivers/net/wireless/ti/wlcore/ps.c-98- ieee80211_tx_status_ni(wl->hw, skb);
--
drivers/net/wireless/ti/wlcore/tx.c=897=static void wl1271_tx_complete_packet(struct wl1271 *wl,
--
drivers/net/wireless/ti/wlcore/tx.c-939-
drivers/net/wireless/ti/wlcore/tx.c:940: info->status.rates[0].idx = rate;
drivers/net/wireless/ti/wlcore/tx.c-941- info->status.rates[0].count = retries;
--
drivers/net/wireless/ti/wlcore/tx.c=1018=void wl1271_tx_reset_link_queues(struct wl1271 *wl, u8 hlid)
--
drivers/net/wireless/ti/wlcore/tx.c-1033- info = IEEE80211_SKB_CB(skb);
drivers/net/wireless/ti/wlcore/tx.c:1034: info->status.rates[0].idx = -1;
drivers/net/wireless/ti/wlcore/tx.c-1035- info->status.rates[0].count = 0;
--
drivers/net/wireless/ti/wlcore/tx.c=1076=void wl12xx_tx_reset(struct wl1271 *wl)
--
drivers/net/wireless/ti/wlcore/tx.c-1122-
drivers/net/wireless/ti/wlcore/tx.c:1123: info->status.rates[0].idx = -1;
drivers/net/wireless/ti/wlcore/tx.c-1124- info->status.rates[0].count = 0;
--
drivers/net/wireless/virtual/mac80211_hwsim_main.c=1902=static bool mac80211_hwsim_tx_frame_no_nl(struct ieee80211_hw *hw,
--
drivers/net/wireless/virtual/mac80211_hwsim_main.c-1928- } else {
drivers/net/wireless/virtual/mac80211_hwsim_main.c:1929: rx_status.rate_idx = info->control.rates[0].idx;
drivers/net/wireless/virtual/mac80211_hwsim_main.c-1930- if (info->control.rates[0].flags & IEEE80211_TX_RC_MCS)
--
drivers/net/wireless/zydas/zd1211rw/zd_mac.c=430=static void zd_mac_tx_status(struct ieee80211_hw *hw, struct sk_buff *skb,
--
drivers/net/wireless/zydas/zd1211rw/zd_mac.c-453-
drivers/net/wireless/zydas/zd1211rw/zd_mac.c:454: first_idx = info->status.rates[0].idx;
drivers/net/wireless/zydas/zd1211rw/zd_mac.c-455- ZD_ASSERT(0<=first_idx && first_idx<ARRAY_SIZE(zd_retry_rates));
--
drivers/net/wireless/zydas/zd1211rw/zd_mac.c-458-
drivers/net/wireless/zydas/zd1211rw/zd_mac.c:459: info->status.rates[0].idx = retries->rate[0];
drivers/net/wireless/zydas/zd1211rw/zd_mac.c-460- info->status.rates[0].count = 1; // (retry > 1 ? 2 : 1);
--
drivers/net/wireless/zydas/zd1211rw/zd_mac.c=485=void zd_mac_tx_failed(struct urb *urb)
--
drivers/net/wireless/zydas/zd1211rw/zd_mac.c-525- info = IEEE80211_SKB_CB(skb);
drivers/net/wireless/zydas/zd1211rw/zd_mac.c:526: first_idx = info->status.rates[0].idx;
drivers/net/wireless/zydas/zd1211rw/zd_mac.c-527- ZD_ASSERT(0<=first_idx && first_idx<ARRAY_SIZE(zd_retry_rates));
--
include/net/mac80211.h=3410=ieee80211_get_tx_rate(const struct ieee80211_hw *hw,
--
include/net/mac80211.h-3412-{
include/net/mac80211.h:3413: if (WARN_ON_ONCE(c->control.rates[0].idx < 0))
include/net/mac80211.h-3414- return NULL;
--
include/net/mac80211.h-3418-
include/net/mac80211.h:3419: return &hw->wiphy->bands[c->band]->bitrates[c->control.rates[0].idx];
include/net/mac80211.h-3420-}
--
net/mac80211/rate.c=366=static void __rate_control_send_low(struct ieee80211_hw *hw,
--
net/mac80211/rate.c-376- info->control.rates[0].flags |= IEEE80211_TX_RC_S1G_MCS;
net/mac80211/rate.c:377: info->control.rates[0].idx = 0;
net/mac80211/rate.c-378- return;
--
net/mac80211/rate.c-384-
net/mac80211/rate.c:385: info->control.rates[0].idx = 0;
net/mac80211/rate.c-386- for (i = 0; i < sband->n_bitrates; i++) {
--
net/mac80211/rate.c-395-
net/mac80211/rate.c:396: info->control.rates[0].idx = i;
net/mac80211/rate.c-397- break;
--
net/mac80211/rate.c=414=static bool rate_control_send_low(struct ieee80211_sta *pubsta,
--
net/mac80211/rate.c-432- if (mcast_rate > 0) {
net/mac80211/rate.c:433: info->control.rates[0].idx = mcast_rate - 1;
net/mac80211/rate.c-434- return true;
--
net/mac80211/rate.c=631=static void rate_fixup_ratelist(struct ieee80211_vif *vif,
--
net/mac80211/rate.c-653-
net/mac80211/rate.c:654: rate = &sband->bitrates[rates[0].idx];
net/mac80211/rate.c-655-
--
net/mac80211/status.c=209=static int ieee80211_tx_radiotap_len(struct ieee80211_tx_info *info,
--
net/mac80211/status.c-225- len += 2;
net/mac80211/status.c:226: else if (info->status.rates[0].idx >= 0 &&
net/mac80211/status.c-227- !(info->status.rates[0].flags &
--
net/mac80211/status.c-245- len = ALIGN(len, 2) + 12;
net/mac80211/status.c:246: } else if (info->status.rates[0].idx >= 0) {
net/mac80211/status.c-247- if (info->status.rates[0].flags & IEEE80211_TX_RC_MCS)
--
net/mac80211/status.c=257=ieee80211_add_tx_radiotap_header(struct ieee80211_local *local,
--
net/mac80211/status.c-298- } else if (info->band < NUM_NL80211_BANDS &&
net/mac80211/status.c:299: info->status.rates[0].idx >= 0 &&
net/mac80211/status.c-300- !(info->status.rates[0].flags & (IEEE80211_TX_RC_MCS |
--
net/mac80211/status.c-305- legacy_rate =
net/mac80211/status.c:306: sband->bitrates[info->status.rates[0].idx].bitrate;
net/mac80211/status.c-307- }
--
net/mac80211/status.c-470-
net/mac80211/status.c:471: if (status_rate || info->status.rates[0].idx < 0)
net/mac80211/status.c-472- return;
--
net/mac80211/status.c-486- pos[1] |= IEEE80211_RADIOTAP_MCS_FMT_GF;
net/mac80211/status.c:487: pos[2] = info->status.rates[0].idx;
net/mac80211/status.c-488- pos += 3;
--
net/mac80211/tx.c=675=ieee80211_tx_h_rate_ctrl(struct ieee80211_tx_data *tx)
--
net/mac80211/tx.c-768-
net/mac80211/tx.c:769: if (unlikely(info->control.rates[0].idx < 0)) {
net/mac80211/tx.c-770- if (ratetbl) {
--
net/mac80211/tx.c=2106=bool ieee80211_parse_tx_radiotap(struct sk_buff *skb,
--
net/mac80211/tx.c-2294-
net/mac80211/tx.c:2295: info->control.rates[0].idx = rate;
net/mac80211/tx.c-2296- } else if (rate_flags & IEEE80211_TX_RC_VHT_MCS) {
--
net/mac80211/tx.c-2307-
net/mac80211/tx.c:2308: info->control.rates[0].idx = i;
net/mac80211/tx.c-2309- break;
--
net/mac80211/tx.c-2312-
net/mac80211/tx.c:2313: if (info->control.rates[0].idx < 0)
net/mac80211/tx.c-2314- info->control.flags &= ~IEEE80211_TX_CTRL_RATE_INJECT;
]
|
| 22/2 |
2026/09/04 14:14 |
llm |
expert |
0m
Model:
Tokens:
input: 33389
output: 52
thoughts: 1264
Thoughts: **Vulnerability Analysis: Triggering a NULL Pointer Dereference**
Okay, so it looks like `ieee80211_tx_h_rate_ctrl` expects `info->control.rates[0].idx` to *sometimes* be negative. Specifically, it's designed to handle cases where this index is less than zero. However, `ieee80211_get_tx_rate` has a `WARN_ON_ONCE` that fires if `c->control.rates[0].idx < 0`. That means, in principle, you *shouldn't* call the getter if the rate index is invalid.
The problem lies in `mac80211_hwsim_get_tx_rate`, which calls `ieee80211_get_tx_rate` without checking. This seems like a potential issue. If `info->control.rates[0].idx` is negative, does this indicate an invalid rate? It seems so, because in `ieee80211_parse_tx_radiotap`, a rate index of `-1` is assigned when no valid rate is found. Even if it's a legacy rate, if it isn't found in `sband->bitrates`, the index remains `-1`. Then, `mac80211_hwsim_write_tsf` calls `mac80211_hwsim_get_tx_rate`, which in turn calls `ieee80211_get_tx_rate`, triggering the warning.
So, the question is, what happens if this rate index is invalid? `ieee80211_get_tx_rate` returns `NULL`. `mac80211_hwsim_write_tsf` *handles* the `NULL` by defaulting to a bitrate of `100`. So, the system *doesn't* immediately crash. However, this could still lead to problems downstream in calculations that rely on this "default" rate.
This all happens in a simulation driver, `mac80211_hwsim`. Can an unprivileged user trigger this?
The call trace shows this is being triggered from a raw packet send via an `AF_PACKET` socket. Creating an `AF_PACKET` socket requires `CAP_NET_RAW`. To exploit this from a user namespace, you'd need the ability to create both a user namespace and a network namespace with `CAP_NET_RAW` enabled.
An unprivileged user *could* create a user namespace and subsequently a network namespace, and potentially be granted `CAP_NET_RAW`, if user namespaces are enabled. The next hurdle is the monitor interface. To send packets, the user would need to send them to a monitor interface. Creating a `mac80211` monitor interface usually requires `CAP_NET_ADMIN` in the initial network namespace, because wireless devices usually reside in the initial network namespace.
However, since we are dealing with `mac80211_hwsim`, virtual wireless interfaces are possible. An unprivileged user could potentially exploit this if the system has a monitor interface *already* up and running and the user can send packets to it. The `AF_PACKET` socket *can* be bound to *any* interface in a network namespace. Therefore the user needs `CAP_NET_RAW` in the namespace where the monitor interface is.
However, the prompt specifies the user has all capabilities within their namespace, so this could be an exploitable path, so long as the user can create a `mac80211_hwsim` device. This is where I have a question. Since we're dealing with a kernel module, creating devices usually involves Netlink messages to the `mac80211_hwsim` generic Netlink family. This might be restricted to the init netns, but, *can* a user with `CAP_NET_ADMIN` within a user namespace create a `mac80211_hwsim` device? This is the key question.
|
| 23/2 |
2026/09/04 14:14 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/net/wireless/virtual/mac80211_hwsim_main.c Name:hwsim_genl_family]
Results: map[SourceCode:7147: static struct genl_family hwsim_genl_family __ro_after_init = {
7148: .name = "MAC80211_HWSIM",
7149: .version = 1,
7150: .maxattr = HWSIM_ATTR_MAX,
7151: .policy = hwsim_genl_policy,
7152: .netnsok = true,
7153: .module = THIS_MODULE,
7154: .small_ops = hwsim_ops,
7155: .n_small_ops = ARRAY_SIZE(hwsim_ops),
7156: .resv_start_op = HWSIM_CMD_REPORT_PMSR + 1, // match with __HWSIM_CMD_MAX
7157: .mcgrps = hwsim_mcgrps,
7158: .n_mcgrps = ARRAY_SIZE(hwsim_mcgrps),
7159: };
SourceFile:drivers/net/wireless/virtual/mac80211_hwsim_main.c]
|
| 24/2 |
2026/09/04 14:14 |
llm |
expert |
0m
Model:
Tokens:
input: 35889
output: 49
thoughts: 20
Thoughts: Okay, here's my interpretation of those thoughts, tailored for an expert audience, presented in the first person:
**Kernel Module Investigation: Namespace & Hardware Simulation**
Alright, the initial check is promising. `.netnsok` is set to `true` - excellent, that means we're in a network namespace context. This is what I was hoping for. Now, let's dive deeper. My primary interest now lies in the `hwsim_ops` structure. This likely contains the function pointers related to the simulated hardware interaction. I need to understand exactly what these operations are, how they’re implemented, and any potential points of contention or unexpected behavior. Time to go deeper.
|
| 25/2 |
2026/09/04 14:14 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/net/wireless/virtual/mac80211_hwsim_main.c Name:hwsim_ops]
Results: map[SourceCode:7104: /* Generic Netlink operations array */
7105: static const struct genl_small_ops hwsim_ops[] = {
7106: {
7107: .cmd = HWSIM_CMD_REGISTER,
7108: .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
7109: .doit = hwsim_register_received_nl,
7110: .flags = GENL_UNS_ADMIN_PERM,
7111: },
7112: {
7113: .cmd = HWSIM_CMD_FRAME,
7114: .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
7115: .doit = hwsim_cloned_frame_received_nl,
7116: },
7117: {
7118: .cmd = HWSIM_CMD_TX_INFO_FRAME,
7119: .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
7120: .doit = hwsim_tx_info_frame_received_nl,
7121: },
7122: {
7123: .cmd = HWSIM_CMD_NEW_RADIO,
7124: .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
7125: .doit = hwsim_new_radio_nl,
7126: .flags = GENL_UNS_ADMIN_PERM,
7127: },
7128: {
7129: .cmd = HWSIM_CMD_DEL_RADIO,
7130: .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
7131: .doit = hwsim_del_radio_nl,
7132: .flags = GENL_UNS_ADMIN_PERM,
7133: },
7134: {
7135: .cmd = HWSIM_CMD_GET_RADIO,
7136: .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
7137: .doit = hwsim_get_radio_nl,
7138: .dumpit = hwsim_dump_radio_nl,
7139: },
7140: {
7141: .cmd = HWSIM_CMD_REPORT_PMSR,
7142: .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
7143: .doit = hwsim_pmsr_report_nl,
7144: },
7145: };
SourceFile:drivers/net/wireless/virtual/mac80211_hwsim_main.c]
|
| 26/2 |
2026/09/04 14:14 |
llm |
expert |
0m
Model:
Tokens:
input: 36898
output: 49
thoughts: 235
Thoughts: **Analyzing the User Namespace Security Implications**
Okay, so `HWSIM_CMD_NEW_RADIO` is set up with `.flags = GENL_UNS_ADMIN_PERM`. This means, and this is important, that you need `CAP_NET_ADMIN` in the user namespace to actually create a new radio. Alright, so a user with those permissions in their user namespace can do this. The next logical step is they can create a monitor interface and start sending packets to it. So, essentially, this feature *is* accessible from user namespaces, which makes it a potential point of interest from a security perspective.
Now, the obvious question – is it exploitable? Let's break this down. That `WARN_ON_ONCE` we saw is just a warning, it's not a kernel panic. Does it cause any memory corruption? No, I don't see any obvious issues there. Information leak? No, that doesn't seem likely either. Denial of service? Not really. In production builds, that `WARN_ON_ONCE` just logs something and moves on, so it’s not blocking anything. I guess that means the warning itself doesn't cause a denial of service, but what's really important is the underlying code. The underlying issue is that `c->control.rates[0].idx < 0`, might it be used somewhere else in a way that could cause an out-of-bounds access? Better go back and check `ieee80211_get_tx_rate` again to be absolutely sure.
|
| 27/2 |
2026/09/04 14:14 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:include/net/mac80211.h Name:ieee80211_get_tx_rate]
Results: map[SourceCode:3409: static inline struct ieee80211_rate *
3410: ieee80211_get_tx_rate(const struct ieee80211_hw *hw,
3411: const struct ieee80211_tx_info *c)
3412: {
3413: if (WARN_ON_ONCE(c->control.rates[0].idx < 0))
3414: return NULL;
3415:
3416: if (c->band >= NUM_NL80211_BANDS)
3417: return NULL;
3418:
3419: return &hw->wiphy->bands[c->band]->bitrates[c->control.rates[0].idx];
3420: }
SourceFile:include/net/mac80211.h]
|
| 28/2 |
2026/09/04 14:14 |
llm |
expert |
0m
Model:
Tokens:
input: 37767
output: 46
thoughts: 216
Thoughts: **Analyzing Potential Out-of-Bounds Access**
Okay, so I see this check: `if (c->control.rates[0].idx < 0) return NULL;`. That's good, it *seems* to prevent an out-of-bounds read. But my gut tells me to dig deeper. What if that negative `idx` gets used somewhere else *without* a check? That's the real vulnerability.
I remember seeing something similar earlier, in `ieee80211_tx_h_rate_ctrl`. There's a check in that function, so that's a point in our favor:
```c
if (unlikely(info->control.rates[0].idx < 0)) {
if (ratetbl) {
/* ... */
} else {
/* ... */
}
}
```
Okay, so the `ieee80211_tx_h_rate_ctrl` function at least has a check, but what about other drivers? Let me see what else is going on. Let's see... a quick `grep` confirms there are other instances of `info->control.rates[0].idx`. Hmmm, I see this:
```
drivers/net/wireless/ath/ath9k/beacon.c:187: ath9k_beacon_setup(sc, vif, bf, info->control.rates[0].idx);
```
That's interesting. `ath9k_beacon_setup` now needs to be looked at! That's the next step, I'll check that function and see if it also checks for the boundary.
|
| 29/2 |
2026/09/04 14:14 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/net/wireless/ath/ath9k/beacon.c Name:ath9k_beacon_setup]
Results: map[SourceCode: 67: /*
68: * Associates the beacon frame buffer with a transmit descriptor. Will set
69: * up rate codes, and channel flags. Beacons are always sent out at the
70: * lowest rate, and are not retried.
71: */
72: static void ath9k_beacon_setup(struct ath_softc *sc, struct ieee80211_vif *vif,
73: struct ath_buf *bf, int rateidx)
74: {
75: struct sk_buff *skb = bf->bf_mpdu;
76: struct ath_hw *ah = sc->sc_ah;
77: struct ath_common *common = ath9k_hw_common(ah);
78: struct ath_tx_info info;
79: struct ieee80211_supported_band *sband;
80: u8 chainmask = ah->txchainmask;
81: u8 i, rate = 0;
82:
83: sband = &common->sbands[sc->cur_chandef.chan->band];
84: rate = sband->bitrates[rateidx].hw_value;
85: if (vif->bss_conf.use_short_preamble)
86: rate |= sband->bitrates[rateidx].hw_value_short;
87:
88: memset(&info, 0, sizeof(info));
89: info.pkt_len = skb->len + FCS_LEN;
90: info.type = ATH9K_PKT_TYPE_BEACON;
91: for (i = 0; i < 4; i++)
92: info.txpower[i] = MAX_RATE_POWER;
93: info.keyix = ATH9K_TXKEYIX_INVALID;
94: info.keytype = ATH9K_KEY_TYPE_CLEAR;
95: info.flags = ATH9K_TXDESC_NOACK | ATH9K_TXDESC_CLRDMASK;
96:
97: info.buf_addr[0] = bf->bf_buf_addr;
98: info.buf_len[0] = roundup(skb->len, 4);
99:
100: info.is_first = true;
101: info.is_last = true;
102:
103: info.qcu = sc->beacon.beaconq;
104:
105: info.rates[0].Tries = 1;
106: info.rates[0].Rate = rate;
107: info.rates[0].ChSel = ath_txchainmask_reduction(sc, chainmask, rate);
108:
109: ath9k_hw_set_txdesc(ah, bf->bf_desc, &info);
110: }
SourceFile:drivers/net/wireless/ath/ath9k/beacon.c]
|
| 30/2 |
2026/09/04 14:14 |
llm |
expert |
0m
Model:
Tokens:
input: 39216
output: 43
thoughts: 156
Thoughts: **My Analysis of a Potential Out-of-Bounds Read in ath9k**
Okay, so I'm looking at this `ath9k_beacon_setup` function, and it seems like there's a potential vulnerability here. Specifically, the code uses `rateidx` as an index into `sband->bitrates[rateidx]`. My immediate concern is that if `rateidx` happens to be `-1`, that's an out-of-bounds read, plain and simple. We're asking to access a memory location that doesn't exist within the defined array. That's a classic error that could lead to crashes, or worse, exploitation.
But I need to understand the context. Where is `ath9k_beacon_setup` called from? Ah, it's called from `ath9k_beacon_generate`. That’s good, that narrows the scope of the risk. Wait a second, the beacon generation path shouldn’t be directly related to arbitrary frame injection. Beacons are a specific type of frame, and the code path that generates beacons wouldn't be directly accessible to maliciously crafted injected frames. I’m thinking injected frames use a different mechanism.
Let's trace that. Injected frames go through `ieee80211_monitor_start_xmit`, then `ieee80211_xmit`, and finally `drv_tx`. For the `ath9k` driver, `drv_tx` resolves to `ath_tx`. This makes sense. Any potential issue related to the `-1` `rateidx` vulnerability is highly unlikely to come through here.
I need to confirm this, but right now I'm leaning toward the belief that the -1 rateidx is not a security vulnerability.
|
| 31/2 |
2026/09/04 14:14 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/net/wireless/ath/ath9k/xmit.c Name:ath_tx]
Results: map[SourceCode: 282: /**
283: * @txq_map: Index is mac80211 queue number. This is
284: * not necessarily the same as the hardware queue number
285: * (axq_qnum).
286: */
287: struct ath_tx {
288: u32 txqsetup;
289: spinlock_t txbuflock;
290: struct list_head txbuf;
291: struct ath_txq txq[ATH9K_NUM_TX_QUEUES];
292: struct ath_descdma txdma;
293: struct ath_txq *txq_map[IEEE80211_NUM_ACS];
294: struct ath_txq *uapsdq;
295: u16 max_aggr_framelen[IEEE80211_NUM_ACS][4][32];
296: };
SourceFile:drivers/net/wireless/ath/ath9k/ath9k.h]
|
| 32/2 |
2026/09/04 14:14 |
llm |
expert |
0m
Model:
Tokens:
input: 40096
output: 35
thoughts: 40
Thoughts: Here's my thought process, as if I were working through this:
**Digging into the Atheros TX Structure**
Okay, so I'm looking at `ath_tx`. Right, that's a struct. That means the actual transmit function I'm after is probably going to be named something along the lines of `ath_tx_tx` or similar. Given the context of Atheros hardware, it's reasonable. Now, let's just make sure, a quick check of `drv_tx` within the `ath9k` driver code should confirm or redirect me. Let's see what that reveals.
|
| 33/2 |
2026/09/04 14:14 |
tool |
grepper |
0m
Args: map[Expression:\.tx = PathPrefix:drivers/net/wireless/ath/ath9k/]
Results: map[Output:drivers/net/wireless/ath/ath9k/htc_drv_init.c=120=static inline int ath9k_htc_connect_svc(struct ath9k_htc_priv *priv,
--
drivers/net/wireless/ath/ath9k/htc_drv_init.c-134- req.ep_callbacks.rx = ath9k_htc_rxep;
drivers/net/wireless/ath/ath9k/htc_drv_init.c:135: req.ep_callbacks.tx = tx;
drivers/net/wireless/ath/ath9k/htc_drv_init.c-136-
--
drivers/net/wireless/ath/ath9k/wmi.c=262=int ath9k_wmi_connect(struct htc_target *htc, struct wmi *wmi,
--
drivers/net/wireless/ath/ath9k/wmi.c-272- connect.ep_callbacks.priv = wmi;
drivers/net/wireless/ath/ath9k/wmi.c:273: connect.ep_callbacks.tx = ath9k_wmi_ctrl_tx;
drivers/net/wireless/ath/ath9k/wmi.c-274- connect.ep_callbacks.rx = ath9k_wmi_ctrl_rx;
]
|
| 34/2 |
2026/09/04 14:14 |
llm |
expert |
0m
Model:
Tokens:
input: 40649
output: 43
thoughts: 20
Thoughts: Here's a summary of my thought process, as if I were the one thinking it:
**Diving into the ath9k mac80211 Operations**
Okay, time to get to the core of the matter. I need to take a look at how `ath9k` interacts with the `mac80211` framework. Specifically, I need to see how the driver implements the `mac80211_ops` structure. This is the crucial bridge, the interface that dictates how `ath9k` handles things like packet transmission, reception, channel management, and all the essential wireless operations, from the perspective of the broader networking stack. I need to understand this connection thoroughly; that’s where the power lies. I have to see how it manages to make that chipset sing.
|
| 35/2 |
2026/09/04 14:14 |
tool |
grepper |
0m
Error:
Args: map[Expression:\.tx = PathPrefix:drivers/net/wireless/ath/ath9k/mac80211.c]
Results:
|
| 36/2 |
2026/09/04 14:14 |
llm |
expert |
0m
Model:
Tokens:
input: 40897
output: 38
thoughts: 20
Thoughts: Okay, here's my interpretation of that thought process, assuming I'm already deep in the weeds of kernel networking:
**Digging into the Atheros Wireless Driver**
Right, let me see... I'm thinking about the Atheros wireless drivers, specifically the ath9k one. Where should I start looking to understand its initialization sequence? The `drivers/net/wireless/ath/ath9k/init.c` file immediately comes to mind. That's usually the place to find the driver's entry points, the `module_init` calls, and generally how everything gets bootstrapped when the module loads. I'll bet a lot of crucial hardware setup happens right there. Understanding the initialization process is key to debugging any issues, or maybe even modifying some of the core behavior. Yep, seems like the logical first step to understanding what's going on here.
|
| 37/2 |
2026/09/04 14:14 |
tool |
grepper |
0m
Error:
Args: map[Expression:\.tx = PathPrefix:drivers/net/wireless/ath/ath9k/init.c]
Results:
|
| 38/2 |
2026/09/04 14:14 |
llm |
expert |
0m
Model:
Tokens:
input: 41153
output: 40
thoughts: 21
Thoughts: Here's my thought process, summarized as you requested:
**Navigating the Atheros Wireless Landscape**
Okay, so I need to dig into the Atheros wireless driver, specifically the `ath9k` module, and I'm looking for a specific function or structure: `mac80211_ops`. Given my familiarity with the Linux wireless stack, this immediately signals that I'm likely dealing with the lower-level interaction points between the driver and the mac80211 framework. I'm probably interested in how `ath9k` registers itself, handles key operations like frame transmission and reception, and perhaps how it exposes its capabilities to the generic wireless stack. A search for `mac80211_ops` within the `ath9k` source code will definitely be the starting point. That's where the real meat of the driver-framework interaction resides, and the key to understanding its implementation details will lie. Now let's see what we can uncover!
|
| 39/2 |
2026/09/04 14:14 |
tool |
grepper |
0m
Error:
Args: map[Expression:mac80211_ops PathPrefix:drivers/net/wireless/ath/ath9k/]
Results:
|
| 40/2 |
2026/09/04 14:14 |
llm |
expert |
0m
Model:
Tokens:
input: 41437
output: 41
thoughts: 31
Thoughts: Okay, here's my summary, taking on the persona you requested:
**Navigating the IEEE 802.11 API**
Hmm, just a moment. I'm looking at this code and something's bugging me. Am I dealing with `ieee80211_ops` or `ieee80211_hw_ops` here? They're both intimately tied to the 802.11 layer, but the exact functionality I need probably lives in one over the other, right? I need to be sure I'm calling the correct set of functions, and therefore accessing the data structures, the right way. This confusion could lead to some significant problems, I've got to ensure I use the appropriate version. It's time to double-check the relevant documentation and header files to make certain I'm on the right track before I proceed any further.
|
| 41/2 |
2026/09/04 14:14 |
tool |
grepper |
0m
Args: map[Expression:ieee80211_ops PathPrefix:drivers/net/wireless/ath/ath9k/]
Results: map[Output:drivers/net/wireless/ath/ath9k/ath9k.h=35=struct ath_vif;
drivers/net/wireless/ath/ath9k/ath9k.h-36-
drivers/net/wireless/ath/ath9k/ath9k.h:37:extern struct ieee80211_ops ath9k_ops;
drivers/net/wireless/ath/ath9k/ath9k.h-38-extern int ath9k_modparam_nohwcrypt;
--
drivers/net/wireless/ath/ath9k/htc.h-44-
drivers/net/wireless/ath/ath9k/htc.h:45:extern struct ieee80211_ops ath9k_htc_ops;
drivers/net/wireless/ath/ath9k/htc.h-46-extern int htc_modparam_nohwcrypt;
--
drivers/net/wireless/ath/ath9k/htc_drv_main.c=1861=static void ath9k_htc_channel_switch_beacon(struct ieee80211_hw *hw,
--
drivers/net/wireless/ath/ath9k/htc_drv_main.c-1873-
drivers/net/wireless/ath/ath9k/htc_drv_main.c:1874:struct ieee80211_ops ath9k_htc_ops = {
drivers/net/wireless/ath/ath9k/htc_drv_main.c-1875- .add_chanctx = ieee80211_emulate_add_chanctx,
--
drivers/net/wireless/ath/ath9k/main.c=2772=static int ath9k_get_txpower(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
--
drivers/net/wireless/ath/ath9k/main.c-2789-
drivers/net/wireless/ath/ath9k/main.c:2790:struct ieee80211_ops ath9k_ops = {
drivers/net/wireless/ath/ath9k/main.c-2791- .add_chanctx = ieee80211_emulate_add_chanctx,
]
|
| 42/2 |
2026/09/04 14:14 |
llm |
expert |
0m
Model:
Tokens:
input: 42290
output: 44
thoughts: 29
Thoughts: Okay, here's my attempt at summarizing the thought process, as if I were a seasoned professional:
**Diving into ath9k_ops**
Alright, let's get down to brass tacks. Time to take a look at `ath9k_ops`. I know this is going to be in `drivers/net/wireless/ath/ath9k/main.c`. My mind immediately jumps to the standard structure of this driver. I'm likely interested in the fundamental operational entry points. This means I'm probably going to be parsing the implementation of `ath9k_ops`, with a focus on how it interfaces with the underlying hardware, how it sets up and tears down connections, and how it handles data flow. Knowing the driver, I expect the structure to contain the core functions responsible for tasks like configuring the hardware, managing the MAC layer, handling interrupts, and the overall management of the wireless interface. I'm keen to see the architecture and how that maps to the underlying hardware registers. This entry point is critical, so I'm hoping for well-organized, understandable code. Let's see what we've got.
|
| 43/2 |
2026/09/04 14:14 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/net/wireless/ath/ath9k/main.c Name:ath9k_ops]
Results: map[SourceCode:2790: struct ieee80211_ops ath9k_ops = {
2791: .add_chanctx = ieee80211_emulate_add_chanctx,
2792: .remove_chanctx = ieee80211_emulate_remove_chanctx,
2793: .change_chanctx = ieee80211_emulate_change_chanctx,
2794: .switch_vif_chanctx = ieee80211_emulate_switch_vif_chanctx,
2795: .tx = ath9k_tx,
2796: .start = ath9k_start,
2797: .stop = ath9k_stop,
2798: .add_interface = ath9k_add_interface,
2799: .change_interface = ath9k_change_interface,
2800: .remove_interface = ath9k_remove_interface,
2801: .config = ath9k_config,
2802: .configure_filter = ath9k_configure_filter,
2803: .sta_state = ath9k_sta_state,
2804: .sta_notify = ath9k_sta_notify,
2805: .conf_tx = ath9k_conf_tx,
2806: .bss_info_changed = ath9k_bss_info_changed,
2807: .set_key = ath9k_set_key,
2808: .get_tsf = ath9k_get_tsf,
2809: .set_tsf = ath9k_set_tsf,
2810: .reset_tsf = ath9k_reset_tsf,
2811: .ampdu_action = ath9k_ampdu_action,
2812: .get_survey = ath9k_get_survey,
2813: .rfkill_poll = ath9k_rfkill_poll_state,
2814: .set_coverage_class = ath9k_set_coverage_class,
2815: .flush = ath9k_flush,
2816: .tx_frames_pending = ath9k_tx_frames_pending,
2817: .tx_last_beacon = ath9k_tx_last_beacon,
2818: .release_buffered_frames = ath9k_release_buffered_frames,
2819: .get_stats = ath9k_get_stats,
2820: .set_antenna = ath9k_set_antenna,
2821: .get_antenna = ath9k_get_antenna,
2822:
2823: #ifdef CONFIG_ATH9K_WOW
2824: .suspend = ath9k_suspend,
2825: .resume = ath9k_resume,
2826: .set_wakeup = ath9k_set_wakeup,
2827: #endif
2828:
2829: #ifdef CONFIG_ATH9K_DEBUGFS
2830: .get_et_sset_count = ath9k_get_et_sset_count,
2831: .get_et_stats = ath9k_get_et_stats,
2832: .get_et_strings = ath9k_get_et_strings,
2833: #endif
2834:
2835: #if defined(CONFIG_MAC80211_DEBUGFS) && defined(CONFIG_ATH9K_STATION_STATISTICS)
2836: .sta_add_debugfs = ath9k_sta_add_debugfs,
2837: #endif
2838: .sw_scan_start = ath9k_sw_scan_start,
2839: .sw_scan_complete = ath9k_sw_scan_complete,
2840: .get_txpower = ath9k_get_txpower,
2841: .wake_tx_queue = ath9k_wake_tx_queue,
2842: };
SourceFile:drivers/net/wireless/ath/ath9k/main.c]
|
| 44/2 |
2026/09/04 14:14 |
llm |
expert |
0m
Model:
Tokens:
input: 43778
output: 45
thoughts: 10
Thoughts: Okay, here's my interpretation of that thought process, tailored for an expert audience, and presented as if it were my own internal monologue:
**Decoding the Network Driver's Transmission Path**
Right, so I'm looking at the `ath9k` driver, specifically at the transmission path. The code has just assigned `.tx = ath9k_tx`. That `.tx` is clearly a pointer or reference within a larger structure – probably a struct related to the hardware interface or a transmission queue itself. The assignment of `ath9k_tx` to `.tx` means that `ath9k_tx` is going to be the function or method that handles packet transmission. It's the core of how the driver orchestrates getting data onto the wireless medium. I know I'll be digging into `ath9k_tx` to understand how the driver handles packet formatting, hardware queue selection, any rate adaptation logic, and the actual DMA transfers to the radio hardware. The fact that this is *the* assignment I see tells me this is where the *action* is.
|
| 45/2 |
2026/09/04 14:14 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/net/wireless/ath/ath9k/xmit.c Name:ath9k_tx]
Results: map[SourceCode: 753: static void ath9k_tx(struct ieee80211_hw *hw,
754: struct ieee80211_tx_control *control,
755: struct sk_buff *skb)
756: {
757: struct ath_softc *sc = hw->priv;
758: struct ath_common *common = ath9k_hw_common(sc->sc_ah);
759: struct ath_tx_control txctl;
760: struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
761: unsigned long flags;
762:
763: if (sc->ps_enabled) {
764: /*
765: * mac80211 does not set PM field for normal data frames, so we
766: * need to update that based on the current PS mode.
767: */
768: if (ieee80211_is_data(hdr->frame_control) &&
769: !ieee80211_is_nullfunc(hdr->frame_control) &&
770: !ieee80211_has_pm(hdr->frame_control)) {
771: ath_dbg(common, PS,
772: "Add PM=1 for a TX frame while in PS mode\n");
773: hdr->frame_control |= cpu_to_le16(IEEE80211_FCTL_PM);
774: }
775: }
776:
777: if (unlikely(sc->sc_ah->power_mode == ATH9K_PM_NETWORK_SLEEP)) {
778: /*
779: * We are using PS-Poll and mac80211 can request TX while in
780: * power save mode. Need to wake up hardware for the TX to be
781: * completed and if needed, also for RX of buffered frames.
782: */
783: ath9k_ps_wakeup(sc);
784: spin_lock_irqsave(&sc->sc_pm_lock, flags);
785: if (!(sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_AUTOSLEEP))
786: ath9k_hw_setrxabort(sc->sc_ah, 0);
787: if (ieee80211_is_pspoll(hdr->frame_control)) {
788: ath_dbg(common, PS,
789: "Sending PS-Poll to pick a buffered frame\n");
790: sc->ps_flags |= PS_WAIT_FOR_PSPOLL_DATA;
791: } else {
792: ath_dbg(common, PS, "Wake up to complete TX\n");
793: sc->ps_flags |= PS_WAIT_FOR_TX_ACK;
794: }
795: /*
796: * The actual restore operation will happen only after
797: * the ps_flags bit is cleared. We are just dropping
798: * the ps_usecount here.
799: */
800: spin_unlock_irqrestore(&sc->sc_pm_lock, flags);
801: ath9k_ps_restore(sc);
802: }
803:
804: /*
805: * Cannot tx while the hardware is in full sleep, it first needs a full
806: * chip reset to recover from that
807: */
808: if (unlikely(sc->sc_ah->power_mode == ATH9K_PM_FULL_SLEEP)) {
809: ath_err(common, "TX while HW is in FULL_SLEEP mode\n");
810: goto exit;
811: }
812:
813: memset(&txctl, 0, sizeof(struct ath_tx_control));
814: txctl.txq = sc->tx.txq_map[skb_get_queue_mapping(skb)];
815: txctl.sta = control->sta;
816:
817: ath_dbg(common, XMIT, "transmitting packet, skb: %p\n", skb);
818:
819: if (ath_tx_start(hw, skb, &txctl) != 0) {
820: ath_dbg(common, XMIT, "TX failed\n");
821: TX_STAT_INC(sc, txctl.txq->axq_qnum, txfailed);
822: goto exit;
823: }
824:
825: return;
826: exit:
827: ieee80211_free_txskb(hw, skb);
828: }
SourceFile:drivers/net/wireless/ath/ath9k/main.c]
|
| 46/2 |
2026/09/04 14:14 |
llm |
expert |
0m
Model:
Tokens:
input: 45461
output: 45
thoughts: 17
Thoughts: Here's my attempt at summarizing the thought process, tailored for an expert audience and written in the first person:
**Kernel Module Interaction Inquiry**
Okay, so I'm digging into this wireless driver code again. My main focus is on the data path, and I'm currently looking at the transmit process. I'm seeing that `ath9k_tx` function is key in handling the transmission of packets. Now, I'm noting that `ath9k_tx` makes a call to `ath_tx_start`. So, to break this down, I have a clear control flow: `ath9k_tx` prepares the transmission request and at some point, `ath_tx_start` is responsible to start the process to get the frame to the transmitter and then the hardware. This has implications for how I want to debug the transmission process from the software all the way down.
|
| 47/2 |
2026/09/04 14:14 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/net/wireless/ath/ath9k/xmit.c Name:ath_tx_start]
Results: map[SourceCode:2322: /* Upon failure caller should free skb */
2323: int ath_tx_start(struct ieee80211_hw *hw, struct sk_buff *skb,
2324: struct ath_tx_control *txctl)
2325: {
2326: struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
2327: struct ieee80211_sta *sta = txctl->sta;
2328: struct ieee80211_vif *vif = info->control.vif;
2329: struct ath_frame_info *fi = get_frame_info(skb);
2330: struct ath_softc *sc = hw->priv;
2331: struct ath_txq *txq = txctl->txq;
2332: struct ath_atx_tid *tid = NULL;
2333: struct ath_node *an = NULL;
2334: struct ath_buf *bf;
2335: bool ps_resp;
2336: int q, ret;
2337:
2338: ps_resp = !!(info->control.flags & IEEE80211_TX_CTRL_PS_RESPONSE);
2339:
2340: ret = ath_tx_prepare(hw, skb, txctl);
2341: if (ret)
2342: return ret;
2343:
2344: /*
2345: * At this point, the vif, hw_key and sta pointers in the tx control
2346: * info are no longer valid (overwritten by the ath_frame_info data.
2347: */
2348:
2349: q = skb_get_queue_mapping(skb);
2350:
2351: if (ps_resp)
2352: txq = sc->tx.uapsdq;
2353:
2354: if (txctl->sta) {
2355: an = (struct ath_node *) sta->drv_priv;
2356: tid = ath_get_skb_tid(an, skb);
2357: }
2358:
2359: ath_txq_lock(sc, txq);
2360: if (txq == sc->tx.txq_map[q]) {
2361: fi->txq = q;
2362: ++txq->pending_frames;
2363: }
2364:
2365: bf = ath_tx_setup_buffer(sc, txq, tid, skb);
2366: if (!bf) {
2367: ath_txq_skb_done(sc, skb);
2368: if (txctl->paprd)
2369: dev_kfree_skb_any(skb);
2370: else
2371: ieee80211_free_txskb(sc->hw, skb);
2372: goto out;
2373: }
2374:
2375: bf->bf_state.bfs_paprd = txctl->paprd;
2376:
2377: if (txctl->paprd)
2378: bf->bf_state.bfs_paprd_timestamp = jiffies;
2379:
2380: ath_set_rates(vif, sta, bf);
2381: ath_tx_send_normal(sc, txq, tid, skb);
2382:
2383: out:
2384: ath_txq_unlock(sc, txq);
2385:
2386: return 0;
2387: }
SourceFile:drivers/net/wireless/ath/ath9k/xmit.c]
|
| 48/2 |
2026/09/04 14:14 |
llm |
expert |
0m
Model:
Tokens:
input: 46796
output: 45
thoughts: 15
Thoughts: Here's my take on those thoughts, from an expert's perspective:
**My Perspective on ath_tx_start and ath_set_rates**
Okay, so `ath_tx_start` is being called, which immediately makes me think about the transmission process in the Atheros driver. It's the point where a frame is actually *sent* out over the air. And the very first thing that jumps out is the call to `ath_set_rates`. That's critical. `ath_set_rates` is where we're defining the *actual* data rates used for this transmission. It's not just a casual decision; this function needs to consider a whole bunch of factors: signal strength, noise levels, the capabilities of both the sending and receiving radios (I'm assuming we're smart about this and aren't blindly sending at the highest possible rate!), the current channel, any rate adaptation algorithms in play, and potentially even things like traffic prioritization. Basically, `ath_set_rates` is the brains of the operation in determining how reliable the transmission is going to be. Are we using the right MCS index, the right modulation coding scheme, to be sure that the packet will arrive at the destination? This means the rate selection directly impacts throughput, error rate, and overall network performance. So, `ath_tx_start` relies on `ath_set_rates` to make the crucial decisions about how the data is actually *transmitted*, so that it has the best chance of succeeding. It's the linchpin.
|
| 49/2 |
2026/09/04 14:14 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/net/wireless/ath/ath9k/xmit.c Name:ath_set_rates]
Results: map[SourceCode: 198: static void ath_set_rates(struct ieee80211_vif *vif, struct ieee80211_sta *sta,
199: struct ath_buf *bf)
200: {
201: struct ieee80211_tx_info *tx_info;
202:
203: tx_info = IEEE80211_SKB_CB(bf->bf_mpdu);
204:
205: if (!ath_merge_ratetbl(sta, bf, tx_info))
206: ieee80211_get_tx_rates(vif, sta, bf->bf_mpdu, bf->rates,
207: ARRAY_SIZE(bf->rates));
208: }
SourceFile:drivers/net/wireless/ath/ath9k/xmit.c]
|
| 50/2 |
2026/09/04 14:14 |
llm |
expert |
0m
Model:
Tokens:
input: 47441
output: 47
thoughts: 17
Thoughts: Here's a summary of my thoughts, as though I'm processing this information:
**Analyzing the Rate Table Interaction**
Okay, so I'm looking at this `ath_set_rates` function, and the first thing that jumps out is its call to `ath_merge_ratetbl`. Clearly, `ath_set_rates` isn't doing the rate setting directly; it's delegating that part to `ath_merge_ratetbl`. This immediately suggests a modular design, likely to handle complex rate selection logic. I need to understand how the rate tables are being merged and what the inputs to `ath_merge_ratetbl` are. Is it combining static rate tables with dynamic ones based on signal quality, perhaps? Are there different tables for different radio modes or bands? This is where the core logic of rate adaptation probably resides. I have to trace the parameters and return values of the `ath_merge_ratetbl` function to truly grasp the control flow. My next step will be to explore `ath_merge_ratetbl` directly to understand what is being merged, how it is being done and why. I'm wondering if this modularity has implications for potential customizations or optimization.
|
| 51/2 |
2026/09/04 14:14 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/net/wireless/ath/ath9k/xmit.c Name:ath_merge_ratetbl]
Results: map[SourceCode: 162: static bool ath_merge_ratetbl(struct ieee80211_sta *sta, struct ath_buf *bf,
163: struct ieee80211_tx_info *tx_info)
164: {
165: struct ieee80211_sta_rates *ratetbl;
166: u8 i;
167:
168: if (!sta)
169: return false;
170:
171: ratetbl = rcu_dereference(sta->rates);
172: if (!ratetbl)
173: return false;
174:
175: if (tx_info->control.rates[0].idx < 0 ||
176: tx_info->control.rates[0].count == 0)
177: {
178: i = 0;
179: } else {
180: bf->rates[0] = tx_info->control.rates[0];
181: i = 1;
182: }
183:
184: for ( ; i < IEEE80211_TX_MAX_RATES; i++) {
185: bf->rates[i].idx = ratetbl->rate[i].idx;
186: bf->rates[i].flags = ratetbl->rate[i].flags;
187: if (tx_info->control.use_rts)
188: bf->rates[i].count = ratetbl->rate[i].count_rts;
189: else if (tx_info->control.use_cts_prot)
190: bf->rates[i].count = ratetbl->rate[i].count_cts;
191: else
192: bf->rates[i].count = ratetbl->rate[i].count;
193: }
194:
195: return true;
196: }
SourceFile:drivers/net/wireless/ath/ath9k/xmit.c]
|
| 52/2 |
2026/09/04 14:14 |
llm |
expert |
0m
Model:
Tokens:
input: 48363
output: 53
thoughts: 133
Thoughts: **Investigating Rate Index Handling in Wireless Drivers**
Okay, so I was looking into how rate indices are handled, and I found something interesting in the `ath_merge_ratetbl` function. It seems that if the rate index, specifically `tx_info->control.rates[0].idx`, is less than zero, it's bypassed entirely. Essentially, the code knows to ignore a negative index and fall back to using the default rate stored in `ratetbl->rate[0]`. That's good; it means `ath9k` is behaving correctly in this scenario.
Now, I'm turning my attention to `iwlwifi`. I remember seeing something similar there, so I'm double-checking the code. Aha! Here it is: `drivers/net/wireless/intel/iwlwifi/mvm/tx.c:364` where `rate_idx` is assigned from `info->control.rates[0].idx`. Time to dive into `iwl_mvm_get_tx_rate` and see how this index is actually used. Need to see if they've implemented a similar fallback mechanism to ensure proper handling of negative indices. Let's see...
|
| 53/2 |
2026/09/04 14:14 |
tool |
codesearch-definition-source |
0m
Error:
Args: map[ContextFile:drivers/net/wireless/intel/iwlwifi/mvm/tx.c Name:iwl_mvm_get_tx_rate]
Results: map[SourceCode: SourceFile:]
|
| 54/2 |
2026/09/04 14:14 |
llm |
expert |
0m
Model:
Tokens:
input: 48828
output: 49
thoughts: 26
Thoughts: Here's my take on the thought process:
**Static Function Analysis - Time to Leverage My Tools!**
Okay, so I'm looking at this piece of code and immediately my brain flags it as a static function. That's a key detail! Static functions have some unique properties in terms of scope and usage that I need to quickly get a handle on.
The next thought is, "How am I going to efficiently track this thing down?" I'm not going to manually scan the codebase like some kind of novice! My mind immediately jumps to either `codesearch-find-references` or, if I'm feeling like a quick and dirty solution, `grepper`. Both are perfectly suited to the task - `codesearch-find-references` for the precision and contextual awareness, and `grepper` for the speed and brute-force approach, when I'm just after a broad overview of usage points. Knowing that this is a static function lets me jump to the best tool for the job. Now, let's see which is the best tool for the job, depending on the scope of the project!
|
| 55/2 |
2026/09/04 14:14 |
tool |
grepper |
0m
Args: map[Expression:iwl_mvm_get_tx_rate PathPrefix:drivers/net/wireless/intel/iwlwifi/mvm/tx.c]
Results: map[Output:drivers/net/wireless/intel/iwlwifi/mvm/tx.c=294=static u32 iwl_mvm_get_inject_tx_rate(struct iwl_mvm *mvm,
--
drivers/net/wireless/intel/iwlwifi/mvm/tx.c-345-
drivers/net/wireless/intel/iwlwifi/mvm/tx.c:346:static u32 iwl_mvm_get_tx_rate(struct iwl_mvm *mvm,
drivers/net/wireless/intel/iwlwifi/mvm/tx.c-347- struct ieee80211_tx_info *info,
--
drivers/net/wireless/intel/iwlwifi/mvm/tx.c-379-
drivers/net/wireless/intel/iwlwifi/mvm/tx.c:380:static __le32 iwl_mvm_get_tx_rate_n_flags(struct iwl_mvm *mvm,
drivers/net/wireless/intel/iwlwifi/mvm/tx.c-381- struct ieee80211_tx_info *info,
--
drivers/net/wireless/intel/iwlwifi/mvm/tx.c-388- else
drivers/net/wireless/intel/iwlwifi/mvm/tx.c:389: rate = iwl_mvm_get_tx_rate(mvm, info, sta, fc) |
drivers/net/wireless/intel/iwlwifi/mvm/tx.c-390- iwl_mvm_get_tx_ant(mvm, info, sta, fc);
--
drivers/net/wireless/intel/iwlwifi/mvm/tx.c=398=void iwl_mvm_set_tx_cmd_rate(struct iwl_mvm *mvm,
--
drivers/net/wireless/intel/iwlwifi/mvm/tx.c-436- /* Set the rate in the TX cmd */
drivers/net/wireless/intel/iwlwifi/mvm/tx.c:437: tx_cmd_params->rate_n_flags = iwl_mvm_get_tx_rate_n_flags(mvm, info, sta, fc);
drivers/net/wireless/intel/iwlwifi/mvm/tx.c-438-}
--
drivers/net/wireless/intel/iwlwifi/mvm/tx.c=553=iwl_mvm_set_tx_params(struct iwl_mvm *mvm, struct sk_buff *skb,
--
drivers/net/wireless/intel/iwlwifi/mvm/tx.c-593- rate_n_flags =
drivers/net/wireless/intel/iwlwifi/mvm/tx.c:594: iwl_mvm_get_tx_rate_n_flags(mvm, info, sta,
drivers/net/wireless/intel/iwlwifi/mvm/tx.c-595- hdr->frame_control);
]
|
| 56/2 |
2026/09/04 14:14 |
llm |
expert |
0m
Model:
Tokens:
input: 49906
output: 46
thoughts: 17
Thoughts: Okay, let's dive into this `iwl_mvm_get_tx_rate` function. I need to understand how the Intel Wireless MVM driver determines the transmit rate. This is critical for performance and reliability in any wireless system, so it's something I need to grasp deeply. I suspect this function is the core of their rate selection algorithm within the driver. I expect it'll take in a bunch of parameters related to the current link conditions, the hardware capabilities, and possibly some hints from higher layers about desired throughput or reliability. I'm looking for the logic flow: what factors does it consider? How are they weighted? Is it a lookup table, a calculation, or some combination of both? Are they using any modern techniques like MCS or beamforming? And of course, I'll be watching for any optimizations they might have implemented. I'm keen to see how they've handled the trade-off between maximizing throughput and ensuring a stable connection – the constant tension in wireless networking. Let's see if this code reveals any clever tricks or reveals any missed opportunities. I will also make sure to check if this function calls or is called by other functions, as this helps me build a mental model of the entire system.
|
| 57/2 |
2026/09/04 14:14 |
tool |
read-file |
0m
Args: map[File:drivers/net/wireless/intel/iwlwifi/mvm/tx.c FirstLine:346 LineCount:40]
Results: map[Contents: 346: static u32 iwl_mvm_get_tx_rate(struct iwl_mvm *mvm,
347: struct ieee80211_tx_info *info,
348: struct ieee80211_sta *sta, __le16 fc)
349: {
350: int rate_idx = -1;
351:
352: if (!ieee80211_hw_check(mvm->hw, HAS_RATE_CONTROL)) {
353: /* info->control is only relevant for non HW rate control */
354:
355: /* HT rate doesn't make sense for a non data frame */
356: WARN_ONCE(info->control.rates[0].flags & IEEE80211_TX_RC_MCS &&
357: !ieee80211_is_data(fc),
358: "Got a HT rate (flags:0x%x/mcs:%d/fc:0x%x/state:%d) for a non data frame\n",
359: info->control.rates[0].flags,
360: info->control.rates[0].idx,
361: le16_to_cpu(fc),
362: sta ? iwl_mvm_sta_from_mac80211(sta)->sta_state : -1);
363:
364: rate_idx = info->control.rates[0].idx;
365:
366: /* For non 2 GHZ band, remap mac80211 rate indices into driver
367: * indices.
368: */
369: if (info->band != NL80211_BAND_2GHZ ||
370: (info->flags & IEEE80211_TX_CTL_NO_CCK_RATE))
371: rate_idx += IWL_FIRST_OFDM_RATE;
372:
373: /* For 2.4 GHZ band, check that there is no need to remap */
374: BUILD_BUG_ON(IWL_FIRST_CCK_RATE != 0);
375: }
376:
377: return iwl_mvm_convert_rate_idx(mvm, info, rate_idx);
378: }
379:
380: static __le32 iwl_mvm_get_tx_rate_n_flags(struct iwl_mvm *mvm,
381: struct ieee80211_tx_info *info,
382: struct ieee80211_sta *sta, __le16 fc)
383: {
384: u32 rate;
385:
]
|
| 58/2 |
2026/09/04 14:14 |
llm |
expert |
0m
Model:
Tokens:
input: 51018
output: 53
thoughts: 55
Thoughts: Okay, here's my interpretation of this logic, as though it were my own thought process, assuming I'm already deep in the weeds of OFDM rate indexing in an 802.11 implementation:
**Decoding this Rate Index Shift**
Alright, so `rate_idx` is this critical value, and if it's -1, something funky is clearly going on. The code is doing a simple offset: `-1` gets transformed into `-1 + IWL_FIRST_OFDM_RATE`. And, seeing as I'm familiar with this codebase, `IWL_FIRST_OFDM_RATE` is defined as 4. So, basically, `-1` maps to `3`. This is likely a special case. Perhaps -1 is a "default" or "invalid" rate in the higher level context. Mapping it to 3 is a method the system takes to deal with the higher-level "invalid" rate. Now that this shift has happened, the result is fed directly into `iwl_mvm_convert_rate_idx`. I know this function is critical. It's the point where we're probably doing the translation from the *logical* rate index, which is what we see here, into the hardware-specific representation. It's the place where we convert the "user-facing" rate index into something the physical layer really understands and acts on. I need to make sure I completely understand what `iwl_mvm_convert_rate_idx` does with the "new" rate, since the value of 3 could mean anything in hardware. I need to make sure all the edge cases are dealt with.
|
| 59/2 |
2026/09/04 14:14 |
tool |
codesearch-definition-source |
0m
Error:
Args: map[ContextFile:drivers/net/wireless/intel/iwlwifi/mvm/tx.c Name:iwl_mvm_convert_rate_idx]
Results: map[SourceCode: SourceFile:]
|
| 60/2 |
2026/09/04 14:14 |
llm |
expert |
0m
Model:
Tokens:
input: 51496
output: 49
thoughts: 18
Thoughts: Here's my thought process, as if I were thinking it:
**Digging into the iwlwifi Rate Conversion**
Okay, so I need to understand this `iwl_mvm_convert_rate_idx` function. My gut tells me this is core to how the Intel Wireless driver, specifically the MVM (Mesh Virtual Machine) part, handles rate selection. I'm guessing it's translating some internal representation of a transmission rate into something the hardware understands, or vice-versa, or maybe even performing a conversion between different standards. The `idx` part of the name is a clue – it likely indicates an index into some lookup table or array of supported rates. I'll need to see how it's used – cross-referencing this function will be key to understanding the data flow here. I'm going to start searching, expecting to find the function's declaration, calls, and hopefully some comments surrounding its implementation. I'm particularly interested in where this function sits in the overall rate adaptation logic of the iwl driver. Hopefully, the code comments are good enough to understand the context of this all. This function is likely a critical part of the PHY adaptation.
|
| 61/2 |
2026/09/04 14:15 |
tool |
grepper |
0m
Args: map[Expression:iwl_mvm_convert_rate_idx PathPrefix:drivers/net/wireless/intel/iwlwifi/mvm/tx.c]
Results: map[Output:drivers/net/wireless/intel/iwlwifi/mvm/tx.c=249=static u32 iwl_mvm_get_tx_ant(struct iwl_mvm *mvm,
--
drivers/net/wireless/intel/iwlwifi/mvm/tx.c-265-
drivers/net/wireless/intel/iwlwifi/mvm/tx.c:266:static u32 iwl_mvm_convert_rate_idx(struct iwl_mvm *mvm,
drivers/net/wireless/intel/iwlwifi/mvm/tx.c-267- struct ieee80211_tx_info *info,
--
drivers/net/wireless/intel/iwlwifi/mvm/tx.c=294=static u32 iwl_mvm_get_inject_tx_rate(struct iwl_mvm *mvm,
--
drivers/net/wireless/intel/iwlwifi/mvm/tx.c-333-
drivers/net/wireless/intel/iwlwifi/mvm/tx.c:334: result = iwl_mvm_convert_rate_idx(mvm, info, rate_idx);
drivers/net/wireless/intel/iwlwifi/mvm/tx.c-335- }
--
drivers/net/wireless/intel/iwlwifi/mvm/tx.c=346=static u32 iwl_mvm_get_tx_rate(struct iwl_mvm *mvm,
--
drivers/net/wireless/intel/iwlwifi/mvm/tx.c-376-
drivers/net/wireless/intel/iwlwifi/mvm/tx.c:377: return iwl_mvm_convert_rate_idx(mvm, info, rate_idx);
drivers/net/wireless/intel/iwlwifi/mvm/tx.c-378-}
]
|
| 62/2 |
2026/09/04 14:15 |
llm |
expert |
0m
Model:
Tokens:
input: 52293
output: 46
thoughts: 17
Thoughts: Okay, let's dive into `iwl_mvm_convert_rate_idx`. Here's my take on understanding this function:
**Analyzing `iwl_mvm_convert_rate_idx`**
Alright, so I'm looking at `iwl_mvm_convert_rate_idx`. Immediately, my expert eye hones in on the name. It's a clear indication of a conversion or translation process, specifically within the Intel Wireless MVM driver (iwl_mvm). The "rate_idx" suggests we're dealing with indexed representations of data rates, likely for different modulation and coding schemes (MCS) or perhaps legacy rates. This implies there's a need to bridge a gap between two different rate representations.
I'm thinking this function probably sits somewhere between the hardware's view of a data rate and the higher-level software's representation. Maybe it handles mapping a generic rate index to hardware-specific registers, or perhaps it does the reverse – translating hardware status reports back to a software-understandable rate value. I'll need to look at the surrounding code to determine which is more likely.
I'm also curious about the data structures being used. Is this dealing with standard IEEE rate structures, or does iwl_mvm have its own custom representation? I'll be looking for references to structures like `ieee80211_rates`, `ieee80211_supported_band`, or perhaps vendor-specific iwl_mvm internal structures. Understanding these structures will be key to understanding the conversion logic.
My initial hypothesis is that it could map the internal MCS index (which might be 0-based) to the actual MCS rates used by the device, or to translate that to the rate used within the `ieee80211` core. I will pay careful attention to the data types of input and output parameters. I expect these types will provide the best clues regarding the direction of the conversion.
This function probably handles edge cases, too. What happens if the input `rate_idx` is invalid? Does it return an error code or a default rate? That will be important. I need to keep an eye out for any error handling or boundary checks. I suspect I might find conditional statements to catch invalid values.
Essentially, I need to understand *what* is being converted *to* and *from*, and *why*. What is the input, what is the output, and what context is this conversion taking place in? This is going to be crucial for figuring out how the Intel Wireless MVM driver manages data rates. Now let's see the code!
|
| 63/2 |
2026/09/04 14:15 |
tool |
read-file |
0m
Args: map[File:drivers/net/wireless/intel/iwlwifi/mvm/tx.c FirstLine:266 LineCount:28]
Results: map[Contents: 266: static u32 iwl_mvm_convert_rate_idx(struct iwl_mvm *mvm,
267: struct ieee80211_tx_info *info,
268: int rate_idx)
269: {
270: u32 rate_flags = 0;
271: bool is_cck;
272:
273: /* if the rate isn't a well known legacy rate, take the lowest one */
274: if (rate_idx < 0 || rate_idx >= IWL_RATE_COUNT_LEGACY)
275: rate_idx = iwl_mvm_mac_ctxt_get_lowest_rate(mvm,
276: info,
277: info->control.vif);
278:
279: /* Get FW rate for tx_cmd->rate_n_flags */
280: rate_flags |= iwl_mvm_rate_idx_to_fw_idx(mvm->fw, rate_idx);
281:
282: is_cck = (rate_idx >= IWL_FIRST_CCK_RATE) &&
283: (rate_idx <= IWL_LAST_CCK_RATE);
284:
285: /* Set CCK or OFDM flag */
286: if (!is_cck)
287: rate_flags |= RATE_MCS_MOD_TYPE_LEGACY_OFDM;
288: else
289: rate_flags |= RATE_MCS_MOD_TYPE_CCK;
290:
291: return rate_flags;
292: }
293:
]
|
| 64/2 |
2026/09/04 14:15 |
llm |
expert |
0m
Model:
Tokens:
input: 53398
output: 59
thoughts: 124
Thoughts: Okay, here's my understanding, expressed as a first-person summary, keeping in mind I'm an expert in this field:
**Rate Index Handling: A Quick Security Check**
Alright, that `iwl_mvm_convert_rate_idx` function is looking good. It's explicitly checking if the `rate_idx` is less than zero, and if it is, it's falling back to `iwl_mvm_mac_ctxt_get_lowest_rate`. That's precisely the kind of defensive programming I like to see. Makes it perfectly safe in this context. It proactively prevents any out-of-bounds access or unexpected behavior. No hidden vulnerabilities there, that's clean code!
Now, let's switch gears and consider the `mt76` driver. I need to make sure I'm thinking about this code correctly. Let's see... looking at the `mt76x02_mac.c` file, line 464... yep, here it is: `if (rates[0].idx == 8)`. This seems to be within the `mt76x02_tx_rate_fallback` function. We need to be sure that it is safe too. Ok, that looks fine.
|
| 65/2 |
2026/09/04 14:15 |
tool |
codesearch-definition-source |
0m
Error:
Args: map[ContextFile:drivers/net/wireless/mediatek/mt76/mt76x02_mac.c Name:mt76x02_tx_rate_fallback]
Results: map[SourceCode: SourceFile:]
|
| 66/2 |
2026/09/04 14:15 |
llm |
expert |
0m
Model:
Tokens:
input: 53874
output: 55
thoughts: 19
Thoughts: Here's my thought process, summarized as you requested:
**Investigating the `mt76x02_tx_rate_fallback` Function**
Okay, time to dive into this `mt76x02_tx_rate_fallback` function. It immediately suggests we're dealing with rate adaptation in an mt76x02 wireless driver, which means it's likely responsible for handling situations where the chosen transmit rate needs to be dropped to maintain a stable connection. I need to figure out *how* and *why* it's falling back. Is it triggered by signal strength, frame errors, channel conditions, or a combination of factors? I need to understand its relationship to the broader rate control mechanisms in this specific driver. Is this a custom fallback scheme, or is it working in conjunction with standard 802.11 rate control algorithms? Are there any related tuning parameters I might need to consider? Knowing where this is called from will be key – is it embedded deep within the MAC layer, or higher up, perhaps interacting with the regulatory domain settings? I also need to find out *what* rate it's falling back to. Is it a fixed pre-determined rate, or is it based on some adaptive logic? I should also examine if any other related functions are used around this one to get the full picture. My immediate goals: trace its call path, understand its inputs and outputs, and assess its role in maintaining link quality. I'll start by searching the code to see where it is used.
|
| 67/2 |
2026/09/04 14:15 |
tool |
grepper |
0m
Args: map[Expression:mt76x02_tx_rate_fallback PathPrefix:drivers/net/wireless/mediatek/mt76/mt76x02_mac.c]
Results: map[Output:drivers/net/wireless/mediatek/mt76/mt76x02_mac.c=439=static void
drivers/net/wireless/mediatek/mt76/mt76x02_mac.c:440:mt76x02_tx_rate_fallback(struct ieee80211_tx_rate *rates, int idx, int phy)
drivers/net/wireless/mediatek/mt76/mt76x02_mac.c-441-{
--
drivers/net/wireless/mediatek/mt76/mt76x02_mac.c=476=mt76x02_mac_fill_tx_status(struct mt76x02_dev *dev, struct mt76x02_sta *msta,
--
drivers/net/wireless/mediatek/mt76/mt76x02_mac.c-516-
drivers/net/wireless/mediatek/mt76/mt76x02_mac.c:517: mt76x02_tx_rate_fallback(info->status.rates, i, phy);
drivers/net/wireless/mediatek/mt76/mt76x02_mac.c-518- if (info->status.rates[i].idx == last_rate.idx)
]
|
| 68/2 |
2026/09/04 14:15 |
llm |
expert |
0m
Model:
Tokens:
input: 54607
output: 47
thoughts: 154
Thoughts: **Analyzing Rate Fallback Logic**
Okay, so I'm looking into how rate fallback is handled within the `mt76x02` driver, specifically triggered by `mt76x02_tx_rate_fallback`. The key here is that this function operates on `info->status.rates`, not `info->control.rates`. That's important. `info->status.rates` is populated *after* a packet is transmitted, providing a record of the actual rates the hardware *used*. It’s a read-only report of what happened, not a user-controllable setting. So, fallback decisions are being made based on what the hardware *achieved*, not what we *asked* it to do initially.
Now, I need to compare this behavior to other drivers. I'm wondering what `cw1200` does. Let me check... Ah, here! In `drivers/net/wireless/st/cw1200/txrx.c`, I see a `BUG_ON(rates[0].idx < 0)`. That's interesting, suggesting the driver expects the index of the rate to be valid.
Let's switch gears and go look at `tx_policy_build` to see how it might be interacting with the process.
|
| 69/2 |
2026/09/04 14:15 |
tool |
codesearch-definition-source |
0m
Error:
Args: map[ContextFile:drivers/net/wireless/st/cw1200/txrx.c Name:tx_policy_build]
Results: map[SourceCode: SourceFile:]
|
| 70/2 |
2026/09/04 14:15 |
llm |
expert |
0m
Model:
Tokens:
input: 55106
output: 45
thoughts: 30
Thoughts: Here's a summary of my thought process, as requested:
**Diving into the CW1200 TX/RX Code**
Okay, time to get my hands dirty. I'm going to jump straight into the `drivers/net/wireless/st/cw1200/txrx.c` file. Specifically, I'm aiming around line 72. I need to understand what's happening at that point in the code, likely related to the transmit or receive path, given the filename. I'm expecting to find some crucial function calls or data structure initializations, or potentially a significant decision point in the data flow. Hopefully it provides some useful information about the state of the driver. I will be looking for clues on how the driver handles data buffering, packet framing, or even hardware interaction. Let's see what secrets this section of the code holds.
|
| 71/2 |
2026/09/04 14:15 |
tool |
read-file |
0m
Args: map[File:drivers/net/wireless/st/cw1200/txrx.c FirstLine:65 LineCount:20]
Results: map[Contents: 65: static void tx_policy_build(const struct cw1200_common *priv,
66: /* [out] */ struct tx_policy *policy,
67: struct ieee80211_tx_rate *rates, size_t count)
68: {
69: int i, j;
70: unsigned limit = priv->short_frame_max_tx_count;
71: unsigned total = 0;
72: BUG_ON(rates[0].idx < 0);
73: memset(policy, 0, sizeof(*policy));
74:
75: /* Sort rates in descending order. */
76: for (i = 1; i < count; ++i) {
77: if (rates[i].idx < 0) {
78: count = i;
79: break;
80: }
81: if (rates[i].idx > rates[i - 1].idx) {
82: struct ieee80211_tx_rate tmp = rates[i - 1];
83: rates[i - 1] = rates[i];
84: rates[i] = tmp;
]
|
| 72/2 |
2026/09/04 14:15 |
llm |
expert |
0m
Model:
Tokens:
input: 55703
output: 43
thoughts: 19
Thoughts: Okay, here's my interpretation of that thought process, from an expert's perspective:
**Diving into the Transmission Pipeline**
Alright, so I'm focusing on the transmit side of the CW1200. I see that the `cw1200_tx` function is the point of entry for the transmit process. That's good, a well-defined starting point is crucial for understanding the whole flow. Now, the key here is `tx_policy_build`. From this call graph context, `tx_policy_build` must be a function responsible for constructing the transmission policy. This policy, I'm guessing, will define things like the transmit rate, power levels, channel selection, retransmission strategies - the critical parameters that govern how the data gets out over the air. The fact that it's called *from* `cw1200_tx` suggests that the policy generation is a preliminary step before the actual data transmission begins. I need to dig into `tx_policy_build` to understand what factors it considers and how the policy is determined. This is likely where the driver's intelligence regarding channel conditions, regulatory constraints, and potentially higher-layer protocol requirements comes into play. It's the brains behind the brawn, so to speak. Understanding this module is key to understanding how the device adapts to its environment.
|
| 73/2 |
2026/09/04 14:15 |
tool |
grepper |
0m
Args: map[Expression:tx_policy_build PathPrefix:drivers/net/wireless/st/cw1200/txrx.c]
Results: map[Output:drivers/net/wireless/st/cw1200/txrx.c=47=static void tx_policy_dump(struct tx_policy *policy)
--
drivers/net/wireless/st/cw1200/txrx.c-64-
drivers/net/wireless/st/cw1200/txrx.c:65:static void tx_policy_build(const struct cw1200_common *priv,
drivers/net/wireless/st/cw1200/txrx.c-66- /* [out] */ struct tx_policy *policy,
--
drivers/net/wireless/st/cw1200/txrx.c=296=static int tx_policy_get(struct cw1200_common *priv,
--
drivers/net/wireless/st/cw1200/txrx.c-303-
drivers/net/wireless/st/cw1200/txrx.c:304: tx_policy_build(priv, &wanted, rates, count);
drivers/net/wireless/st/cw1200/txrx.c-305-
]
|
| 74/2 |
2026/09/04 14:16 |
llm |
expert |
0m
Model:
Tokens:
input: 56339
output: 46
thoughts: 11
Thoughts: Okay, let's dive into this. Here's my take on those thoughts, as if they're my own:
**Analyzing the `tx_policy_get` Function**
Alright, let's break this down. My mind immediately goes to the `tx_policy_get` function. Now, what's its purpose? Is it a lookup, a retrieval, a calculation? Context is key. Am I looking at a specific transaction policy? What are the implications of *getting* a policy? Does this function dictate the parameters of a transaction, enforce it, or merely return existing settings? Is it part of the execution path, or merely used for external display?
I need to understand its relationship to the broader system. What's the surrounding code? Are there error handling mechanisms? What are the potential failure modes if the policy isn't available, or if the retrieval fails? I need to think about data structures: How is the policy data *represented*? Is it in a database, a cache, a configuration file? The efficiency of `tx_policy_get` is critical, especially in a high-volume transactional environment. I need to be aware of caching strategies, potential race conditions, and any security implications related to the information it retrieves. This also includes understanding how the policies are changed, in the event of an update.
My next step is to examine the function's parameters, return values, and side effects. What inputs does it take? What does it return? Are there any global variables being accessed or modified? What exceptions might be thrown? What external systems does it interact with? I need to look for documentation, or better, unit tests, to gain a clearer understanding of its behavior under various conditions. Ultimately, a good understanding of `tx_policy_get` is essential to understanding the transaction's behavior.
|
| 75/2 |
2026/09/04 14:16 |
tool |
read-file |
0m
Args: map[File:drivers/net/wireless/st/cw1200/txrx.c FirstLine:296 LineCount:20]
Results: map[Contents: 296: static int tx_policy_get(struct cw1200_common *priv,
297: struct ieee80211_tx_rate *rates,
298: size_t count, bool *renew)
299: {
300: int idx;
301: struct tx_policy_cache *cache = &priv->tx_policy_cache;
302: struct tx_policy wanted;
303:
304: tx_policy_build(priv, &wanted, rates, count);
305:
306: spin_lock_bh(&cache->lock);
307: if (WARN_ON_ONCE(list_empty(&cache->free))) {
308: spin_unlock_bh(&cache->lock);
309: return CW1200_INVALID_RATE_ID;
310: }
311: idx = tx_policy_find(cache, &wanted);
312: if (idx >= 0) {
313: pr_debug("[TX policy] Used TX policy: %d\n", idx);
314: *renew = false;
315: } else {
]
|
| 76/2 |
2026/09/04 14:16 |
llm |
expert |
0m
Model:
Tokens:
input: 57119
output: 43
thoughts: 20
Thoughts: Here's my thinking about that snippet of code:
**Understanding the Data Flow: `tx_policy_get` and `cw1200_tx`**
Okay, so I see `tx_policy_get` being called within the `cw1200_tx` function. My initial thought is to figure out the purpose of each of these, and how they relate. Given the naming conventions, it seems like `cw1200_tx` is likely related to the CW1200 Wi-Fi chipset, probably handling transmission functions. `tx_policy_get`, on the other hand, is probably responsible for retrieving transmission policy configurations or settings. The name strongly suggests this is about getting some kind of "policy" that dictates how a transmission should proceed.
The fact that `tx_policy_get` is called from `cw1200_tx` implies a dependency. `cw1200_tx` likely needs the transmission policy, possibly to make decisions about power levels, modulation schemes, or channel access parameters, before actually transmitting the data. I'll need to dig deeper into the code to understand the specific role of `tx_policy_get` within the overall transmission process. Are there any particular parameters being passed between these two functions? Are there any return values from `tx_policy_get` that would be critical for `cw1200_tx` to function? That's what I want to understand next.
|
| 77/2 |
2026/09/04 14:16 |
tool |
grepper |
0m
Args: map[Expression:tx_policy_get PathPrefix:drivers/net/wireless/st/cw1200/txrx.c]
Results: map[Output:drivers/net/wireless/st/cw1200/txrx.c=281=void tx_policy_init(struct cw1200_common *priv)
--
drivers/net/wireless/st/cw1200/txrx.c-295-
drivers/net/wireless/st/cw1200/txrx.c:296:static int tx_policy_get(struct cw1200_common *priv,
drivers/net/wireless/st/cw1200/txrx.c-297- struct ieee80211_tx_rate *rates,
--
drivers/net/wireless/st/cw1200/txrx.c=638=cw1200_tx_h_rate_policy(struct cw1200_common *priv,
--
drivers/net/wireless/st/cw1200/txrx.c-643-
drivers/net/wireless/st/cw1200/txrx.c:644: t->txpriv.rate_id = tx_policy_get(priv,
drivers/net/wireless/st/cw1200/txrx.c-645- t->tx_info->control.rates, IEEE80211_TX_MAX_RATES,
]
|
| 78/2 |
2026/09/04 14:16 |
llm |
expert |
0m
Model:
Tokens:
input: 57825
output: 46
thoughts: 19
Thoughts: Okay, here's my interpretation of what's going through my mind, delivered as a first-person summary, keeping in mind the expert user:
**Deep Dive into `cw1200_tx_h_rate_policy`**
Alright, let's get into this. I'm looking at `cw1200_tx_h_rate_policy`... Immediately, my mind starts to churn through related concepts. I'm thinking about the context. Is this related to a specific radio standard, a particular chipset, or a proprietary implementation? "High rate" transmission policy suggests we're dealing with the finer points of data throughput – likely within the physical layer (PHY) or MAC layer. I'm immediately trying to recall related structures. What are the key parameters involved? Is this policy related to rate adaptation, transmit power control, or some form of congestion avoidance at the transmitter?
I need to understand its impact. How does this policy influence the behavior of the transmitter? Does it dictate which modulation and coding scheme (MCS) is selected? Does it impact the fragmentation or aggregation of data frames? And, of course, the big question: what is the overall goal of the policy? Is it optimization for throughput, power efficiency, or maybe reliability under certain channel conditions?
Next, I'm thinking about where this policy lives in the code. Is it defined within the driver, the firmware, or perhaps within the radio hardware itself? Understanding the implementation level is critical to knowing its flexibility and constraints. My internal search for related code is well underway; I'm already anticipating the typical functions and variables I'll see associated with this policy. I'm ready to dig into the details to understand how this policy is crafted!
|
| 79/2 |
2026/09/04 14:16 |
tool |
read-file |
0m
Args: map[File:drivers/net/wireless/st/cw1200/txrx.c FirstLine:638 LineCount:20]
Results: map[Contents: 638: cw1200_tx_h_rate_policy(struct cw1200_common *priv,
639: struct cw1200_txinfo *t,
640: struct wsm_tx *wsm)
641: {
642: bool tx_policy_renew = false;
643:
644: t->txpriv.rate_id = tx_policy_get(priv,
645: t->tx_info->control.rates, IEEE80211_TX_MAX_RATES,
646: &tx_policy_renew);
647: if (t->txpriv.rate_id == CW1200_INVALID_RATE_ID)
648: return -EFAULT;
649:
650: wsm->flags |= t->txpriv.rate_id << 4;
651:
652: t->rate = cw1200_get_tx_rate(priv,
653: &t->tx_info->control.rates[0]);
654: wsm->max_tx_rate = t->rate->hw_value;
655: if (t->rate->flags & IEEE80211_TX_RC_MCS) {
656: if (cw1200_ht_greenfield(&priv->ht_info))
657: wsm->ht_tx_parameters |=
]
|
| 80/2 |
2026/09/04 14:16 |
llm |
expert |
0m
Model:
Tokens:
input: 58653
output: 51
thoughts: 140
Thoughts: Okay, let me break this down.
**Diving into the Transmission Rate Policy**
Alright, so I'm tracing through this `cw1200_tx` flow, and I've hit a potential snag. It looks like `cw1200_tx_h_rate_policy` is passing the contents of `t->tx_info->control.rates` to `tx_policy_get`. Now, I know `tx_policy_get` is a crucial function; it calls `tx_policy_build` which is where the real work of determining the transmission rate policy occurs. And I see a `BUG_ON(rates[0].idx < 0)` check inside `tx_policy_build`. A negative index here is a critical failure.
So, if that `rates[0].idx` is less than zero, we're going to get a kernel panic. That's a *bad* day. The question now is how can `rates[0].idx` be negative? The code must assume it's never negative, which is an error in the logic flow.
My immediate concern is whether `cw1200_tx_h_rate_policy` is involved with injected frames. Injected frames are often where we see strange edge cases crop up, and if this policy is even *potentially* used for frames that are manually crafted or in any way modified outside the normal driver flow, that could be the trigger. I need to dig deeper into the call path of `cw1200_tx` to confirm whether or not injected frames are even a possibility here.
|
| 81/2 |
2026/09/04 14:16 |
tool |
grepper |
0m
Args: map[Expression:cw1200_tx_h_rate_policy PathPrefix:drivers/net/wireless/st/cw1200/txrx.c]
Results: map[Output:drivers/net/wireless/st/cw1200/txrx.c=637=static int
drivers/net/wireless/st/cw1200/txrx.c:638:cw1200_tx_h_rate_policy(struct cw1200_common *priv,
drivers/net/wireless/st/cw1200/txrx.c-639- struct cw1200_txinfo *t,
--
drivers/net/wireless/st/cw1200/txrx.c=703=void cw1200_tx(struct ieee80211_hw *dev,
--
drivers/net/wireless/st/cw1200/txrx.c-760- cw1200_tx_h_bt(priv, &t, wsm);
drivers/net/wireless/st/cw1200/txrx.c:761: ret = cw1200_tx_h_rate_policy(priv, &t, wsm);
drivers/net/wireless/st/cw1200/txrx.c-762- if (ret)
]
|
| 82/2 |
2026/09/04 14:16 |
llm |
expert |
0m
Model:
Tokens:
input: 59485
output: 46
thoughts: 180
Thoughts: **My Analysis of the cw1200 Kernel Panic**
Okay, so it looks like `cw1200_tx` is indeed the transmission callback function associated with the `cw1200` driver. I've tracked down the issue to a very specific scenario, and it's a classic example of how subtle input validation can lead to serious problems. The core of the problem stems from how the driver handles invalid rate information within injected frames.
Specifically, if a user injects a frame with an invalid transmission rate, the `ieee80211_parse_tx_radiotap` function flags this by setting `rates[0].idx` to -1. This is perfectly reasonable, as -1 is often used to signal an "invalid" or "not set" state. The problem arises when this invalid rate value propagates down the call chain: `cw1200_tx` calls `cw1200_tx_h_rate_policy`, which in turn calls `tx_policy_get`, and finally `tx_policy_build`. It's within `tx_policy_build` that the fatal flaw surfaces: a `BUG_ON(rates[0].idx < 0)` is triggered. This assertion, intended as a debugging check, results in a kernel panic!
Essentially, a user can exploit this vulnerability with an invalidly crafted frame to cause a Denial of Service. My initial instinct is that this is concerning, but I need to understand the full context.
Now, a crucial question surfaces: does the `cw1200` driver even *support* monitor mode and frame injection? If it doesn't, this entire issue is likely a low-priority edge case, and something I'd want to understand, but might not pose a serious security risk. If it *does* support those functionalities, then we've got a much more serious problem on our hands. So I need to verify its capabilities to assess the impact. I'll need to check the driver's feature flags, supported modes, and likely the configuration settings to see what the driver supports.
|
| 83/2 |
2026/09/04 14:16 |
tool |
grepper |
0m
Args: map[Expression:NL80211_IFTYPE_MONITOR PathPrefix:drivers/net/wireless/st/cw1200/]
Results: map[Output:drivers/net/wireless/st/cw1200/debug.c=45=static const char *cw1200_debug_mode(int mode)
--
drivers/net/wireless/st/cw1200/debug.c-49- return "unspecified";
drivers/net/wireless/st/cw1200/debug.c:50: case NL80211_IFTYPE_MONITOR:
drivers/net/wireless/st/cw1200/debug.c-51- return "monitor";
--
drivers/net/wireless/st/cw1200/sta.c=54=int cw1200_start(struct ieee80211_hw *dev)
--
drivers/net/wireless/st/cw1200/sta.c-78- memcpy(priv->mac_addr, dev->wiphy->perm_addr, ETH_ALEN);
drivers/net/wireless/st/cw1200/sta.c:79: priv->mode = NL80211_IFTYPE_MONITOR;
drivers/net/wireless/st/cw1200/sta.c-80- priv->wep_default_key_id = -1;
--
drivers/net/wireless/st/cw1200/sta.c=205=int cw1200_add_interface(struct ieee80211_hw *dev,
--
drivers/net/wireless/st/cw1200/sta.c-217-
drivers/net/wireless/st/cw1200/sta.c:218: if (priv->mode != NL80211_IFTYPE_MONITOR) {
drivers/net/wireless/st/cw1200/sta.c-219- mutex_unlock(&priv->conf_mutex);
--
drivers/net/wireless/st/cw1200/sta.c=248=void cw1200_remove_interface(struct ieee80211_hw *dev,
--
drivers/net/wireless/st/cw1200/sta.c-291- priv->vif = NULL;
drivers/net/wireless/st/cw1200/sta.c:292: priv->mode = NL80211_IFTYPE_MONITOR;
drivers/net/wireless/st/cw1200/sta.c-293- eth_zero_addr(priv->mac_addr);
--
drivers/net/wireless/st/cw1200/sta.c=930=void cw1200_flush(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
--
drivers/net/wireless/st/cw1200/sta.c-935- switch (priv->mode) {
drivers/net/wireless/st/cw1200/sta.c:936: case NL80211_IFTYPE_MONITOR:
drivers/net/wireless/st/cw1200/sta.c-937- drop = true;
--
drivers/net/wireless/st/cw1200/sta.c=2189=static int cw1200_upload_beacon(struct cw1200_common *priv)
--
drivers/net/wireless/st/cw1200/sta.c-2200- if (priv->mode == NL80211_IFTYPE_STATION ||
drivers/net/wireless/st/cw1200/sta.c:2201: priv->mode == NL80211_IFTYPE_MONITOR ||
drivers/net/wireless/st/cw1200/sta.c-2202- priv->mode == NL80211_IFTYPE_UNSPECIFIED)
--
drivers/net/wireless/st/cw1200/wsm.c=1453=static bool wsm_handle_tx_data(struct cw1200_common *priv,
--
drivers/net/wireless/st/cw1200/wsm.c-1505- break;
drivers/net/wireless/st/cw1200/wsm.c:1506: case NL80211_IFTYPE_MONITOR:
drivers/net/wireless/st/cw1200/wsm.c-1507- default:
]
|
| 84/2 |
2026/09/04 14:16 |
llm |
expert |
0m
Model:
Tokens:
input: 61274
output: 49
thoughts: 313
Thoughts: **My Analysis of the WiFi Driver Vulnerability**
Okay, so I've been digging into this potential vulnerability, and here's what I've got so far. It looks like the `cw1200` driver *does* support `NL80211_IFTYPE_MONITOR`, which immediately flags something for me. With the right permissions (specifically `CAP_NET_RAW`), a malicious actor could craft a packet with an invalid rate in the radiotap header, send it through an `AF_PACKET` socket, and potentially trigger a system crash via `BUG_ON` if the system *has* this hardware present.
Hang on though… `cw1200` is a physical device driver, right? I wonder if this can be exploited on something like `mac80211_hwsim`. Let me check. Ah, no. It doesn’t crash there; it just prints a warning. But… the original report *was* about `mac80211_hwsim`, wasn't it? Okay, that changes things slightly. It looks like the core issue actually lies within the `mac80211` core itself. The core is leaving `rates[0].idx = -1`, which is causing issues.
Now, this isn’t just a `cw1200` problem. This affects *multiple* drivers. For `cw1200`, that leads to the `BUG_ON` and the crash. For `wfx`, it triggers a `WARN` statement about an invalid rate policy. The `ath9k` driver seems to have built-in defenses. `iwlwifi` is safe too. `mt76` is also handling it gracefully. Even `mac80211_hwsim` triggers a `WARN_ON_ONCE` in this case.
I have to wonder, what about `silabs/wfx`? That's an interesting one to follow up on.
|
| 85/2 |
2026/09/04 14:16 |
tool |
codesearch-definition-source |
0m
Error:
Args: map[ContextFile:drivers/net/wireless/silabs/wfx/data_tx.c Name:wfx_tx_policy_build]
Results: map[SourceCode: SourceFile:]
|
| 86/2 |
2026/09/04 14:16 |
llm |
expert |
0m
Model:
Tokens:
input: 62082
output: 44
thoughts: 29
Thoughts: Here's my attempt at summarizing the thought process, tailored for an expert audience:
**Diving into the WFX Data Transmission Code**
Okay, time to get my hands dirty. Let's start digging into the WFX driver, specifically the `data_tx.c` file. I'm focusing around line 46. I'm assuming that the kernel version is 6.1. This is where the core of the data transmission logic likely resides. I'm hoping to understand how they're handling packet queuing, descriptor management, and potentially any rate limiting or QoS mechanisms. My initial goal is to see how the software interacts with the hardware's transmit buffers. I'll be looking for clues on how they optimize for throughput and handle potential congestion. Let's see if there are any interesting data structures or macros used here that I'm unfamiliar with. I'll be paying close attention to any error handling or retry logic that might be present as well. Based on the file name, this likely is the first critical component for understanding how the device gets packets from the kernel network stack to the RF link. I'll start with that line and quickly jump around to see what the surrounding code does.
|
| 87/2 |
2026/09/04 14:16 |
tool |
read-file |
0m
Args: map[File:drivers/net/wireless/silabs/wfx/data_tx.c FirstLine:46 LineCount:20]
Results: map[Contents: 46: static void wfx_tx_policy_build(struct wfx_vif *wvif, struct wfx_tx_policy *policy,
47: struct ieee80211_tx_rate *rates)
48: {
49: struct wfx_dev *wdev = wvif->wdev;
50: int i, rateid;
51: u8 count;
52:
53: WARN(rates[0].idx < 0, "invalid rate policy");
54: memset(policy, 0, sizeof(*policy));
55: for (i = 0; i < IEEE80211_TX_MAX_RATES; ++i) {
56: if (rates[i].idx < 0)
57: break;
58: WARN_ON(rates[i].count > 15);
59: rateid = wfx_get_hw_rate(wdev, &rates[i]);
60: /* Pack two values in each byte of policy->rates */
61: count = rates[i].count;
62: if (rateid % 2)
63: count <<= 4;
64: policy->rates[rateid / 2] |= count;
65: }
]
|
| 88/2 |
2026/09/04 14:16 |
llm |
expert |
0m
Model:
Tokens:
input: 62762
output: 45
thoughts: 254
Thoughts: **Analyzing Potential Driver Vulnerabilities**
Okay, so I'm seeing a pattern here. The code I'm looking at has a `WARN` statement about potentially invalid rate policies, specifically when `rates[0].idx` is less than zero. Then, it uses `break` to handle these conditions. So, it's not a hard crash, which is good, but it's still something to investigate. It's a soft error.
My initial thought is to trace the flow of this variable and where it is set and used, just to be thorough. I'm going to look at other drivers that use this pattern.
Let me think... what about `ti/wlcore`? I see in `drivers/net/wireless/ti/wlcore/tx.c` the line `info->status.rates[0].idx = rate;` This looks like the right place to start; however, the rate index is being set on `info->status`, not `info->control`. So this doesn't seem to be the source of the issue.
Let's check `zydas/zd1211rw` now. Here, in `drivers/net/wireless/zydas/zd1211rw/zd_mac.c`, I see a similar setup on line 454: `first_idx = info->status.rates[0].idx;` Again, it is accessing the *status* rates index. Interesting.
Now, let's look at `realtek/rtlwifi`. Okay, here in `drivers/net/wireless/realtek/rtlwifi/base.c` at line 1265, I see `if (info->control.rates[0].idx == 0 ||`. Aha, it's accessing `info->control.rates[0].idx`, which is different! I need to dig deeper into the code to determine what the proper values should be. I should investigate the `rtl_get_tcb_desc` function, as that's probably related to where this `info->control` data is being set. It could be that the warning is fine, since it could be some initialization happening. I need to understand what this index represents.
|
| 89/2 |
2026/09/04 14:17 |
tool |
read-file |
0m
Args: map[File:drivers/net/wireless/realtek/rtlwifi/base.c FirstLine:1260 LineCount:20]
Results: map[Contents:1260:
1261: /*
1262: *So tcb_desc->hw_rate is just used for
1263: *special data and mgt frames
1264: */
1265: if (info->control.rates[0].idx == 0 ||
1266: ieee80211_is_nullfunc(fc)) {
1267: tcb_desc->use_driver_rate = true;
1268: tcb_desc->ratr_index =
1269: SET_RATE_ID(RATR_INX_WIRELESS_MC);
1270:
1271: tcb_desc->disable_ratefallback = 1;
1272: } else {
1273: /*
1274: *because hw will nerver use hw_rate
1275: *when tcb_desc->use_driver_rate = false
1276: *so we never set highest N rate here,
1277: *and N rate will all be controlled by FW
1278: *when tcb_desc->use_driver_rate = false
1279: */
]
|
| 90/2 |
2026/09/04 14:17 |
llm |
expert |
0m
Model:
Tokens:
input: 63862
output: 45
thoughts: 36
Thoughts: Okay, let me break this down.
**Initial Assessment: Navigating Conditional Logic**
Right, so it's starting with a check: `idx == 0`. Simple enough. If `idx` is zero, we're likely dealing with the "base case" or the initial condition of something. But the interesting part is the `else` condition, where it moves to it, if `idx == -1`. Hmmm, that's throwing a flag. If it *doesn't* equal zero, and *does* equal negative one, where does it go from there? What's the *actual* action triggered by that `else` path? I need to understand that flow. The way this is written is ambiguous, and I need a better understanding of what happens when that 'else' path is taken. Let's see if the rest is relevant.
|
| 91/2 |
2026/09/04 14:17 |
tool |
read-file |
0m
Args: map[File:drivers/net/wireless/realtek/rtlwifi/base.c FirstLine:1270 LineCount:20]
Results: map[Contents:1270:
1271: tcb_desc->disable_ratefallback = 1;
1272: } else {
1273: /*
1274: *because hw will nerver use hw_rate
1275: *when tcb_desc->use_driver_rate = false
1276: *so we never set highest N rate here,
1277: *and N rate will all be controlled by FW
1278: *when tcb_desc->use_driver_rate = false
1279: */
1280: if (sta && sta->deflink.vht_cap.vht_supported) {
1281: tcb_desc->hw_rate =
1282: _rtl_get_vht_highest_n_rate(hw, sta);
1283: } else {
1284: if (sta && sta->deflink.ht_cap.ht_supported) {
1285: tcb_desc->hw_rate =
1286: _rtl_get_highest_n_rate(hw, sta);
1287: } else {
1288: if (rtlmac->mode == WIRELESS_MODE_B) {
1289: tcb_desc->hw_rate =
]
|
| 92/2 |
2026/09/04 14:17 |
llm |
expert |
0m
Model:
Tokens:
input: 64474
output: 48
thoughts: 85
Thoughts: **Digging into the `idx` Usage**
Okay, so I'm trying to understand how this particular piece of code handles rate selection, and the initial observation is that it doesn't seem to use `idx` directly. This is interesting, but not necessarily a dead end. I need to understand the control flow. The next logical step is to see where the value ultimately ends up being used.
Alright, let's explore `intel/iwlegacy` further. Ah, found it! Looks like the `idx` value is indeed assigned within a structure; a quick peek at `drivers/net/wireless/intel/iwlegacy/4965-mac.c:1573` shows `rate_idx = info->control.rates[0].idx;`. This is likely where the relevant `idx` value I was trying to find comes from.
Now, where does it go? The function name `il4965_tx_cmd_build_rate` looks promising. Let's trace it and see how that `rate_idx` influences the rest of the transmission command construction. That should clarify the role of `idx` in the bigger picture.
|
| 93/2 |
2026/09/04 14:17 |
tool |
read-file |
0m
Args: map[File:drivers/net/wireless/intel/iwlegacy/4965-mac.c FirstLine:1570 LineCount:20]
Results: map[Contents:1570: * this band. Also use the lowest supported rate if the stored rate
1571: * idx is invalid.
1572: */
1573: rate_idx = info->control.rates[0].idx;
1574: if ((info->control.rates[0].flags & IEEE80211_TX_RC_MCS) || rate_idx < 0
1575: || rate_idx > RATE_COUNT_LEGACY)
1576: rate_idx = rate_lowest_index(&il->bands[info->band], sta);
1577: /* For 5 GHZ band, remap mac80211 rate indices into driver indices */
1578: if (info->band == NL80211_BAND_5GHZ) {
1579: rate_idx += IL_FIRST_OFDM_RATE;
1580: if (rate_idx > IL_LAST_OFDM_RATE)
1581: rate_idx = IL_LAST_OFDM_RATE;
1582: }
1583: /* Get PLCP rate for tx_cmd->rate_n_flags */
1584: rate_plcp = il_rates[rate_idx].plcp;
1585: /* Zero out flags for this packet */
1586: rate_flags = 0;
1587:
1588: /* Set CCK flag as needed */
1589: if (rate_idx >= IL_FIRST_CCK_RATE && rate_idx <= IL_LAST_CCK_RATE)
]
|
| 94/2 |
2026/09/04 14:17 |
llm |
expert |
0m
Model:
Tokens:
input: 65276
output: 46
thoughts: 88
Thoughts: Okay, let me break this down.
**Safety Check and Potential Concerns Regarding Rate Indexing in iwlwifi/dvm/tx.c**
Alright, so the code has a built-in safety net, right? It checks if `rate_idx` is less than zero and defaults to `rate_lowest_index` if that's the case. That's good. It suggests there's a safeguard against out-of-bounds access or an uninitialized value, ensuring that the system doesn't crash if something goes wonky with the rate selection process. It prevents negative indexing, which is a common source of bugs.
Now, I'm thinking about `intel/iwlwifi/dvm/tx.c`, specifically line 153. That's where we see `rate_idx = info->control.rates[0].idx;`. This is where we're initially assigning the rate index. While the fallback mechanism *exists*, I need to dig into this specific assignment. Is there any way for `info->control.rates[0].idx` to *become* negative in the first place? What are the potential conditions? Is there another code path or other code that could cause issues later? I'm gonna have to review how `info->control.rates` is populated and how the `idx` field is set. This looks like the critical point. Need to ensure the index itself is initialized correctly and, more importantly, doesn't get messed up between initialization and use. This could potentially cause errors with the safeguard, as it is only a last resort to safe execution.
|
| 95/2 |
2026/09/04 14:17 |
tool |
read-file |
0m
Args: map[File:drivers/net/wireless/intel/iwlwifi/dvm/tx.c FirstLine:150 LineCount:20]
Results: map[Contents: 150: * this band. Also use the lowest supported rate if the stored rate
151: * index is invalid.
152: */
153: rate_idx = info->control.rates[0].idx;
154: if (info->control.rates[0].flags & IEEE80211_TX_RC_MCS ||
155: (rate_idx < 0) || (rate_idx > IWL_RATE_COUNT_LEGACY))
156: rate_idx = rate_lowest_index(
157: &priv->nvm_data->bands[info->band], sta);
158: /* For 5 GHZ band, remap mac80211 rate indices into driver indices */
159: if (info->band == NL80211_BAND_5GHZ)
160: rate_idx += IWL_FIRST_OFDM_RATE;
161: /* Get PLCP rate for tx_cmd->rate_n_flags */
162: rate_plcp = iwl_rates[rate_idx].plcp;
163: /* Zero out flags for this packet */
164: rate_flags = 0;
165:
166: /* Set CCK flag as needed */
167: if ((rate_idx >= IWL_FIRST_CCK_RATE) && (rate_idx <= IWL_LAST_CCK_RATE))
168: rate_flags |= RATE_MCS_CCK_MSK;
169:
]
|
| 96/2 |
2026/09/04 14:17 |
llm |
expert |
0m
Model:
Tokens:
input: 66168
output: 46
thoughts: 73
Thoughts: Okay, let me break this down.
**Checking for Negative Rate Indices in iwlwifi DVM Code**
So, I'm taking a look at this code and immediately I see a check for `rate_idx < 0`. That's standard practice, a good safeguard against some kind of index corruption or invalid state, right? It's essential to catch these edge cases and prevent out-of-bounds access. I'm wondering though, what context surrounds this check? Is it just a basic sanity check, or is it part of a larger error-handling strategy?
Then my mind starts running through the code. Ah, the `intel/iwlwifi/dvm/main.c` file. Specifically line 234. I’m already thinking about the surrounding logic. Is this the right place for it? Is the index calculation sound? Maybe the underlying hardware has some quirks that are triggering an unexpected negative index, in which case I’ll be looking deeper at how the rate indices are being generated and used. It really is the devil in the details, isn't it?
|
| 97/2 |
2026/09/04 14:17 |
tool |
read-file |
0m
Args: map[File:drivers/net/wireless/intel/iwlwifi/dvm/main.c FirstLine:230 LineCount:20]
Results: map[Contents: 230: * Let's set up the rate at least somewhat correctly;
231: * it will currently not actually be used by the uCode,
232: * it uses the broadcast station's rate instead.
233: */
234: if (info->control.rates[0].idx < 0 ||
235: info->control.rates[0].flags & IEEE80211_TX_RC_MCS)
236: rate = 0;
237: else
238: rate = info->control.rates[0].idx;
239:
240: priv->mgmt_tx_ant = iwl_toggle_tx_ant(priv, priv->mgmt_tx_ant,
241: priv->nvm_data->valid_tx_ant);
242: rate_flags = iwl_ant_idx_to_flags(priv->mgmt_tx_ant);
243:
244: /* In mac80211, rates for 5 GHz start at 0 */
245: if (info->band == NL80211_BAND_5GHZ)
246: rate += IWL_FIRST_OFDM_RATE;
247: else if (rate >= IWL_FIRST_CCK_RATE && rate <= IWL_LAST_CCK_RATE)
248: rate_flags |= RATE_MCS_CCK_MSK;
249:
]
|
| 98/2 |
2026/09/04 14:17 |
llm |
expert |
0m
Model:
Tokens:
input: 66921
output: 51
thoughts: 142
Thoughts: Okay, let me break this down.
**Initial Assessment: Navigating the Codebase**
First, I see the code checking if `idx < 0`. That's the starting point. I need to understand why this condition is being checked and what negative values represent in this context. It's almost always a good indication that this signifies an "invalid" or "unset" state, or perhaps an error condition.
Then my mind jumps to `marvell/mwl8k.c`. I have a feeling this specific file might be relevant, and there it is: line 1763, where we see `info->status.rates[0].idx = -1;`. Aha! So, in this Marvell wireless driver, `-1` *is* used to initialize a rate index within a `status` structure. That confirms the "unset" or "invalid" theory.
I need more examples, so next I go to `ralink/rt2x00/rt2x00queue.c`. Here it is on line 622: `rate_idx = tx_info->control.rates[0].idx;`. I see the `idx` is being used, so this is another data point. That `rate_idx` variable is being assigned from an index in a rates array within a `tx_info` structure.
Okay, I'm forming a good picture. Negative values for this `idx`, particularly -1 in the cases I've looked at, are likely used as a flag to indicate that a particular rate is invalid or has not been set, at least initially. I'd need to trace the usage of this variable and the implications when the index is negative. That will give me the whole picture.
|
| 99/2 |
2026/09/04 14:17 |
tool |
read-file |
0m
Args: map[File:drivers/net/wireless/ralink/rt2x00/rt2x00queue.c FirstLine:615 LineCount:20]
Results: map[Contents: 615:
616: /*
617: * All information is retrieved from the skb->cb array,
618: * now we should claim ownership of the driver part of that
619: * array, preserving the bitrate index and flags.
620: */
621: tx_info = IEEE80211_SKB_CB(skb);
622: rate_idx = tx_info->control.rates[0].idx;
623: rate_flags = tx_info->control.rates[0].flags;
624: skbdesc = get_skb_frame_desc(skb);
625: memset(skbdesc, 0, sizeof(*skbdesc));
626: skbdesc->tx_rate_idx = rate_idx;
627: skbdesc->tx_rate_flags = rate_flags;
628:
629: if (local)
630: skbdesc->flags |= SKBDESC_NOT_MAC80211;
631:
632: /*
633: * When hardware encryption is supported, and this frame
634: * is to be encrypted, we should strip the IV/EIV data from
]
|
| 100/2 |
2026/09/04 14:17 |
llm |
expert |
0m
Model:
Tokens:
input: 67835
output: 87
thoughts: 35
Thoughts: Okay, here's my take on those thoughts, framed as an expert's inner monologue:
**Investigating the Role of `skbdesc->tx_rate_idx`**
Alright, so I see this piece of code is storing `rate_idx` into `skbdesc->tx_rate_idx`. That's straightforward enough; it's capturing the index of the transmit rate. My immediate question, though, is *where* does this value actually get used? I need to understand its downstream impact to truly grasp its significance. Is it for MAC layer processing? Does it influence power adjustments? Perhaps it's for performance monitoring or statistics gathering later on? I need to trace the usage of `skbdesc->tx_rate_idx` through the code base to build a complete picture of its purpose. Knowing where this index is used will illuminate its role in overall system behavior.
|
| 101/2 |
2026/09/04 14:17 |
tool |
codesearch-find-references |
0m
Args: map[ContextFile:drivers/net/wireless/ralink/rt2x00/rt2x00queue.c IncludeSnippetLines:0 Name:skb_frame_desc::tx_rate_idx SourceTreePrefix:drivers/net/wireless/ralink/rt2x00/]
Results: map[References:<nil> TruncatedOutput:false]
|
| 102/2 |
2026/09/04 14:17 |
llm |
expert |
0m
Model:
Tokens:
input: 68162
output: 40
thoughts: 20
Thoughts: Okay, here's my take on those thoughts, tailored for an expert audience, presented in the first person:
**Investigating `tx_rate_idx` within the `rt2x00` driver suite**
Right, let's dive in. My initial thought is to zero in on `tx_rate_idx` specifically within the `rt2x00` driver family. I know this variable plays a crucial role in transmit rate selection, and I'm probably looking at a potential performance bottleneck, a subtle bug, or perhaps simply trying to understand how rate adaptation is handled at a deeper level. I'm likely interested in how the index maps to actual modulation and coding schemes (MCS), and how the driver updates this based on channel conditions and acknowledgements. I'll need to remember to check how the PHY is configured alongside this index to fully grasp the behavior. Time to crack open the code and start tracing the calls.
|
| 103/2 |
2026/09/04 14:17 |
tool |
grepper |
0m
Args: map[Expression:tx_rate_idx PathPrefix:drivers/net/wireless/ralink/rt2x00/]
Results: map[Output:drivers/net/wireless/ralink/rt2x00/rt2800lib.c=945=static void rt2800_rate_from_status(struct skb_frame_desc *skbdesc,
--
drivers/net/wireless/ralink/rt2x00/rt2800lib.c-973-
drivers/net/wireless/ralink/rt2x00/rt2800lib.c:974: skbdesc->tx_rate_idx = idx;
drivers/net/wireless/ralink/rt2x00/rt2800lib.c-975- skbdesc->tx_rate_flags = flags;
--
drivers/net/wireless/ralink/rt2x00/rt2x00dev.c=305=static void rt2x00lib_fill_tx_status(struct rt2x00_dev *rt2x00dev,
--
drivers/net/wireless/ralink/rt2x00/rt2x00dev.c-313-
drivers/net/wireless/ralink/rt2x00/rt2x00dev.c:314: rate_idx = skbdesc->tx_rate_idx;
drivers/net/wireless/ralink/rt2x00/rt2x00dev.c-315- rate_flags = skbdesc->tx_rate_flags;
--
drivers/net/wireless/ralink/rt2x00/rt2x00queue.c=599=int rt2x00queue_write_tx_frame(struct data_queue *queue, struct sk_buff *skb,
--
drivers/net/wireless/ralink/rt2x00/rt2x00queue.c-625- memset(skbdesc, 0, sizeof(*skbdesc));
drivers/net/wireless/ralink/rt2x00/rt2x00queue.c:626: skbdesc->tx_rate_idx = rate_idx;
drivers/net/wireless/ralink/rt2x00/rt2x00queue.c-627- skbdesc->tx_rate_flags = rate_flags;
--
drivers/net/wireless/ralink/rt2x00/rt2x00queue.h=71=enum skb_frame_desc_flags {
--
drivers/net/wireless/ralink/rt2x00/rt2x00queue.h-86- * @desc_len: Length of the frame descriptor.
drivers/net/wireless/ralink/rt2x00/rt2x00queue.h:87: * @tx_rate_idx: the index of the TX rate, used for TX status reporting
drivers/net/wireless/ralink/rt2x00/rt2x00queue.h-88- * @tx_rate_flags: the TX rate flags, used for TX status reporting
--
drivers/net/wireless/ralink/rt2x00/rt2x00queue.h=96=struct skb_frame_desc {
--
drivers/net/wireless/ralink/rt2x00/rt2x00queue.h-99- u8 desc_len;
drivers/net/wireless/ralink/rt2x00/rt2x00queue.h:100: u8 tx_rate_idx;
drivers/net/wireless/ralink/rt2x00/rt2x00queue.h-101- u8 tx_rate_flags;
]
|
| 104/2 |
2026/09/04 14:17 |
llm |
expert |
0m
Model:
Tokens:
input: 69304
output: 46
thoughts: 76
Thoughts: Okay, here's my interpretation of that thought process, from an expert's perspective:
**TX Status Reporting - No Big Deal (Usually)**
Right, so this code snippet is only being used for reporting the transmit status. That generally means it's pretty benign. We're just trying to figure out if a packet went out successfully or not. As long as it's not manipulating the actual transmit process or hardware directly, it's typically considered a low-risk area. We're just observing, not actively making changes to critical operations. My initial instinct is that it's safe.
However...
Hang on a minute... What's this `realtek/rtw89/core.c` thing? I'm familiar with Realtek wireless drivers, and `core.c` is usually a foundational file. Let me quickly refresh that line of code:
```
drivers/net/wireless/realtek/rtw89/core.c:1234: u8 idx = info->control.rates[0].idx;
```
Okay, now I remember. That line is getting the `idx` value from the transmit information, likely the index for the transmission rate we used to send the packet. It's reading the rate index. This isn't necessarily dangerous in isolation, but I need to dive deeper and see how `idx` is used later on in that file. I need to understand what this index actually *represents* and where it's subsequently used. It's time to dig into the surrounding code and see what they're doing with this `idx` value, just to be sure we're not overlooking something. A seemingly simple read operation could still potentially be problematic if it's coupled with a write operation to shared memory.
|
| 105/2 |
2026/09/04 14:18 |
tool |
read-file |
0m
Args: map[File:drivers/net/wireless/realtek/rtw89/core.c FirstLine:1226 LineCount:20]
Results: map[Contents:1226: static void rtw89_core_tx_update_injection(struct rtw89_dev *rtwdev,
1227: struct rtw89_core_tx_request *tx_req,
1228: struct ieee80211_tx_info *info)
1229: {
1230: const struct rtw89_hw_rate_def *hw_rate = &rtw89_hw_rate[rtwdev->chip->chip_gen];
1231: enum mac80211_rate_control_flags flags = info->control.rates[0].flags;
1232: struct rtw89_tx_desc_info *desc_info = &tx_req->desc_info;
1233: const struct rtw89_chan *chan;
1234: u8 idx = info->control.rates[0].idx;
1235: u8 nss, mcs;
1236:
1237: desc_info->use_rate = true;
1238: desc_info->dis_data_fb = true;
1239:
1240: if (flags & IEEE80211_TX_RC_160_MHZ_WIDTH)
1241: desc_info->data_bw = 3;
1242: else if (flags & IEEE80211_TX_RC_80_MHZ_WIDTH)
1243: desc_info->data_bw = 2;
1244: else if (flags & IEEE80211_TX_RC_40_MHZ_WIDTH)
1245: desc_info->data_bw = 1;
]
|
| 106/2 |
2026/09/04 14:18 |
llm |
expert |
0m
Model:
Tokens:
input: 70264
output: 46
thoughts: 50
Thoughts: Okay, let me think this through.
**Analyzing Potential Integer Overflow**
Hmm, that line... `u8 idx = info->control.rates[0].idx;` ... Right, `idx` is an unsigned 8-bit integer. That's immediately making me think about potential underflow/overflow issues. If `info->control.rates[0].idx` happens to be -1, which is perfectly valid as a signed integer, then it'll get cast to 255 because it's an unsigned 8-bit integer. It's a common trick, but I need to make sure this is what is intended.
The crucial question is: where does `idx` get used? I need to trace its subsequent usage in the code. I need to know if this 255 is an expected value. Is it a flag, or will it cause an out-of-bounds access if it's used as an array index somewhere, or cause an issue when comparing it to a signed variable. I need to know the context to understand if that's a clever hack or a bug waiting to happen.
|
| 107/2 |
2026/09/04 14:18 |
tool |
read-file |
0m
Args: map[File:drivers/net/wireless/realtek/rtw89/core.c FirstLine:1246 LineCount:40]
Results: map[Contents:1246:
1247: if (flags & IEEE80211_TX_RC_SHORT_GI)
1248: desc_info->gi_ltf = 1;
1249:
1250: if (flags & IEEE80211_TX_RC_VHT_MCS) {
1251: nss = umin(idx >> 4, ARRAY_SIZE(hw_rate->vht) - 1);
1252: mcs = idx & 0xf;
1253: desc_info->data_rate = hw_rate->vht[nss] + mcs;
1254: } else if (flags & IEEE80211_TX_RC_MCS) {
1255: desc_info->data_rate = hw_rate->ht + idx;
1256: } else {
1257: chan = rtw89_chan_get(rtwdev, tx_req->rtwvif_link->chanctx_idx);
1258:
1259: desc_info->data_rate = idx + (chan->band_type == RTW89_BAND_2G ?
1260: RTW89_HW_RATE_CCK1 : RTW89_HW_RATE_OFDM6);
1261: }
1262: }
1263:
1264: static void
1265: rtw89_core_tx_update_desc_info(struct rtw89_dev *rtwdev,
1266: struct rtw89_core_tx_request *tx_req)
1267: {
1268: struct rtw89_tx_desc_info *desc_info = &tx_req->desc_info;
1269: struct sk_buff *skb = tx_req->skb;
1270: struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
1271: struct ieee80211_hdr *hdr = (void *)skb->data;
1272: struct rtw89_addr_cam_entry *addr_cam;
1273: enum btc_pkt_type pkt_type;
1274: bool upd_wlan_hdr = false;
1275: bool is_bmc;
1276: u16 seq;
1277:
1278: desc_info->pkt_size = skb->len;
1279:
1280: if (unlikely(tx_req->tx_type == RTW89_CORE_TX_TYPE_FWCMD)) {
1281: rtw89_core_tx_update_h2c_info(rtwdev, tx_req);
1282: return;
1283: }
1284:
1285: tx_req->tx_type = rtw89_core_get_tx_type(rtwdev, skb);
]
|
| 108/2 |
2026/09/04 14:18 |
llm |
expert |
0m
Model:
Tokens:
input: 71406
output: 43
thoughts: 1856
Thoughts: **Analysis of Potential Denial-of-Service Vulnerability**
Okay, let's break this down systematically. My initial thought process revolves around whether this bug can lead to a denial-of-service, a crucial assessment. The code snippet with the `data_rate` manipulation looks like a red herring; the `u8` type ensures no out-of-bounds access directly happens there, and it's ultimately used safely in the hardware descriptor.
The real concern centers on the `cw1200` driver and, more broadly, how `idx` values are handled in rate selection. My initial thought was that the `BUG_ON(rates[0].idx < 0)` in `cw1200` represents a definite DoS if triggered. However, the `cw1200` driver is specific to a particular piece of hardware. Could an unprivileged user trigger this? My assessment is, *likely not*.
The path requires both a `cw1200` device and a user with `CAP_NET_RAW`. While a user namespace could provide `CAP_NET_RAW`, the physical wireless device typically resides in the initial network namespace, unreachable by default. `iw phy phy0 set netns $PID` provides a path to move the device, but that requires `CAP_NET_ADMIN`, which is not generally available to a regular user.
The use of `mac80211_hwsim` introduced another path for exploitation, since it can be created inside a user namespace. The warning with `mac80211_hwsim` wasn't a crash. The `WARN_ON_ONCE` in `ieee80211_get_tx_rate` looked like a potential problem. It seemed like the warning was handled properly, returning `NULL`, which is handled safely by the caller.
So `cw1200` isn't accessible to a non-root user, which means it isn't a DoS unless a user is privileged in the init netns. The `WARN_ON_ONCE` with `mac80211_hwsim` also turns out not to be a DoS because it's properly handled, returning a value that is safely handled. However, this is where it gets interesting...
Thinking more broadly, I need to check every case where `info->control.rates[0].idx` is used as an array index. That's a critical point to consider. The `mac80211` core uses `info->status.rates[0].idx` and `info->control.rates[0].idx` as array indices. The code seems to perform the `idx >= 0` check. The issue is likely not there...
Wait a second. In `net/mac80211/rate.c`, in the function `rate_fixup_ratelist`, I see a critical oversight! The code iterates through the `rates` array and accesses `sband->bitrates[rates[0].idx]` WITHOUT a check. That is the vulnerability. If `rates[0].idx` is `-1`, it will access `sband->bitrates[-1]`, leading to out-of-bounds access.
So, in summary: the primary denial-of-service issue lies not in `cw1200` nor the `WARN_ON_ONCE`, but in a potential out-of-bounds array access within `rate_fixup_ratelist`. This lack of a bounds check is the key vulnerability.
|
| 109/2 |
2026/09/04 14:18 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:net/mac80211/rate.c Name:rate_fixup_ratelist]
Results: map[SourceCode: 631: static void rate_fixup_ratelist(struct ieee80211_vif *vif,
632: struct ieee80211_supported_band *sband,
633: struct ieee80211_tx_info *info,
634: struct ieee80211_tx_rate *rates,
635: int max_rates)
636: {
637: struct ieee80211_rate *rate;
638: bool inval = false;
639: int i;
640:
641: /*
642: * Set up the RTS/CTS rate as the fastest basic rate
643: * that is not faster than the data rate unless there
644: * is no basic rate slower than the data rate, in which
645: * case we pick the slowest basic rate
646: *
647: * XXX: Should this check all retry rates?
648: */
649: if (!(rates[0].flags &
650: (IEEE80211_TX_RC_MCS | IEEE80211_TX_RC_VHT_MCS))) {
651: u32 basic_rates = vif->bss_conf.basic_rates;
652: s8 baserate = basic_rates ? ffs(basic_rates) - 1 : 0;
653:
654: rate = &sband->bitrates[rates[0].idx];
655:
656: for (i = 0; i < sband->n_bitrates; i++) {
657: /* must be a basic rate */
658: if (!(basic_rates & BIT(i)))
659: continue;
660: /* must not be faster than the data rate */
661: if (sband->bitrates[i].bitrate > rate->bitrate)
662: continue;
663: /* maximum */
664: if (sband->bitrates[baserate].bitrate <
665: sband->bitrates[i].bitrate)
666: baserate = i;
667: }
668:
669: info->control.rts_cts_rate_idx = baserate;
670: }
671:
672: for (i = 0; i < max_rates; i++) {
673: /*
674: * make sure there's no valid rate following
675: * an invalid one, just in case drivers don't
676: * take the API seriously to stop at -1.
677: */
678: if (inval) {
679: rates[i].idx = -1;
680: continue;
681: }
682: if (rates[i].idx < 0) {
683: inval = true;
684: continue;
685: }
686:
687: /*
688: * For now assume MCS is already set up correctly, this
689: * needs to be fixed.
690: */
691: if (rates[i].flags & IEEE80211_TX_RC_MCS) {
692: WARN_ON(rates[i].idx > 76);
693:
694: if (!(rates[i].flags & IEEE80211_TX_RC_USE_RTS_CTS) &&
695: info->control.use_cts_prot)
696: rates[i].flags |=
697: IEEE80211_TX_RC_USE_CTS_PROTECT;
698: continue;
699: }
700:
701: if (rates[i].flags & IEEE80211_TX_RC_VHT_MCS) {
702: WARN_ON(ieee80211_rate_get_vht_mcs(&rates[i]) > 9);
703: continue;
704: }
705:
706: /* set up RTS protection if desired */
707: if (info->control.use_rts) {
708: rates[i].flags |= IEEE80211_TX_RC_USE_RTS_CTS;
709: info->control.use_cts_prot = false;
710: }
711:
712: /* RC is busted */
713: if (WARN_ON_ONCE(rates[i].idx >= sband->n_bitrates)) {
714: rates[i].idx = -1;
715: continue;
716: }
717:
718: rate = &sband->bitrates[rates[i].idx];
719:
720: /* set up short preamble */
721: if (info->control.short_preamble &&
722: rate->flags & IEEE80211_RATE_SHORT_PREAMBLE)
723: rates[i].flags |= IEEE80211_TX_RC_USE_SHORT_PREAMBLE;
724:
725: /* set up G protection */
726: if (!(rates[i].flags & IEEE80211_TX_RC_USE_RTS_CTS) &&
727: info->control.use_cts_prot &&
728: rate->flags & IEEE80211_RATE_ERP_G)
729: rates[i].flags |= IEEE80211_TX_RC_USE_CTS_PROTECT;
730: }
731: }
SourceFile:net/mac80211/rate.c]
|
| 110/2 |
2026/09/04 14:18 |
llm |
expert |
0m
Model:
Tokens:
input: 75705
output: 65
thoughts: 171
Thoughts: **Analyzing a Potential Vulnerability in Wireless Rate Handling**
Okay, let's break this down. I'm looking at the `rate_fixup_ratelist` function, specifically this snippet of code. It seems like it's trying to determine the basic rate from a list of available rates. The critical part is checking `rates[0].idx`. If this index happens to be `-1`, it could potentially cause a nasty out-of-bounds read when accessing `sband->bitrates[-1]`. I understand that's a dangerous situation that I need to investigate. I need to be sure where `rate_fixup_ratelist` is being called and under what circumstances the `rates[0].idx` can be assigned `-1`. Clearly, that's the vulnerability point. This is the critical next step.
|
| 111/2 |
2026/09/04 14:18 |
tool |
codesearch-find-references |
0m
Args: map[ContextFile:net/mac80211/rate.c IncludeSnippetLines:0 Name:rate_fixup_ratelist SourceTreePrefix:net/mac80211/]
Results: map[References:[map[ReferenceKind:calls ReferencingEntityKind:function ReferencingEntityName:ieee80211_get_tx_rates SourceFile:net/mac80211/rate.c SourceLine:915]] TruncatedOutput:false]
|
| 112/2 |
2026/09/04 14:18 |
llm |
expert |
0m
Model:
Tokens:
input: 76198
output: 49
thoughts: 20
Thoughts: Okay, here's my interpretation of that thought process, assuming I'm already deep in the weeds of wireless networking code and know what `ieee80211_get_tx_rates` is all about.
**Examining the Tx Rate Selection**
Right, so I'm thinking about how the transmitter rates are being determined in the 802.11 stack. The critical function is `ieee80211_get_tx_rates`, and the fact that it's being *called* is the important takeaway here. This means the system is actively in the process of deciding which transmission rates to use for sending data. I'm likely debugging a rate selection issue or working on performance enhancements, and this function call is the key to understanding that. So, I need to trace this specific function call.
|
| 113/2 |
2026/09/04 14:18 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:net/mac80211/rate.c Name:ieee80211_get_tx_rates]
Results: map[SourceCode: 882: void ieee80211_get_tx_rates(struct ieee80211_vif *vif,
883: struct ieee80211_sta *sta,
884: struct sk_buff *skb,
885: struct ieee80211_tx_rate *dest,
886: int max_rates)
887: {
888: struct ieee80211_sub_if_data *sdata;
889: struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
890: struct ieee80211_supported_band *sband;
891: u32 mask = ~0;
892:
893: rate_control_fill_sta_table(sta, info, dest, max_rates);
894:
895: if (!vif)
896: return;
897:
898: sdata = vif_to_sdata(vif);
899: if (info->band >= NUM_NL80211_BANDS)
900: return;
901:
902: sband = sdata->local->hw.wiphy->bands[info->band];
903:
904: if (ieee80211_is_tx_data(skb))
905: rate_control_apply_mask(sdata, sta, sband, dest, max_rates);
906:
907: if (!(info->control.flags & IEEE80211_TX_CTRL_DONT_USE_RATE_MASK))
908: mask = sdata->rc_rateidx_mask[info->band];
909:
910: if (dest[0].idx < 0)
911: __rate_control_send_low(&sdata->local->hw, sband, sta, info,
912: mask);
913:
914: if (sta)
915: rate_fixup_ratelist(vif, sband, info, dest, max_rates);
916: }
SourceFile:net/mac80211/rate.c]
|
| 114/2 |
2026/09/04 14:18 |
llm |
expert |
0m
Model:
Tokens:
input: 77098
output: 44
thoughts: 56
Thoughts: Okay, here's my interpretation of that thought process, assuming I'm deep in the weeds of 802.11 rate control:
**Investigating a Suspect Rate Control Path**
Right, *aha!* `ieee80211_get_tx_rates`... that's the function responsible for determining the transmission rates, and I see it's doing a check on `dest[0].idx < 0`. That index being negative immediately flags something interesting. *And, look at this*, a negative index triggers a call to `__rate_control_send_low`. Now we're getting somewhere. I need to dig into `__rate_control_send_low`. What's happening there? Is this where we're falling into a default or emergency rate selection path? Or is this a legitimate, under-the-hood operation that I've just never deeply investigated? Time to see what's going on *inside* that function. Let's see how it works.
|
| 115/2 |
2026/09/04 14:18 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:net/mac80211/rate.c Name:__rate_control_send_low]
Results: map[SourceCode: 366: static void __rate_control_send_low(struct ieee80211_hw *hw,
367: struct ieee80211_supported_band *sband,
368: struct ieee80211_sta *sta,
369: struct ieee80211_tx_info *info,
370: u32 rate_mask)
371: {
372: u32 rate_flags = 0;
373: int i;
374:
375: if (sband->band == NL80211_BAND_S1GHZ) {
376: info->control.rates[0].flags |= IEEE80211_TX_RC_S1G_MCS;
377: info->control.rates[0].idx = 0;
378: return;
379: }
380:
381: if ((sband->band == NL80211_BAND_2GHZ) &&
382: (info->flags & IEEE80211_TX_CTL_NO_CCK_RATE))
383: rate_flags |= IEEE80211_RATE_ERP_G;
384:
385: info->control.rates[0].idx = 0;
386: for (i = 0; i < sband->n_bitrates; i++) {
387: if (!(rate_mask & BIT(i)))
388: continue;
389:
390: if ((rate_flags & sband->bitrates[i].flags) != rate_flags)
391: continue;
392:
393: if (!rate_supported(sta, sband->band, i))
394: continue;
395:
396: info->control.rates[0].idx = i;
397: break;
398: }
399: WARN_ONCE(i == sband->n_bitrates,
400: "no supported rates for sta %pM (0x%x, band %d) in rate_mask 0x%x with flags 0x%x\n",
401: sta ? sta->addr : NULL,
402: sta ? sta->deflink.supp_rates[sband->band] : -1,
403: sband->band,
404: rate_mask, rate_flags);
405:
406: info->control.rates[0].count =
407: (info->flags & IEEE80211_TX_CTL_NO_ACK) ?
408: 1 : hw->max_rate_tries;
409:
410: info->control.skip_table = 1;
411: }
SourceFile:net/mac80211/rate.c]
|
| 116/2 |
2026/09/04 14:18 |
llm |
expert |
0m
Model:
Tokens:
input: 78245
output: 47
thoughts: 633
Thoughts: **Analyzing a Potential Out-of-Bounds Read in Rate Control**
Okay, let's break this down. I'm looking at this rate control mechanism and something feels off. It starts with `__rate_control_send_low` setting `info->control.rates[0].idx` to a valid index, or at least it should. Then `ieee80211_get_tx_rates` gets called, passing `dest` (which is `rates`, got it). Hmm, hold on a second... `__rate_control_send_low` is modifying `info->control.rates[0].idx`, not `dest[0].idx` directly. Interesting...
Okay, re-examining `ieee80211_get_tx_rates`: If `dest[0].idx < 0`, it calls `__rate_control_send_low`, which, as mentioned, modifies that *other* index. But, after the call to `__rate_control_send_low`, `dest[0].idx` is *still* negative! It hasn't been updated! That means `rate_fixup_ratelist` is called with `dest` with a negative index.
Then, inside `rate_fixup_ratelist`, I see the critical line: `rate = &sband->bitrates[rates[0].idx];`. Here, `rates` is that original `dest` pointer, so it's `dest[0].idx` that's negative. This will result in accessing `sband->bitrates[-1]`! Boom. Out-of-bounds read!
And it gets worse. Then the code proceeds to read `rate->bitrate`, which translates to `sband->bitrates[-1].bitrate` - another out-of-bounds read!
So, we've got two consecutive out-of-bounds reads. The question now is: is it exploitable? We need to understand what's in that `sband->bitrates` array. `sband` is a `struct ieee80211_supported_band`, so I should go check that out to fully understand what data it contains.
|
| 117/2 |
2026/09/04 14:19 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:include/net/mac80211.h Name:ieee80211_supported_band]
Results: map[SourceCode: 561: /**
562: * struct ieee80211_supported_band - frequency band definition
563: *
564: * This structure describes a frequency band a wiphy
565: * is able to operate in.
566: *
567: * @channels: Array of channels the hardware can operate with
568: * in this band.
569: * @band: the band this structure represents
570: * @n_channels: Number of channels in @channels
571: * @bitrates: Array of bitrates the hardware can operate with
572: * in this band. Must be sorted to give a valid "supported
573: * rates" IE, i.e. CCK rates first, then OFDM.
574: * @n_bitrates: Number of bitrates in @bitrates
575: * @ht_cap: HT capabilities in this band
576: * @vht_cap: VHT capabilities in this band
577: * @s1g_cap: S1G capabilities in this band
578: * @edmg_cap: EDMG capabilities in this band
579: * @s1g_cap: S1G capabilities in this band (S1G band only, of course)
580: * @n_iftype_data: number of iftype data entries
581: * @iftype_data: interface type data entries. Note that the bits in
582: * @types_mask inside this structure cannot overlap (i.e. only
583: * one occurrence of each type is allowed across all instances of
584: * iftype_data).
585: */
586: struct ieee80211_supported_band {
587: struct ieee80211_channel *channels;
588: struct ieee80211_rate *bitrates;
589: enum nl80211_band band;
590: int n_channels;
591: int n_bitrates;
592: struct ieee80211_sta_ht_cap ht_cap;
593: struct ieee80211_sta_vht_cap vht_cap;
594: struct ieee80211_sta_s1g_cap s1g_cap;
595: struct ieee80211_edmg edmg_cap;
596: u16 n_iftype_data;
597: const struct ieee80211_sband_iftype_data __iftd *iftype_data;
598: };
SourceFile:include/net/cfg80211.h]
|
| 118/2 |
2026/09/04 14:19 |
llm |
expert |
0m
Model:
Tokens:
input: 80163
output: 93
thoughts: 89
Thoughts: Here's my thought process, summarized as if I were considering this myself:
**Investigating a Potential Memory Access Violation**
Okay, hold on a second. I'm looking at this code and something is immediately jumping out at me. The variable `bitrates` is declared as a pointer: `struct ieee80211_rate *bitrates;`. My experience tells me that it is likely a pointer to an array of structures. This means the compiler *isn't* doing any bounds checking on accesses via that pointer.
If that's the case, then this line: `sband->bitrates[-1]` is immediately concerning. That index is *negative*! It's accessing memory *before* the intended start of the `bitrates` array! That's a classic off-by-one or buffer-overrun scenario and it's almost certainly going to cause problems. The location being read from should be checked.
Now, the `bitrates` array itself is probably allocated dynamically, or maybe even statically defined within the driver somewhere. Let's dig deeper and verify exactly how it's being handled in the `mac80211_hwsim` driver. I need to trace back where the `bitrates` pointer is actually assigned and see how large the corresponding array is expected to be. This could be a very serious bug that needs immediate attention. I hope it is isolated, because this could potentially compromise the stability of the system.
|
| 119/2 |
2026/09/04 14:19 |
tool |
codesearch-find-references |
0m
Args: map[ContextFile:drivers/net/wireless/virtual/mac80211_hwsim_main.c IncludeSnippetLines:0 Name:ieee80211_supported_band::bitrates SourceTreePrefix:drivers/net/wireless/virtual/mac80211_hwsim_main.c]
Results: map[References:[map[ReferenceKind:writes ReferencingEntityKind:function ReferencingEntityName:mac80211_hwsim_new_radio SourceFile:drivers/net/wireless/virtual/mac80211_hwsim_main.c SourceLine:6001] map[ReferenceKind:writes ReferencingEntityKind:function ReferencingEntityName:mac80211_hwsim_new_radio SourceFile:drivers/net/wireless/virtual/mac80211_hwsim_main.c SourceLine:6007] map[ReferenceKind:writes ReferencingEntityKind:function ReferencingEntityName:mac80211_hwsim_new_radio SourceFile:drivers/net/wireless/virtual/mac80211_hwsim_main.c SourceLine:6028]] TruncatedOutput:false]
|
| 120/2 |
2026/09/04 14:19 |
llm |
expert |
0m
Model:
Tokens:
input: 80892
output: 58
thoughts: 19
Thoughts: Here's my attempt at summarizing the thought process, tailored for an expert audience:
**Analyzing `mac80211_hwsim_new_radio`**
Alright, let's dive into `mac80211_hwsim_new_radio`. This function is fundamental, obviously. It's the entry point for creating a new simulated radio within the mac80211 hardware simulation environment, right? So, what's the core logic here? I immediately start thinking about what it needs to initialize: the basic data structures – the `struct ieee80211_hw` itself, the associated driver data (`hwsim_priv` most likely), and probably some initial configuration based on provided parameters, such as the number of supported channels, rates, and capabilities.
I'd expect some allocation using `kzalloc` or similar for the private data and the `ieee80211_hw` struct. Then, it'll need to populate the hardware description – the `hw->wiphy` field probably needs to be set up with a new `wiphy` instance. I'm mentally checking what flags are appropriate for the simulated hardware in `ieee80211_hw_set`. Thinking about things like `IEEE80211_HW_SUPPORTS_PS`, `IEEE80211_HW_REPORTS_TX_ACK_STATUS`, etc. Gotta make sure those capabilities are correctly reflected in the simulation. I'd need to consider how to handle the virtual RF front-end - is it an abstraction over a phy/rate/channel model or something simpler?
The function must also be setting up the `ieee80211_ops` structure with the necessary callbacks for simulating various 802.11 operations: TX, RX, channel switching, setting key material and so on. Those are absolutely crucial, because without them, the simulation wouldn't be able to do anything. Gotta check what the specific implementations in hwsim are doing, it's probably using its own private structures to store the data and configuration.
I need to confirm if there is any initial configuration passed to this function or if default parameters are applied. I'll need to identify those parameters and check if they are being correctly processed within this function. The return value? Should be a pointer to the `ieee80211_hw` struct. If any allocation fails, or if the initialization goes sideways, a null pointer or an error code should be returned, hopefully with detailed error messages. And finally, I must be missing something as this function does not initialize the interface...
So yeah, a good chunk of that's about setting up the virtual hardware and the callbacks that make it function like a real radio, within the mac80211 framework. Important function. I'm going to dig deeper to see exactly how all this unfolds.
|
| 121/2 |
2026/09/04 14:19 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/net/wireless/virtual/mac80211_hwsim_main.c Name:mac80211_hwsim_new_radio]
Results: map[SourceCode:5674: static int mac80211_hwsim_new_radio(struct genl_info *info,
5675: struct hwsim_new_radio_params *param)
5676: {
5677: int err;
5678: u8 addr[ETH_ALEN];
5679: struct mac80211_hwsim_data *data;
5680: struct ieee80211_hw *hw;
5681: enum nl80211_band band;
5682: const struct ieee80211_ops *ops = &mac80211_hwsim_ops;
5683: struct net *net;
5684: int idx, i;
5685: int n_limits = 0;
5686: int n_bands = 0;
5687:
5688: if (WARN_ON(param->channels > 1 && !param->use_chanctx))
5689: return -EINVAL;
5690:
5691: spin_lock_bh(&hwsim_radio_lock);
5692: idx = hwsim_radio_idx++;
5693: spin_unlock_bh(&hwsim_radio_lock);
5694:
5695: if (param->mlo)
5696: ops = &mac80211_hwsim_mlo_ops;
5697: else if (param->use_chanctx)
5698: ops = &mac80211_hwsim_mchan_ops;
5699: hw = ieee80211_alloc_hw_nm(sizeof(*data), ops, param->hwname);
5700: if (!hw) {
5701: pr_debug("mac80211_hwsim: ieee80211_alloc_hw failed\n");
5702: err = -ENOMEM;
5703: goto failed;
5704: }
5705:
5706: /* ieee80211_alloc_hw_nm may have used a default name */
5707: param->hwname = wiphy_name(hw->wiphy);
5708:
5709: if (info)
5710: net = genl_info_net(info);
5711: else
5712: net = &init_net;
5713: wiphy_net_set(hw->wiphy, net);
5714:
5715: data = hw->priv;
5716: data->hw = hw;
5717:
5718: data->dev = device_create(&hwsim_class, NULL, 0, hw, "hwsim%d", idx);
5719: if (IS_ERR(data->dev)) {
5720: printk(KERN_DEBUG
5721: "mac80211_hwsim: device_create failed (%ld)\n",
5722: PTR_ERR(data->dev));
5723: err = -ENOMEM;
5724: goto failed_drvdata;
5725: }
5726: data->dev->driver = &mac80211_hwsim_driver.driver;
5727: err = device_bind_driver(data->dev);
5728: if (err != 0) {
5729: pr_debug("mac80211_hwsim: device_bind_driver failed (%d)\n",
5730: err);
5731: goto failed_bind;
5732: }
5733:
5734: skb_queue_head_init(&data->pending);
5735:
5736: SET_IEEE80211_DEV(hw, data->dev);
5737: if (!param->perm_addr) {
5738: eth_zero_addr(addr);
5739: addr[0] = 0x02;
5740: addr[3] = idx >> 8;
5741: addr[4] = idx;
5742: memcpy(data->addresses[0].addr, addr, ETH_ALEN);
5743: /* Why need here second address ? */
5744: memcpy(data->addresses[1].addr, addr, ETH_ALEN);
5745: data->addresses[1].addr[0] |= 0x40;
5746: memcpy(data->addresses[2].addr, addr, ETH_ALEN);
5747: data->addresses[2].addr[0] |= 0x50;
5748:
5749: hw->wiphy->n_addresses = 3;
5750: hw->wiphy->addresses = data->addresses;
5751: /* possible address clash is checked at hash table insertion */
5752: } else {
5753: memcpy(data->addresses[0].addr, param->perm_addr, ETH_ALEN);
5754: /* compatibility with automatically generated mac addr */
5755: memcpy(data->addresses[1].addr, param->perm_addr, ETH_ALEN);
5756: memcpy(data->addresses[2].addr, param->perm_addr, ETH_ALEN);
5757: hw->wiphy->n_addresses = 3;
5758: hw->wiphy->addresses = data->addresses;
5759: }
5760:
5761: data->channels = param->channels;
5762: data->use_chanctx = param->use_chanctx;
5763: data->idx = idx;
5764: data->destroy_on_close = param->destroy_on_close;
5765: if (info)
5766: data->portid = info->snd_portid;
5767:
5768: /* setup interface limits, only on interface types we support */
5769: if (param->iftypes & BIT(NL80211_IFTYPE_ADHOC)) {
5770: data->if_limits[n_limits].max = 1;
5771: data->if_limits[n_limits].types = BIT(NL80211_IFTYPE_ADHOC);
5772: n_limits++;
5773: }
5774:
5775: if (param->iftypes & HWSIM_DEFAULT_IF_LIMIT) {
5776: data->if_limits[n_limits].max = 2048;
5777: /*
5778: * For this case, we may only support a subset of
5779: * HWSIM_DEFAULT_IF_LIMIT, therefore we only want to add the
5780: * bits that both param->iftype & HWSIM_DEFAULT_IF_LIMIT have.
5781: */
5782: data->if_limits[n_limits].types =
5783: HWSIM_DEFAULT_IF_LIMIT & param->iftypes;
5784: n_limits++;
5785: }
5786:
5787: if (param->iftypes & BIT(NL80211_IFTYPE_P2P_DEVICE)) {
5788: data->if_limits[n_limits].max = 1;
5789: data->if_limits[n_limits].types =
5790: BIT(NL80211_IFTYPE_P2P_DEVICE);
5791: n_limits++;
5792: }
5793:
5794: if (param->iftypes & BIT(NL80211_IFTYPE_NAN)) {
5795: data->if_limits[n_limits].max = 1;
5796: data->if_limits[n_limits].types = BIT(NL80211_IFTYPE_NAN);
5797: n_limits++;
5798:
5799: hw->wiphy->nan_supported_bands = BIT(NL80211_BAND_2GHZ) |
5800: BIT(NL80211_BAND_5GHZ);
5801:
5802: hw->wiphy->nan_capa.flags = WIPHY_NAN_FLAGS_CONFIGURABLE_SYNC |
5803: WIPHY_NAN_FLAGS_USERSPACE_DE;
5804: hw->wiphy->nan_capa.op_mode = NAN_OP_MODE_PHY_MODE_MASK |
5805: NAN_OP_MODE_80P80MHZ |
5806: NAN_OP_MODE_160MHZ;
5807:
5808: hw->wiphy->nan_capa.n_antennas = 0x22;
5809: hw->wiphy->nan_capa.max_channel_switch_time = 0;
5810:
5811: wiphy_ext_feature_set(hw->wiphy,
5812: NL80211_EXT_FEATURE_SECURE_NAN);
5813:
5814: hrtimer_setup(&data->nan.slot_timer,
5815: mac80211_hwsim_nan_slot_timer,
5816: CLOCK_BOOTTIME, HRTIMER_MODE_ABS_SOFT);
5817: hrtimer_setup(&data->nan.resume_txqs_timer,
5818: mac80211_hwsim_nan_resume_txqs_timer,
5819: CLOCK_BOOTTIME, HRTIMER_MODE_ABS_SOFT);
5820: hrtimer_setup(&data->nan.discovery_beacon_timer,
5821: mac80211_hwsim_nan_discovery_beacon_timer,
5822: CLOCK_BOOTTIME, HRTIMER_MODE_ABS_SOFT);
5823:
5824: spin_lock_init(&data->nan.state_lock);
5825: }
5826:
5827: if (param->iftypes & BIT(NL80211_IFTYPE_NAN_DATA)) {
5828: data->if_limits[n_limits].max = 2;
5829: data->if_limits[n_limits].types = BIT(NL80211_IFTYPE_NAN_DATA);
5830: n_limits++;
5831:
5832: hw->wiphy->nan_capa.phy.ht = hwsim_nan_ht_cap;
5833: hw->wiphy->nan_capa.phy.vht = hwsim_nan_vht_cap;
5834: hw->wiphy->nan_capa.phy.he = hwsim_nan_he_cap;
5835:
5836: /*
5837: * NAN switches between bands/channels per its schedule,
5838: * so mac80211 rate control can't work here.
5839: */
5840: ieee80211_hw_set(hw, HAS_RATE_CONTROL);
5841: }
5842:
5843: data->if_combination.radar_detect_widths =
5844: BIT(NL80211_CHAN_WIDTH_5) |
5845: BIT(NL80211_CHAN_WIDTH_10) |
5846: BIT(NL80211_CHAN_WIDTH_20_NOHT) |
5847: BIT(NL80211_CHAN_WIDTH_20) |
5848: BIT(NL80211_CHAN_WIDTH_40) |
5849: BIT(NL80211_CHAN_WIDTH_80) |
5850: BIT(NL80211_CHAN_WIDTH_160);
5851:
5852: if (data->use_chanctx) {
5853: hw->wiphy->max_scan_ssids = 255;
5854: hw->wiphy->max_scan_ie_len = IEEE80211_MAX_DATA_LEN;
5855: hw->wiphy->max_remain_on_channel_duration = 1000;
5856: data->if_combination.num_different_channels = data->channels;
5857: } else {
5858: data->if_combination.num_different_channels = 1;
5859: }
5860:
5861: if (!n_limits) {
5862: err = -EINVAL;
5863: goto failed_hw;
5864: }
5865:
5866: data->if_combination.max_interfaces = 0;
5867: for (i = 0; i < n_limits; i++)
5868: data->if_combination.max_interfaces +=
5869: data->if_limits[i].max;
5870:
5871: data->if_combination.n_limits = n_limits;
5872: data->if_combination.limits = data->if_limits;
5873:
5874: /*
5875: * If we actually were asked to support combinations,
5876: * advertise them - if there's only a single thing like
5877: * only IBSS then don't advertise it as combinations.
5878: */
5879: if (data->if_combination.max_interfaces > 1) {
5880: hw->wiphy->iface_combinations = &data->if_combination;
5881: hw->wiphy->n_iface_combinations = 1;
5882: }
5883:
5884: if (param->ciphers) {
5885: memcpy(data->ciphers, param->ciphers,
5886: param->n_ciphers * sizeof(u32));
5887: hw->wiphy->cipher_suites = data->ciphers;
5888: hw->wiphy->n_cipher_suites = param->n_ciphers;
5889: }
5890:
5891: hw->wiphy->mbssid_max_interfaces = 8;
5892: hw->wiphy->ema_max_profile_periodicity = 3;
5893:
5894: spin_lock_init(&data->tsf_offset_lock);
5895:
5896: data->rx_rssi = DEFAULT_RX_RSSI;
5897:
5898: INIT_DELAYED_WORK(&data->roc_start, hw_roc_start);
5899: INIT_DELAYED_WORK(&data->roc_done, hw_roc_done);
5900: INIT_DELAYED_WORK(&data->hw_scan, hw_scan_work);
5901:
5902: hw->queues = 5;
5903: hw->offchannel_tx_hw_queue = 4;
5904:
5905: ieee80211_hw_set(hw, SUPPORT_FAST_XMIT);
5906: ieee80211_hw_set(hw, CHANCTX_STA_CSA);
5907: ieee80211_hw_set(hw, SUPPORTS_HT_CCK_RATES);
5908: ieee80211_hw_set(hw, QUEUE_CONTROL);
5909: ieee80211_hw_set(hw, WANT_MONITOR_VIF);
5910: ieee80211_hw_set(hw, AMPDU_AGGREGATION);
5911: ieee80211_hw_set(hw, MFP_CAPABLE);
5912: ieee80211_hw_set(hw, SIGNAL_DBM);
5913: ieee80211_hw_set(hw, SUPPORTS_PS);
5914: ieee80211_hw_set(hw, REPORTS_TX_ACK_STATUS);
5915: ieee80211_hw_set(hw, TDLS_WIDER_BW);
5916: ieee80211_hw_set(hw, SUPPORTS_MULTI_BSSID);
5917: ieee80211_hw_set(hw, STRICT);
5918: ieee80211_hw_set(hw, BUFF_MMPDU_TXQ);
5919: ieee80211_hw_set(hw, STA_MMPDU_TXQ);
5920:
5921: if (param->mlo) {
5922: hw->wiphy->flags |= WIPHY_FLAG_SUPPORTS_MLO;
5923: ieee80211_hw_set(hw, HAS_RATE_CONTROL);
5924: ieee80211_hw_set(hw, SUPPORTS_DYNAMIC_PS);
5925: ieee80211_hw_set(hw, CONNECTION_MONITOR);
5926: ieee80211_hw_set(hw, AP_LINK_PS);
5927:
5928: hw->wiphy->iftype_ext_capab = mac80211_hwsim_iftypes_ext_capa;
5929: hw->wiphy->num_iftype_ext_capab =
5930: ARRAY_SIZE(mac80211_hwsim_iftypes_ext_capa);
5931: } else {
5932: ieee80211_hw_set(hw, HOST_BROADCAST_PS_BUFFERING);
5933: ieee80211_hw_set(hw, PS_NULLFUNC_STACK);
5934: if (rctbl)
5935: ieee80211_hw_set(hw, SUPPORTS_RC_TABLE);
5936: }
5937:
5938: hw->wiphy->flags &= ~WIPHY_FLAG_PS_ON_BY_DEFAULT;
5939: hw->wiphy->flags |= WIPHY_FLAG_SUPPORTS_TDLS |
5940: WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL |
5941: WIPHY_FLAG_AP_UAPSD |
5942: WIPHY_FLAG_HAS_CHANNEL_SWITCH;
5943: hw->wiphy->flags |= WIPHY_FLAG_IBSS_RSN;
5944: hw->wiphy->features |= NL80211_FEATURE_ACTIVE_MONITOR |
5945: NL80211_FEATURE_AP_MODE_CHAN_WIDTH_CHANGE |
5946: NL80211_FEATURE_STATIC_SMPS |
5947: NL80211_FEATURE_DYNAMIC_SMPS |
5948: NL80211_FEATURE_SCAN_RANDOM_MAC_ADDR |
5949: NL80211_FEATURE_AP_SCAN;
5950: wiphy_ext_feature_set(hw->wiphy, NL80211_EXT_FEATURE_VHT_IBSS);
5951: wiphy_ext_feature_set(hw->wiphy, NL80211_EXT_FEATURE_BEACON_PROTECTION);
5952: wiphy_ext_feature_set(hw->wiphy,
5953: NL80211_EXT_FEATURE_MULTICAST_REGISTRATIONS);
5954: wiphy_ext_feature_set(hw->wiphy,
5955: NL80211_EXT_FEATURE_BEACON_RATE_LEGACY);
5956: wiphy_ext_feature_set(hw->wiphy, NL80211_EXT_FEATURE_ENABLE_FTM_RESPONDER);
5957:
5958: wiphy_ext_feature_set(hw->wiphy,
5959: NL80211_EXT_FEATURE_SCAN_MIN_PREQ_CONTENT);
5960: wiphy_ext_feature_set(hw->wiphy,
5961: NL80211_EXT_FEATURE_BSS_COLOR);
5962: wiphy_ext_feature_set(hw->wiphy,
5963: NL80211_EXT_FEATURE_SPP_AMSDU_SUPPORT);
5964: wiphy_ext_feature_set(hw->wiphy,
5965: NL80211_EXT_FEATURE_CAN_REPLACE_PTK0);
5966: wiphy_ext_feature_set(hw->wiphy,
5967: NL80211_EXT_FEATURE_EXT_KEY_ID);
5968: wiphy_ext_feature_set(hw->wiphy,
5969: NL80211_EXT_FEATURE_ASSOC_FRAME_ENCRYPTION);
5970:
5971: hw->wiphy->interface_modes = param->iftypes;
5972:
5973: /* ask mac80211 to reserve space for magic */
5974: hw->vif_data_size = sizeof(struct hwsim_vif_priv);
5975: hw->sta_data_size = sizeof(struct hwsim_sta_priv);
5976: hw->chanctx_data_size = sizeof(struct hwsim_chanctx_priv);
5977: hw->txq_data_size = 0;
5978:
5979: memcpy(data->channels_2ghz, hwsim_channels_2ghz,
5980: sizeof(hwsim_channels_2ghz));
5981: memcpy(data->channels_5ghz, hwsim_channels_5ghz,
5982: sizeof(hwsim_channels_5ghz));
5983: memcpy(data->channels_6ghz, hwsim_channels_6ghz,
5984: sizeof(hwsim_channels_6ghz));
5985: memcpy(data->channels_s1g, hwsim_channels_s1g,
5986: sizeof(hwsim_channels_s1g));
5987: memcpy(data->rates, hwsim_rates, sizeof(hwsim_rates));
5988:
5989: for (band = NL80211_BAND_2GHZ; band < NUM_NL80211_BANDS; band++) {
5990: struct ieee80211_supported_band *sband = &data->bands[band];
5991: struct wiphy_radio_freq_range *radio_range;
5992: const struct ieee80211_channel *c;
5993: struct wiphy_radio *radio;
5994:
5995: sband->band = band;
5996:
5997: switch (band) {
5998: case NL80211_BAND_2GHZ:
5999: sband->channels = data->channels_2ghz;
6000: sband->n_channels = ARRAY_SIZE(hwsim_channels_2ghz);
6001: sband->bitrates = data->rates;
6002: sband->n_bitrates = ARRAY_SIZE(hwsim_rates);
6003: break;
6004: case NL80211_BAND_5GHZ:
6005: sband->channels = data->channels_5ghz;
6006: sband->n_channels = ARRAY_SIZE(hwsim_channels_5ghz);
6007: sband->bitrates = data->rates + 4;
6008: sband->n_bitrates = ARRAY_SIZE(hwsim_rates) - 4;
6009:
6010: sband->vht_cap.vht_supported = true;
6011: sband->vht_cap.cap =
6012: IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_11454 |
6013: IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ |
6014: IEEE80211_VHT_CAP_RXLDPC |
6015: IEEE80211_VHT_CAP_SHORT_GI_80 |
6016: IEEE80211_VHT_CAP_SHORT_GI_160 |
6017: IEEE80211_VHT_CAP_TXSTBC |
6018: IEEE80211_VHT_CAP_RXSTBC_4 |
6019: IEEE80211_VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK;
6020: sband->vht_cap.vht_mcs.rx_mcs_map =
6021: cpu_to_le16(HWSIM_VHT_MCS_MAP);
6022: sband->vht_cap.vht_mcs.tx_mcs_map =
6023: sband->vht_cap.vht_mcs.rx_mcs_map;
6024: break;
6025: case NL80211_BAND_6GHZ:
6026: sband->channels = data->channels_6ghz;
6027: sband->n_channels = ARRAY_SIZE(hwsim_channels_6ghz);
6028: sband->bitrates = data->rates + 4;
6029: sband->n_bitrates = ARRAY_SIZE(hwsim_rates) - 4;
6030: break;
6031: case NL80211_BAND_S1GHZ:
6032: memcpy(&sband->s1g_cap, &hwsim_s1g_cap,
6033: sizeof(sband->s1g_cap));
6034: sband->channels = data->channels_s1g;
6035: sband->n_channels = ARRAY_SIZE(hwsim_channels_s1g);
6036: break;
6037: default:
6038: continue;
6039: }
6040:
6041: if (band != NL80211_BAND_6GHZ){
6042: sband->ht_cap.ht_supported = true;
6043: sband->ht_cap.cap = IEEE80211_HT_CAP_SUP_WIDTH_20_40 |
6044: IEEE80211_HT_CAP_GRN_FLD |
6045: IEEE80211_HT_CAP_SGI_20 |
6046: IEEE80211_HT_CAP_SGI_40 |
6047: IEEE80211_HT_CAP_DSSSCCK40 |
6048: IEEE80211_HT_CAP_TX_STBC |
6049: IEEE80211_HT_CAP_RX_STBC;
6050: sband->ht_cap.ampdu_factor = 0x3;
6051: sband->ht_cap.ampdu_density = 0x6;
6052: memset(&sband->ht_cap.mcs, 0,
6053: sizeof(sband->ht_cap.mcs));
6054: sband->ht_cap.mcs.rx_mask[0] = 0xff;
6055: sband->ht_cap.mcs.rx_mask[1] = 0xff;
6056: sband->ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED;
6057: }
6058:
6059: mac80211_hwsim_sband_capab(sband);
6060:
6061: hw->wiphy->bands[band] = sband;
6062:
6063: if (!param->multi_radio)
6064: continue;
6065:
6066: c = sband->channels;
6067: radio_range = &data->radio_range[n_bands];
6068: radio_range->start_freq = ieee80211_channel_to_khz(c) - 10000;
6069:
6070: c += sband->n_channels - 1;
6071: radio_range->end_freq = ieee80211_channel_to_khz(c) + 10000;
6072:
6073: radio = &data->radio[n_bands++];
6074: radio->freq_range = radio_range;
6075: radio->n_freq_range = 1;
6076: radio->iface_combinations = &data->if_combination_radio;
6077: radio->n_iface_combinations = 1;
6078: }
6079:
6080: if (param->multi_radio) {
6081: hw->wiphy->radio = data->radio;
6082: hw->wiphy->n_radio = n_bands;
6083:
6084: memcpy(&data->if_combination_radio, &data->if_combination,
6085: sizeof(data->if_combination));
6086: data->if_combination.num_different_channels *= n_bands;
6087: }
6088:
6089: if (data->use_chanctx)
6090: data->if_combination.radar_detect_widths = 0;
6091:
6092: /* By default all radios belong to the first group */
6093: data->group = 1;
6094: mutex_init(&data->mutex);
6095:
6096: data->netgroup = hwsim_net_get_netgroup(net);
6097: data->wmediumd = hwsim_net_get_wmediumd(net);
6098:
6099: /* Enable frame retransmissions for lossy channels */
6100: hw->max_rates = 4;
6101: hw->max_rate_tries = 11;
6102:
6103: hw->wiphy->vendor_commands = mac80211_hwsim_vendor_commands;
6104: hw->wiphy->n_vendor_commands =
6105: ARRAY_SIZE(mac80211_hwsim_vendor_commands);
6106: hw->wiphy->vendor_events = mac80211_hwsim_vendor_events;
6107: hw->wiphy->n_vendor_events = ARRAY_SIZE(mac80211_hwsim_vendor_events);
6108:
6109: if (param->reg_strict)
6110: hw->wiphy->regulatory_flags |= REGULATORY_STRICT_REG;
6111: if (param->regd) {
6112: data->regd = param->regd;
6113: hw->wiphy->regulatory_flags |= REGULATORY_CUSTOM_REG;
6114: wiphy_apply_custom_regulatory(hw->wiphy, param->regd);
6115: /* give the regulatory workqueue a chance to run */
6116: schedule_timeout_interruptible(1);
6117: }
6118:
6119: wiphy_ext_feature_set(hw->wiphy,
6120: NL80211_EXT_FEATURE_DFS_CONCURRENT);
6121: if (param->background_radar)
6122: wiphy_ext_feature_set(hw->wiphy,
6123: NL80211_EXT_FEATURE_RADAR_BACKGROUND);
6124:
6125: if (param->no_vif)
6126: ieee80211_hw_set(hw, NO_AUTO_VIF);
6127:
6128: wiphy_ext_feature_set(hw->wiphy, NL80211_EXT_FEATURE_CQM_RSSI_LIST);
6129: wiphy_ext_feature_set(hw->wiphy, NL80211_EXT_FEATURE_PUNCT);
6130: wiphy_ext_feature_set(hw->wiphy, NL80211_EXT_FEATURE_PROBE_AP);
6131:
6132: for (i = 0; i < ARRAY_SIZE(data->link_data); i++) {
6133: hrtimer_setup(&data->link_data[i].beacon_timer, mac80211_hwsim_beacon,
6134: CLOCK_MONOTONIC, HRTIMER_MODE_ABS_SOFT);
6135: data->link_data[i].link_id = i;
6136: }
6137:
6138: err = ieee80211_register_hw(hw);
6139: if (err < 0) {
6140: pr_debug("mac80211_hwsim: ieee80211_register_hw failed (%d)\n",
6141: err);
6142: goto failed_hw;
6143: }
6144:
6145: wiphy_dbg(hw->wiphy, "hwaddr %pM registered\n", hw->wiphy->perm_addr);
6146:
6147: if (param->reg_alpha2) {
6148: data->alpha2[0] = param->reg_alpha2[0];
6149: data->alpha2[1] = param->reg_alpha2[1];
6150: regulatory_hint(hw->wiphy, param->reg_alpha2);
6151: }
6152:
6153: data->debugfs = debugfs_create_dir("hwsim", hw->wiphy->debugfsdir);
6154: debugfs_create_file("ps", 0666, data->debugfs, data, &hwsim_fops_ps);
6155: debugfs_create_file("group", 0666, data->debugfs, data,
6156: &hwsim_fops_group);
6157: debugfs_create_file("rx_rssi", 0666, data->debugfs, data,
6158: &hwsim_fops_rx_rssi);
6159: if (!data->use_chanctx)
6160: debugfs_create_file("dfs_simulate_radar", 0222,
6161: data->debugfs,
6162: data, &hwsim_simulate_radar);
6163: if (param->background_radar)
6164: debugfs_create_file("dfs_background_cac", 0200,
6165: data->debugfs,
6166: data, &hwsim_background_cac_ops);
6167: debugfs_create_file("simulate_incumbent_signal_interference", 0200,
6168: data->debugfs,
6169: data, &hwsim_simulate_incumbent_signal_fops);
6170:
6171: if (param->pmsr_capa) {
6172: data->pmsr_capa = *param->pmsr_capa;
6173: hw->wiphy->pmsr_capa = &data->pmsr_capa;
6174: }
6175:
6176: spin_lock_bh(&hwsim_radio_lock);
6177: err = rhashtable_insert_fast(&hwsim_radios_rht, &data->rht,
6178: hwsim_rht_params);
6179: if (err < 0) {
6180: if (info) {
6181: GENL_SET_ERR_MSG(info, "perm addr already present");
6182: NL_SET_BAD_ATTR(info->extack,
6183: info->attrs[HWSIM_ATTR_PERM_ADDR]);
6184: }
6185: spin_unlock_bh(&hwsim_radio_lock);
6186: goto failed_final_insert;
6187: }
6188:
6189: list_add_tail(&data->list, &hwsim_radios);
6190: hwsim_radios_generation++;
6191: spin_unlock_bh(&hwsim_radio_lock);
6192:
6193: hwsim_mcast_new_radio(idx, info, param);
6194:
6195: return idx;
6196:
6197: failed_final_insert:
6198: debugfs_remove_recursive(data->debugfs);
6199: ieee80211_unregister_hw(data->hw);
6200: failed_hw:
6201: device_release_driver(data->dev);
6202: failed_bind:
6203: device_unregister(data->dev);
6204: failed_drvdata:
6205: ieee80211_free_hw(hw);
6206: failed:
6207: return err;
6208: }
SourceFile:drivers/net/wireless/virtual/mac80211_hwsim_main.c]
|
| 122/2 |
2026/09/04 14:19 |
llm |
expert |
0m
Model:
Tokens:
input: 91840
output: 61
thoughts: 199
Thoughts: **Concerning a Subtle Memory Corruption Bug**
Okay, so I'm looking at this `memcpy` call and immediately the warning bells are going off. I see `memcpy(data->rates, hwsim_rates, sizeof(hwsim_rates));`. `data->rates` is an array within this `mac80211_hwsim_data` structure. That part is straightforward. Let's make sure we have the struct definition clearly in mind. Now, the potential problem is that `rates[0].idx` can be set to -1. That's where things get interesting and where a potential out-of-bounds read, or even worse, a write, could occur. If `rates[0].idx` is -1, then it accesses `sband->bitrates[-1]`. This `sband->bitrates` has a tricky pointer - it either points to `data->rates` directly, or to `data->rates + 4`. That's where I need to focus and consider what happens in those two cases. The critical realization is that, if `sband->bitrates` *points* to `data->rates`, then indexing it with `-1` means it is accessing memory *before* the start of the `data->rates` array, which is very dangerous and is probably a bug. I need to figure out what data lies *before* the `data->rates` member in the `mac80211_hwsim_data` struct to understand the possible impact of this potential memory corruption. This could lead to read or write problems, so I'll need to figure out how these pointers are actually set and used and then find out what could be overwritten or leaked.
|
| 123/2 |
2026/09/04 14:19 |
tool |
codesearch-struct-layout |
0m
Args: map[ContextFile:drivers/net/wireless/virtual/mac80211_hwsim_main.c FieldOffset:<nil> Name:mac80211_hwsim_data]
Results: map[Fields:[map[Name:list OffsetBits:0 SizeBits:128] map[Name:rht OffsetBits:128 SizeBits:64] map[Name:hw OffsetBits:192 SizeBits:64] map[Name:dev OffsetBits:256 SizeBits:64] map[Name:bands OffsetBits:320 SizeBits:4992] map[Name:channels_2ghz OffsetBits:5312 SizeBits:8960] map[Name:channels_5ghz OffsetBits:14272 SizeBits:25600] map[Name:channels_6ghz OffsetBits:39872 SizeBits:37760] map[Name:channels_s1g OffsetBits:77632 SizeBits:32640] map[Name:rates OffsetBits:110272 SizeBits:1152] map[Name:if_combination OffsetBits:111424 SizeBits:192] map[Name:if_limits OffsetBits:111616 SizeBits:160] map[Name:n_if_limits OffsetBits:111776 SizeBits:32] map[Name:phy_data OffsetBits:111808 SizeBits:64] map[Name:if_combination_radio OffsetBits:111872 SizeBits:192] map[Name:radio_range OffsetBits:112064 SizeBits:384] map[Name:radio OffsetBits:112448 SizeBits:1536] map[Name:ciphers OffsetBits:113984 SizeBits:352] map[Name:addresses OffsetBits:114336 SizeBits:144] map[Name:channels OffsetBits:114496 SizeBits:32] map[Name:idx OffsetBits:114528 SizeBits:32] map[Name:use_chanctx OffsetBits:114560 SizeBits:8] map[Name:destroy_on_close OffsetBits:114568 SizeBits:8] map[Name:portid OffsetBits:114592 SizeBits:32] map[Name:alpha2 OffsetBits:114624 SizeBits:16] map[Name:regd OffsetBits:114688 SizeBits:64] map[Name:tmp_chan OffsetBits:114752 SizeBits:64] map[Name:roc_chan OffsetBits:114816 SizeBits:64] map[Name:roc_duration OffsetBits:114880 SizeBits:32] map[Name:roc_start OffsetBits:114944 SizeBits:1344] map[Name:roc_done OffsetBits:116288 SizeBits:1344] map[Name:hw_scan OffsetBits:117632 SizeBits:1344] map[Name:hw_scan_request OffsetBits:118976 SizeBits:64] map[Name:hw_scan_vif OffsetBits:119040 SizeBits:64] map[Name:scan_chan_idx OffsetBits:119104 SizeBits:32] map[Name:scan_addr OffsetBits:119136 SizeBits:48] map[Name:survey_data OffsetBits:119232 SizeBits:28928] map[Name:channel OffsetBits:148160 SizeBits:64] map[Name:bw OffsetBits:148224 SizeBits:32] map[Name:rx_filter OffsetBits:148256 SizeBits:32] map[Name:started OffsetBits:148288 SizeBits:8] map[Name:idle OffsetBits:148296 SizeBits:8] map[Name:scanning OffsetBits:148304 SizeBits:8] map[Name:mutex OffsetBits:148352 SizeBits:1088] map[Name:ps OffsetBits:149440 SizeBits:32] map[Name:ps_poll_pending OffsetBits:149472 SizeBits:8] map[Name:debugfs OffsetBits:149504 SizeBits:64] map[Name:radar_background_chandef OffsetBits:149568 SizeBits:384] map[Name:pending_cookie OffsetBits:149952 SizeBits:32] map[Name:pending OffsetBits:150016 SizeBits:704] map[Name:group OffsetBits:150720 SizeBits:64] map[Name:netgroup OffsetBits:150784 SizeBits:32] map[Name:wmediumd OffsetBits:150816 SizeBits:32] map[Name:tsf_offset_lock OffsetBits:150848 SizeBits:512] map[Name:tsf_offset OffsetBits:151360 SizeBits:64] map[Name:tx_pkts OffsetBits:151424 SizeBits:64] map[Name:rx_pkts OffsetBits:151488 SizeBits:64] map[Name:tx_bytes OffsetBits:151552 SizeBits:64] map[Name:rx_bytes OffsetBits:151616 SizeBits:64] map[Name:tx_dropped OffsetBits:151680 SizeBits:64] map[Name:tx_failed OffsetBits:151744 SizeBits:64] map[Name:rx_rssi OffsetBits:151808 SizeBits:32] map[Name:pmsr_capa OffsetBits:151840 SizeBits:544] map[Name:pmsr_request OffsetBits:152384 SizeBits:64] map[Name:pmsr_request_wdev OffsetBits:152448 SizeBits:64] map[Name:link_data OffsetBits:152512 SizeBits:11520] map[Name:nan OffsetBits:164032 SizeBits:15360]]]
|
| 124/2 |
2026/09/04 14:19 |
llm |
expert |
0m
Model:
Tokens:
input: 94097
output: 45
thoughts: 169
Thoughts: **Analyzing Potential Array Index Out-of-Bounds**
Okay, so I'm looking at this code and something is immediately jumping out at me. Before we even get to where `rates` is in memory (specifically offset 110272), we have `channels_s1g` starting at offset 77632 and taking up 32640 bytes. Simple arithmetic: 77632 + 32640 equals 110272. That's the key. This means that if `sband->bitrates[-1]` is accessing *before* the start of where `channels_s1g` would be located in memory, and this section is using the last element of `channels_s1g`. I'm going to want to verify that.
My concern is further intensified by the fact that `channels_s1g` is an array of `struct ieee80211_channel`, yet we're treating `sband->bitrates[-1]` as if it were a `struct ieee80211_rate`. This is a classic recipe for disaster. The memory layout of these structures is what will be important. I need to quickly ascertain the sizes of both `struct ieee80211_rate` and `struct ieee80211_channel` to get a clearer picture of the magnitude of this potential out-of-bounds access and what is really being accessed. This could be a sneaky bug waiting to be exploited.
|
| 125/2 |
2026/09/04 14:19 |
tool |
codesearch-struct-layout |
0m
Args: map[ContextFile:include/net/mac80211.h Name:ieee80211_rate]
Results: map[Fields:[map[Name:flags OffsetBits:0 SizeBits:32] map[Name:bitrate OffsetBits:32 SizeBits:16] map[Name:hw_value OffsetBits:48 SizeBits:16] map[Name:hw_value_short OffsetBits:64 SizeBits:16]]]
|
| 126/2 |
2026/09/04 14:19 |
llm |
expert |
0m
Model:
Tokens:
input: 94732
output: 45
thoughts: 65
Thoughts: **Analyzing Data Structure Sizes**
Okay, so I'm looking at this `ieee80211_rate` structure, and it looks like the size is coming in at 80 bits. Let me think... 64 plus 16 equals 80, yeah that makes sense. But given that it's likely being used in some kind of memory block, I bet there's some padding in there, so the real size is probably a multiple of the word size, making it 12 bytes. I should confirm that and, just to be sure, check the `ieee80211_channel` size too. That might give me some clues about common alignment practices.
|
| 127/2 |
2026/09/04 14:19 |
tool |
codesearch-struct-layout |
0m
Args: map[ContextFile:include/net/mac80211.h Name:ieee80211_channel]
Results: map[Fields:[map[Name:band OffsetBits:0 SizeBits:32] map[Name:center_freq OffsetBits:32 SizeBits:32] map[Name:freq_offset OffsetBits:64 SizeBits:16] map[Name:hw_value OffsetBits:80 SizeBits:16] map[Name:flags OffsetBits:96 SizeBits:32] map[Name:max_antenna_gain OffsetBits:128 SizeBits:32] map[Name:max_power OffsetBits:160 SizeBits:32] map[Name:max_reg_power OffsetBits:192 SizeBits:32] map[Name:beacon_found OffsetBits:224 SizeBits:8] map[Name:orig_flags OffsetBits:256 SizeBits:32] map[Name:orig_mag OffsetBits:288 SizeBits:32] map[Name:orig_mpwr OffsetBits:320 SizeBits:32] map[Name:dfs_state OffsetBits:352 SizeBits:32] map[Name:dfs_state_entered OffsetBits:384 SizeBits:64] map[Name:dfs_cac_ms OffsetBits:448 SizeBits:32] map[Name:cac_start_time OffsetBits:512 SizeBits:64] map[Name:psd OffsetBits:576 SizeBits:8]]]
|
| 128/2 |
2026/09/04 14:19 |
llm |
expert |
0m
Model:
Tokens:
input: 95361
output: 62
thoughts: 1764
Thoughts: **Analysis of the IEEE 802.11 Rate Index Bug**
Okay, let's break this down. My initial observation is that the size discrepancy of `ieee80211_channel` (72 bytes) throws a wrench into `sband->bitrates[-1]`. This suggests a potential out-of-bounds read, and I'm zeroing in on where that manifests. It seems like the core issue lies in how the rate index is handled, specifically within `rate_fixup_ratelist` and related functions.
My immediate concern was the read of `rate->bitrate` within the if statement. However, that read is not out of bounds, so I can dismiss that. The `baserate` calculation appears suspect, and it does make a read out of bounds. But I can confirm it's not a write; it's selecting a rate index, not writing a new value. This means it just messes up the *selection* of `baserate`, resulting in an incorrect RTS/CTS rate, but no memory corruption.
The `rate_fixup_ratelist` loop has a check for `rates[i].idx < 0`, and I noted the loop handled negative indices properly. The critical area is *before* the loop, in the initial access to `sband->bitrates[rates[0].idx]`. This is the single out-of-bounds read and is due to `rates[0].idx` being set to `-1`.
The vulnerability originates with `ieee80211_parse_tx_radiotap`, which sets `rates[0].idx = -1`. This is subsequently read by `ieee80211_get_tx_rates` and passed to `rate_fixup_ratelist`. `mac80211_hwsim_write_tsf` triggers `WARN_ON_ONCE` because of this, and the `cw1200` driver actually *crashes* with `BUG_ON`.
The question becomes: is this exploitable? Specifically, can an unprivileged user trigger a crash? The answer depends on the presence and usage of the `cw1200` device. The crash is a DoS, but it requires either `CAP_NET_RAW` (which is privileged) or moving the `cw1200` device into the user namespace (which requires `CAP_NET_ADMIN`, also privileged). `mac80211_hwsim` merely issues a warning, meaning there is no denial of service.
I went through a quick check of other potentially vulnerable drivers, checking for negative index handling in the code. I investigated `wfx`, `ath9k`, and `mt76`, but the negative index issue either does not exist, or the code handled it properly. `cw1200` is the only crash I can confirm.
The conclusion is that the bug primarily presents a DoS risk if the user has `CAP_NET_RAW` and a `cw1200` device present. It can cause only a warning, and a harmless out-of-bounds read otherwise. It's not a privilege escalation or information leak vulnerability. No DoS can be triggered by unprivileged users. I'm satisfied that with the current understanding, no actionable exploit exists to leverage this bug.
My final analysis focuses on the `WARN_ON_ONCE`. The warning is handled by normal control flow (that is, there's an `if` statement to handle it) and so does not cause any denial of service. The out-of-bounds read in `rate_fixup_ratelist` is harmless. I'm certain there is no DoS. And no exploitable bugs. However, there may be some implications around the status of `-1`. In the context of `mac80211_hwsim_tx_frame_no_nl`, there is a potential issue if `-1` is read by the `rx_status.rate_idx`, depending on the data type. I should check the data type of `rate_idx`. This is the final consideration.
|
| 129/2 |
2026/09/04 14:20 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/net/wireless/virtual/mac80211_hwsim_main.c Name:mac80211_hwsim_tx_frame_no_nl]
Results: map[SourceCode:1902: static bool mac80211_hwsim_tx_frame_no_nl(struct ieee80211_hw *hw,
1903: struct sk_buff *skb,
1904: struct ieee80211_channel *chan)
1905: {
1906: struct mac80211_hwsim_data *data = hw->priv, *data2;
1907: bool ack = false;
1908: struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
1909: struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
1910: struct ieee80211_rx_status rx_status;
1911: u64 sim_tsf = mac80211_hwsim_get_sim_tsf();
1912:
1913: mac80211_hwsim_write_tsf(data, skb, sim_tsf);
1914:
1915: mac80211_hwsim_monitor_rx(hw, skb, chan);
1916:
1917: memset(&rx_status, 0, sizeof(rx_status));
1918: rx_status.flag |= RX_FLAG_MACTIME_START;
1919: rx_status.freq = chan->center_freq;
1920: rx_status.freq_offset = chan->freq_offset ? 1 : 0;
1921: rx_status.band = chan->band;
1922: if (info->control.rates[0].flags & IEEE80211_TX_RC_VHT_MCS) {
1923: rx_status.rate_idx =
1924: ieee80211_rate_get_vht_mcs(&info->control.rates[0]);
1925: rx_status.nss =
1926: ieee80211_rate_get_vht_nss(&info->control.rates[0]);
1927: rx_status.encoding = RX_ENC_VHT;
1928: } else {
1929: rx_status.rate_idx = info->control.rates[0].idx;
1930: if (info->control.rates[0].flags & IEEE80211_TX_RC_MCS)
1931: rx_status.encoding = RX_ENC_HT;
1932: }
1933: if (info->control.rates[0].flags & IEEE80211_TX_RC_40_MHZ_WIDTH)
1934: rx_status.bw = RATE_INFO_BW_40;
1935: else if (info->control.rates[0].flags & IEEE80211_TX_RC_80_MHZ_WIDTH)
1936: rx_status.bw = RATE_INFO_BW_80;
1937: else if (info->control.rates[0].flags & IEEE80211_TX_RC_160_MHZ_WIDTH)
1938: rx_status.bw = RATE_INFO_BW_160;
1939: else
1940: rx_status.bw = RATE_INFO_BW_20;
1941: if (info->control.rates[0].flags & IEEE80211_TX_RC_SHORT_GI)
1942: rx_status.enc_flags |= RX_ENC_FLAG_SHORT_GI;
1943: /* TODO: simulate optional packet loss */
1944: rx_status.signal = data->rx_rssi;
1945: if (info->control.vif)
1946: rx_status.signal += info->control.vif->bss_conf.txpower;
1947:
1948: if (data->ps != PS_DISABLED)
1949: hdr->frame_control |= cpu_to_le16(IEEE80211_FCTL_PM);
1950:
1951: /* release the skb's source info */
1952: skb_orphan(skb);
1953: skb_dst_drop(skb);
1954: skb->mark = 0;
1955: skb_ext_reset(skb);
1956: nf_reset_ct(skb);
1957:
1958: if (ieee80211_is_beacon(hdr->frame_control) ||
1959: ieee80211_is_probe_resp(hdr->frame_control))
1960: rx_status.boottime_ns = ktime_get_boottime_ns();
1961:
1962: /* Copy skb to all enabled radios that are on the current frequency */
1963: spin_lock(&hwsim_radio_lock);
1964: list_for_each_entry(data2, &hwsim_radios, list) {
1965: struct sk_buff *nskb;
1966: struct tx_iter_data tx_iter_data = {
1967: .receive = false,
1968: .hw = data2->hw,
1969: .channel = chan,
1970: .rx_status = &rx_status,
1971: };
1972:
1973: if (data == data2)
1974: continue;
1975:
1976: if (!data2->started || (data2->idle && !data2->tmp_chan) ||
1977: !hwsim_ps_rx_ok(data2, skb))
1978: continue;
1979:
1980: if (!(data->group & data2->group))
1981: continue;
1982:
1983: if (data->netgroup != data2->netgroup)
1984: continue;
1985:
1986: /*
1987: * Set mactime early since NAN RX filtering relies on it
1988: * for slot calculation
1989: */
1990: rx_status.mactime = sim_tsf + data2->tsf_offset;
1991:
1992: if (!hwsim_chans_compat(chan, data2->tmp_chan) &&
1993: !hwsim_chans_compat(chan, data2->channel)) {
1994: ieee80211_iterate_active_interfaces_atomic(
1995: data2->hw, IEEE80211_IFACE_ITER_NORMAL,
1996: mac80211_hwsim_tx_iter, &tx_iter_data);
1997: if (!tx_iter_data.receive)
1998: continue;
1999: }
2000:
2001: /*
2002: * reserve some space for our vendor and the normal
2003: * radiotap header, since we're copying anyway
2004: */
2005: if (skb->len < PAGE_SIZE && paged_rx) {
2006: struct page *page = alloc_page(GFP_ATOMIC);
2007:
2008: if (!page)
2009: continue;
2010:
2011: nskb = dev_alloc_skb(128);
2012: if (!nskb) {
2013: __free_page(page);
2014: continue;
2015: }
2016:
2017: memcpy(page_address(page), skb->data, skb->len);
2018: skb_add_rx_frag(nskb, 0, page, 0, skb->len, skb->len);
2019: } else {
2020: nskb = skb_copy(skb, GFP_ATOMIC);
2021: if (!nskb)
2022: continue;
2023: }
2024:
2025: if (mac80211_hwsim_addr_match(data2, hdr->addr1))
2026: ack = true;
2027:
2028: mac80211_hwsim_rx(data2, &rx_status, nskb);
2029: }
2030: spin_unlock(&hwsim_radio_lock);
2031:
2032: return ack;
2033: }
SourceFile:drivers/net/wireless/virtual/mac80211_hwsim_main.c]
|
| 130/2 |
2026/09/04 14:20 |
llm |
expert |
0m
Model:
Tokens:
input: 100476
output: 66
thoughts: 2180
Thoughts: **Bug Analysis: mac80211_hwsim and Rate Index Vulnerability**
Okay, so here's what I've got. It looks like `rx_status.rate_idx`, which is a `u32`, can end up being set to `4294967295` (effectively -1 when interpreted as a signed integer) under certain conditions. Specifically, this happens when `info->control.rates[0].idx` is `-1`. The `mac80211_hwsim` driver, which queues and processes packets, is the trigger for this issue.
The packet goes through a few layers of function calls eventually leading to `ieee80211_rx`, which passes the `rx_status` to the `mac80211` core. In the `mac80211` core, this `rate_idx` is used to populate the radiotap header, specifically when a monitor interface is active. Here's the key thing: because of the check `if (rx_status->rate_idx < sband->n_bitrates)`, if `rate_idx` is `4294967295`, it *won't* be less than `sband->n_bitrates`. This means it *won't* try to look up a rate from the bitrate array, so, this avoids a possible out-of-bounds read and crashes.
So, in the end, it means that the rate won't be set. The worst that happens is a `WARN_ON_ONCE` in `ieee80211_get_tx_rate`, triggered by `mac80211_hwsim`. I'm going to look at other drivers to see if they're affected by the negative value.
I checked `ath10k`, `ath11k`, `ath5k`, `iwlegacy`, `iwlwifi`, `mt76x02`, `mm81x`, `rt2x00`, `rtlwifi`, `rtw89`, and `wfx` and the code handles the negative `idx`. `st/cw1200` crashes.
I've determined that the bug is *not* exploitable in a meaningful way because the `rate_idx` check prevents a real out-of-bounds read, and, the only other driver that crashes is a physical device which is only vulnerable with higher permissions in the base namespace. Therefore, the `WARN_ON_ONCE` is not a denial of service.
The bug *is* accessible from user namespaces because a user can create a `mac80211_hwsim` device in a user namespace, create a monitor interface, and inject a frame. Since a monitor interface requires `CAP_NET_ADMIN` in the namespace of the device, this means that even though it *is* accessible from a user namespace, an unprivileged user cannot trigger it without obtaining CAP_NET_ADMIN.
To summarize the relevant bug report attributes:
- Exploitable: No
- Denial of Service: No
- Accessible From Unprivileged Processes: No
- Accessible From User Namespaces: Yes
- VM Guest Trigger: No
- VM Host Trigger: No
- Ethernet Network Trigger: No
- Other Remote Trigger: No
- Peripheral Trigger: No
- Malicious Filesystem Trigger: No
|
| 131/2 |
2026/09/04 14:20 |
tool |
set-results |
0m
Args: map[DenialOfService:false Exploitable:false FilesystemTrigger:false NetworkTrigger:false PeripheralTrigger:false RemoteTrigger:false Unprivileged:false UserNamespace:true VMGuestTrigger:false VMHostTrigger:false]
Results: map[DenialOfService:false Exploitable:false FilesystemTrigger:false NetworkTrigger:false PeripheralTrigger:false RemoteTrigger:false Unprivileged:false UserNamespace:true VMGuestTrigger:false VMHostTrigger:false]
|
| 132/2 |
2026/09/04 14:20 |
llm |
expert |
0m
Model:
Tokens:
input: 103522
output: 521
thoughts: 12
Thoughts: Okay, here's my attempt at summarizing the thought process, as requested, aimed at an expert audience and in the first person:
**Finalizing the Analysis and Preparing the Response**
Alright, the analysis is finally complete. I've thoroughly reviewed the data, considered the nuances, and integrated all the relevant information. Now, it's time to craft the final response. I've got a solid grasp of the core findings, the implications, and the potential counterarguments. I'm ready to articulate everything concisely and effectively. Time to synthesize this information into a cohesive, impactful, and, of course, accurate conclusion. Let's get to it.
|
| 133/1 |
2026/09/04 14:20 |
action |
format-explanation |
0m
Results: map[Explanation:The bug is caused by `ieee80211_parse_tx_radiotap()` failing to find a valid
rate in the injected radiotap header and leaving `info->control.rates[0].idx`
set to `-1`. Later, when the frame is transmitted, `mac80211_hwsim` calls
`ieee80211_get_tx_rate()`, which checks `WARN_ON_ONCE(c->control.rates[0].idx <
0)` and returns `NULL`. The caller properly handles the `NULL` return value, so
this does not lead to any memory corruption, information leak, or crash.
In production builds, `WARN_ON_ONCE` simply logs a warning and continues
execution without halting the kernel. Therefore, this bug does not cause a
Denial of Service (DoS).
While some physical drivers (like `cw1200`) might trigger a `BUG_ON` if they
encounter a negative rate index, triggering this requires injecting frames into
that specific physical device. Frame injection requires a monitor interface,
which can only be created by a user with `CAP_NET_ADMIN` in the network
namespace where the device resides. Physical devices are typically restricted to
the initial network namespace, meaning only a privileged user (root) could
trigger the crash on such hardware.
However, the bug can be reached from an unprivileged user namespace by
leveraging the `mac80211_hwsim` module. The `hwsim_genl_family` allows creating
virtual radios from non-initial network namespaces (`.netnsok = true`). An
unprivileged user can create a user namespace, obtain `CAP_NET_ADMIN` within it,
create a virtual `mac80211_hwsim` radio, set up a monitor interface, and inject
a malformed frame to trigger the warning. Since it only results in a handled
warning, it has no security impact.
**Conclusion:**
- **Exploitable:** No. The negative index is either properly handled or checked
before use in most drivers, and the `mac80211` core handles it gracefully.
- **Denial of Service:** No. The `WARN_ON_ONCE` does not crash the kernel in
production.
- **Accessible From User Namespaces:** Yes. An unprivileged user can create a
user namespace, instantiate a `mac80211_hwsim` device, and trigger the warning.]
|