| 0/0 |
2026/06/16 00:04 |
flow |
assessment-security |
17m
Results: map[DenialOfService:true Explanation:The bug report indicates a `WARNING` in `__ieee80211_start_scan` when
`ieee80211_prep_hw_scan` returns `false`.
### Bug Analysis
In `__ieee80211_start_scan`, the `local->hw_scan_req` structure is allocated
using `kmalloc`, which leaves its contents uninitialized. Several fields, such
as `req.ie_len`, `req.mac_addr`, and `req.mac_addr_mask`, are expected to be
initialized later by `ieee80211_prep_hw_scan`.
However, `ieee80211_prep_hw_scan` can fail and return `false` in a couple of
scenarios:
1. **Buffer size miscalculation:** The `local->scan_ies_len` calculation in
`ieee80211_register_hw` fails to account for the 5 bytes required by the
`he_6ghz_cap` element. When `ieee80211_build_preq_ies` attempts to append this
element, it runs out of `skb_tailroom` and returns `-ENOBUFS`.
2. **Race condition:** If a scan is concurrently aborted, the
`SCAN_HW_CANCELLED` bit is set, causing `ieee80211_prep_hw_scan` to immediately
return `false`.
When `ieee80211_prep_hw_scan` returns `false`, a `WARN_ON` is triggered, but
**execution does not halt**. The kernel proceeds to call the driver's
`drv_hw_scan` callback with the partially uninitialized `local->hw_scan_req`.
### Security Impact
**Exploitable & Denial of Service:**
This is highly exploitable for both Information Leaks and Denial of Service
(DoS):
- **Out-of-Bounds Read / Info Leak:** Drivers like `mt76` and `mac80211_hwsim`
use the uninitialized `req.ie_len` to copy data from the uninitialized `req.ie`
pointer into a probe request `skb`. Since `req.ie_len` can be a large garbage
value, this results in a massive out-of-bounds read of kernel heap memory. This
leaked memory is then transmitted over the air in the probe request, leading to
a remote information leak that can expose sensitive kernel data or bypass KASLR.
- **Kernel Panic (DoS):** If the uninitialized `req.ie_len` is larger than the
allocated `skb` tailroom, the `skb_put` function will trigger a kernel panic,
resulting in a DoS.
- **Use-After-Free (UAF):** For drivers like `iwlwifi` that rely on `ies->ies`
and `ies->len`, a failure in `ieee80211_build_preq_ies` causes `ies->ies` to
point to a freed `skb` buffer. The driver will then read from this freed buffer
(UAF read) to construct the probe request.
**Privilege Requirements:**
Triggering this bug requires sending the `NL80211_CMD_TRIGGER_SCAN` netlink
command. While this command has the `GENL_UNS_ADMIN_PERM` flag (meaning it can
be called from a user namespace where the user has `CAP_NET_ADMIN`), it requires
a wireless device (`wiphy`) to be present in that network namespace.
Physical wireless devices reside in the init network namespace by default and
cannot be moved to an unprivileged user namespace without root privileges.
Unless a testing module like `mac80211_hwsim` is loaded (which allows
unprivileged creation of virtual radios), an unprivileged user cannot reach this
code path. Therefore, it is not accessible from unprivileged processes or user
namespaces in a typical production environment. Exploitable:true FilesystemTrigger:false NetworkTrigger:false PeripheralTrigger:false RemoteTrigger:false Unprivileged:false UserNamespace:false VMGuestTrigger:false VMHostTrigger:false]
|
| 1/1 |
2026/06/16 00:04 |
action |
syz-repro-to-c-repro |
0m
Results:
|
| 2/1 |
2026/06/16 00:04 |
action |
kernel-checkouter |
0m
Results: map[KernelSrc:/app/workdir/cache/src/d86a654ec02bc244167423f4ab29ac17d783b9c0]
|
| 3/1 |
2026/06/16 00:04 |
action |
kernel-builder |
0m
Results: map[KernelObj:/app/workdir/cache/build/1c98865825acbd3ae98b2204a2560ae4f0cf120f]
|
| 4/1 |
2026/06/16 00:04 |
action |
codesearch-prepare |
0m
Results: map[Index:codesearch-index]
|
| 5/1 |
2026/06/16 00:04 |
agent |
expert |
17m
Model:
Results: map[DenialOfService:true Exploitable:true FilesystemTrigger:false NetworkTrigger:false PeripheralTrigger:false RemoteTrigger:false Unprivileged:false UserNamespace:false 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:
------------[ cut here ]------------
!ieee80211_prep_hw_scan(sdata)
WARNING: net/mac80211/scan.c:879 at __ieee80211_start_scan+0x1336/0x1d40 net/mac80211/scan.c:879, CPU#0: syz.0.5003/24116
Modules linked in:
CPU: 0 UID: 0 PID: 24116 Comm: syz.0.5003 Not tainted syzkaller #0 PREEMPT(full)
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 05/09/2026
RIP: 0010:__ieee80211_start_scan+0x1336/0x1d40 net/mac80211/scan.c:879
Code: 06 90 e8 bd 74 b0 f6 48 83 fd 09 0f 84 41 07 00 00 83 fd 03 0f 84 3f 07 00 00 e8 25 6f b0 f6 e9 d5 f2 ff ff e8 1b 6f b0 f6 90 <0f> 0b 90 e9 0d fe ff ff 89 d9 80 e1 07 80 c1 03 38 c1 0f 8c 53 fa
RSP: 0018:ffffc9000674f170 EFLAGS: 00010293
RAX: ffffffff8b154795 RBX: ffff888053bf8e40 RCX: ffff888079661f00
RDX: 0000000000000000 RSI: 00000000fffffff4 RDI: 0000000000000000
RBP: ffff88804acc3024 R08: ffffffff903034f7 R09: 1ffffffff206069e
R10: dffffc0000000000 R11: fffffbfff206069f R12: ffff88804acc3060
R13: dffffc0000000000 R14: ffff88805c5a0f20 R15: ffff88805c5a2a88
FS: 00007fe61492d6c0(0000) GS:ffff8881252a0000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007fe613987cc0 CR3: 0000000075924000 CR4: 00000000003526f0
Call Trace:
<TASK>
rdev_scan+0x147/0x300 net/wireless/rdev-ops.h:467
nl80211_trigger_scan+0x1aa1/0x1f50 net/wireless/nl80211.c:11046
genl_family_rcv_msg_doit+0x22a/0x330 net/netlink/genetlink.c:1114
genl_family_rcv_msg net/netlink/genetlink.c:1194 [inline]
genl_rcv_msg+0x61c/0x7a0 net/netlink/genetlink.c:1209
netlink_rcv_skb+0x232/0x4b0 net/netlink/af_netlink.c:2555
genl_rcv+0x28/0x40 net/netlink/genetlink.c:1218
netlink_unicast_kernel net/netlink/af_netlink.c:1318 [inline]
netlink_unicast+0x75c/0x8e0 net/netlink/af_netlink.c:1344
netlink_sendmsg+0x813/0xb40 net/netlink/af_netlink.c:1899
sock_sendmsg_nosec net/socket.c:787 [inline]
__sock_sendmsg net/socket.c:802 [inline]
____sys_sendmsg+0x972/0x9f0 net/socket.c:2699
___sys_sendmsg+0x2a5/0x360 net/socket.c:2753
__sys_sendmsg net/socket.c:2785 [inline]
__do_sys_sendmsg net/socket.c:2790 [inline]
__se_sys_sendmsg net/socket.c:2788 [inline]
__x64_sys_sendmsg+0x1bd/0x2a0 net/socket.c:2788
do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
do_syscall_64+0x174/0x580 arch/x86/entry/syscall_64.c:94
entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7fe61399ce59
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:00007fe61492d028 EFLAGS: 00000246 ORIG_RAX: 000000000000002e
RAX: ffffffffffffffda RBX: 00007fe613c15fa0 RCX: 00007fe61399ce59
RDX: 0000000004000000 RSI: 0000200000000900 RDI: 0000000000000003
RBP: 00007fe61492d090 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000001
R13: 00007fe613c16038 R14: 00007fe613c15fa0 R15: 00007fff3acb29d8
</TASK>
Reply: The bug report indicates a `WARNING` in `__ieee80211_start_scan` when `ieee80211_prep_hw_scan` returns `false`.
### Bug Analysis
In `__ieee80211_start_scan`, the `local->hw_scan_req` structure is allocated using `kmalloc`, which leaves its contents uninitialized. Several fields, such as `req.ie_len`, `req.mac_addr`, and `req.mac_addr_mask`, are expected to be initialized later by `ieee80211_prep_hw_scan`.
However, `ieee80211_prep_hw_scan` can fail and return `false` in a couple of scenarios:
1. **Buffer size miscalculation:** The `local->scan_ies_len` calculation in `ieee80211_register_hw` fails to account for the 5 bytes required by the `he_6ghz_cap` element. When `ieee80211_build_preq_ies` attempts to append this element, it runs out of `skb_tailroom` and returns `-ENOBUFS`.
2. **Race condition:** If a scan is concurrently aborted, the `SCAN_HW_CANCELLED` bit is set, causing `ieee80211_prep_hw_scan` to immediately return `false`.
When `ieee80211_prep_hw_scan` returns `false`, a `WARN_ON` is triggered, but **execution does not halt**. The kernel proceeds to call the driver's `drv_hw_scan` callback with the partially uninitialized `local->hw_scan_req`.
### Security Impact
**Exploitable & Denial of Service:**
This is highly exploitable for both Information Leaks and Denial of Service (DoS):
- **Out-of-Bounds Read / Info Leak:** Drivers like `mt76` and `mac80211_hwsim` use the uninitialized `req.ie_len` to copy data from the uninitialized `req.ie` pointer into a probe request `skb`. Since `req.ie_len` can be a large garbage value, this results in a massive out-of-bounds read of kernel heap memory. This leaked memory is then transmitted over the air in the probe request, leading to a remote information leak that can expose sensitive kernel data or bypass KASLR.
- **Kernel Panic (DoS):** If the uninitialized `req.ie_len` is larger than the allocated `skb` tailroom, the `skb_put` function will trigger a kernel panic, resulting in a DoS.
- **Use-After-Free (UAF):** For drivers like `iwlwifi` that rely on `ies->ies` and `ies->len`, a failure in `ieee80211_build_preq_ies` causes `ies->ies` to point to a freed `skb` buffer. The driver will then read from this freed buffer (UAF read) to construct the probe request.
**Privilege Requirements:**
Triggering this bug requires sending the `NL80211_CMD_TRIGGER_SCAN` netlink command. While this command has the `GENL_UNS_ADMIN_PERM` flag (meaning it can be called from a user namespace where the user has `CAP_NET_ADMIN`), it requires a wireless device (`wiphy`) to be present in that network namespace.
Physical wireless devices reside in the init network namespace by default and cannot be moved to an unprivileged user namespace without root privileges. Unless a testing module like `mac80211_hwsim` is loaded (which allows unprivileged creation of virtual radios), an unprivileged user cannot reach this code path. Therefore, it is not accessible from unprivileged processes or user namespaces in a typical production environment.
|
| 6/2 |
2026/06/16 00:04 |
llm |
expert |
0m
Model:
Tokens:
input: 7610
output: 40
thoughts: 83
Thoughts: Here's my analysis of the situation:
**Investigating a Potential Scan Issue in mac80211**
Okay, so I've got a bug report flagging a WARNING at `net/mac80211/scan.c:879`. The warning originates in the `__ieee80211_start_scan` function. The culprit seems to be the conditional check: `!ieee80211_prep_hw_scan(sdata)`. Right, so this suggests that `ieee80211_prep_hw_scan` is failing. That's my immediate focus. I need to dive into `net/mac80211/scan.c` and figure out what circumstances lead to that function returning a failure. It could be something straightforward like a hardware state issue, or it might be a more complex interaction with other parts of the scanning process. Time to dig in and see what's going on.
|
| 7/2 |
2026/06/16 00:04 |
tool |
read-file |
0m
Args: map[File:net/mac80211/scan.c FirstLine:860 LineCount:40]
Results: map[Contents: 860: if (req->n_ssids)
861: set_bit(SCAN_BEACON_WAIT, &local->scanning);
862: } else {
863: ieee80211_scan_state_send_probe(local, &next_delay);
864: next_delay = IEEE80211_CHANNEL_TIME;
865: }
866:
867: /* Now, just wait a bit and we are all done! */
868: wiphy_delayed_work_queue(local->hw.wiphy, &local->scan_work,
869: next_delay);
870: return 0;
871: } else {
872: /* Do normal software scan */
873: __set_bit(SCAN_SW_SCANNING, &local->scanning);
874: }
875:
876: ieee80211_recalc_idle(local);
877:
878: if (hw_scan) {
879: WARN_ON(!ieee80211_prep_hw_scan(sdata));
880: rc = drv_hw_scan(local, sdata, local->hw_scan_req);
881: } else {
882: rc = ieee80211_start_sw_scan(local, sdata);
883: }
884:
885: if (rc) {
886: kfree(local->hw_scan_req);
887: local->hw_scan_req = NULL;
888: local->scanning = 0;
889:
890: ieee80211_recalc_idle(local);
891:
892: local->scan_req = NULL;
893: RCU_INIT_POINTER(local->scan_sdata, NULL);
894: }
895:
896: if (hw_scan && rc == 1) {
897: /*
898: * we can't fall back to software for P2P-GO
899: * as it must update NoA etc.
]
|
| 8/2 |
2026/06/16 00:04 |
llm |
expert |
0m
Model:
Tokens:
input: 8577
output: 49
thoughts: 49
Thoughts: Okay, let's break this down.
**Diving into the Hardware Scan Preparation**
That `WARN_ON(!ieee80211_prep_hw_scan(sdata));` warning flag has caught my attention. It's a clear indication that something is amiss with the preparation of a hardware scan, and a "WARN_ON" usually means a potential issue we need to address, otherwise the kernel might crash.
So, the next logical step is to dive right into the `ieee80211_prep_hw_scan` function itself. I need to understand what this function is designed to do. My immediate goal is to analyze the conditions under which it returns a false value, indicating an unsuccessful preparation, and why that might be happening in this context. I'll be looking for possible error conditions: Are we missing required resources? Is the hardware in an inappropriate state? Or is there some external dependency not being met? Only then can I diagnose the root cause of this warning and determine the appropriate action to resolve it.
|
| 9/2 |
2026/06/16 00:04 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:net/mac80211/scan.c Name:ieee80211_prep_hw_scan]
Results: map[SourceCode: 378: /* return false if no more work */
379: static bool ieee80211_prep_hw_scan(struct ieee80211_sub_if_data *sdata)
380: {
381: struct ieee80211_local *local = sdata->local;
382: struct cfg80211_scan_request *req;
383: struct cfg80211_chan_def chandef;
384: u8 bands_used = 0;
385: int i, ielen;
386: u32 *n_chans;
387: u32 flags = 0;
388:
389: req = rcu_dereference_protected(local->scan_req,
390: lockdep_is_held(&local->hw.wiphy->mtx));
391:
392: if (test_bit(SCAN_HW_CANCELLED, &local->scanning))
393: return false;
394:
395: if (ieee80211_hw_check(&local->hw, SINGLE_SCAN_ON_ALL_BANDS)) {
396: local->hw_scan_req->req.n_channels = req->n_channels;
397:
398: for (i = 0; i < req->n_channels; i++) {
399: local->hw_scan_req->req.channels[i] = req->channels[i];
400: bands_used |= BIT(req->channels[i]->band);
401: }
402: } else {
403: do {
404: if (local->hw_scan_band == NUM_NL80211_BANDS)
405: return false;
406:
407: n_chans = &local->hw_scan_req->req.n_channels;
408: *n_chans = 0;
409:
410: for (i = 0; i < req->n_channels; i++) {
411: if (req->channels[i]->band !=
412: local->hw_scan_band)
413: continue;
414: local->hw_scan_req->req.channels[(*n_chans)++] =
415: req->channels[i];
416:
417: bands_used |= BIT(req->channels[i]->band);
418: }
419:
420: local->hw_scan_band++;
421: } while (!*n_chans);
422: }
423:
424: ieee80211_prepare_scan_chandef(&chandef);
425:
426: if (req->flags & NL80211_SCAN_FLAG_MIN_PREQ_CONTENT)
427: flags |= IEEE80211_PROBE_FLAG_MIN_CONTENT;
428:
429: ielen = ieee80211_build_preq_ies(sdata,
430: (u8 *)local->hw_scan_req->req.ie,
431: local->hw_scan_ies_bufsize,
432: &local->hw_scan_req->ies,
433: req->ie, req->ie_len,
434: bands_used, req->rates, &chandef,
435: flags);
436: if (ielen < 0)
437: return false;
438: local->hw_scan_req->req.ie_len = ielen;
439: local->hw_scan_req->req.no_cck = req->no_cck;
440: ether_addr_copy(local->hw_scan_req->req.mac_addr, req->mac_addr);
441: ether_addr_copy(local->hw_scan_req->req.mac_addr_mask,
442: req->mac_addr_mask);
443: ether_addr_copy(local->hw_scan_req->req.bssid, req->bssid);
444:
445: return true;
446: }
SourceFile:net/mac80211/scan.c]
|
| 10/2 |
2026/06/16 00:04 |
llm |
expert |
0m
Model:
Tokens:
input: 10125
output: 41
thoughts: 115
Thoughts: **Analyzing the Hardware Scan Preparation Function**
Okay, so I'm diving into this `ieee80211_prep_hw_scan` function. My initial read tells me that it's the gatekeeper for starting a hardware scan. My thinking is, that if this thing returns `false`, the scan won't happen. Seems straightforward enough. Let's see what's actually stopping the scan.
It seems there are three reasons for a `false` return. First, if the `SCAN_HW_CANCELLED` bit is set in `local->scanning`, meaning a hardware scan was cancelled. That makes sense; if it's cancelled, we stop. Second, if `local->hw_scan_band` is equal to `NUM_NL80211_BANDS`. I'm guessing this means that the band wasn't initialized correctly or there's some kind of band mismatch β it's an invalid band index. Finally, if `ielen` is less than zero. I need to figure out what `ielen` stands for. That sounds like a length issue, perhaps a malformed input parameter.
Right, so to get a good picture, I need to see how the function `ieee80211_prep_hw_scan` is called. I'll need to jump into `__ieee80211_start_scan` to see what's happening upstream. I'm guessing that will show me the context and provide the reasons for the scan failing. I'll use that callsite information to infer the meaning of `ielen`.
|
| 11/2 |
2026/06/16 00:04 |
tool |
read-file |
0m
Args: map[File:net/mac80211/scan.c FirstLine:800 LineCount:100]
Results: map[Contents: 800: eth_broadcast_addr(local->hw_scan_req->req.bssid);
801: local->hw_scan_req->req.duration = req->duration;
802: local->hw_scan_req->req.duration_mandatory =
803: req->duration_mandatory;
804: local->hw_scan_req->req.tsf_report_link_id =
805: req->tsf_report_link_id;
806:
807: local->hw_scan_band = 0;
808: local->hw_scan_req->req.n_6ghz_params = req->n_6ghz_params;
809: local->hw_scan_req->req.scan_6ghz_params =
810: req->scan_6ghz_params;
811: local->hw_scan_req->req.scan_6ghz = req->scan_6ghz;
812: local->hw_scan_req->req.first_part = req->first_part;
813:
814: /*
815: * After allocating local->hw_scan_req, we must
816: * go through until ieee80211_prep_hw_scan(), so
817: * anything that might be changed here and leave
818: * this function early must not go after this
819: * allocation.
820: */
821: }
822:
823: rcu_assign_pointer(local->scan_req, req);
824: rcu_assign_pointer(local->scan_sdata, sdata);
825:
826: if (req->flags & NL80211_SCAN_FLAG_RANDOM_ADDR)
827: get_random_mask_addr(local->scan_addr,
828: req->mac_addr,
829: req->mac_addr_mask);
830: else
831: memcpy(local->scan_addr, sdata->vif.addr, ETH_ALEN);
832:
833: if (hw_scan) {
834: __set_bit(SCAN_HW_SCANNING, &local->scanning);
835: } else if ((req->n_channels == 1) &&
836: (req->channels[0] == local->hw.conf.chandef.chan)) {
837: /*
838: * If we are scanning only on the operating channel
839: * then we do not need to stop normal activities
840: */
841: unsigned long next_delay;
842:
843: __set_bit(SCAN_ONCHANNEL_SCANNING, &local->scanning);
844:
845: ieee80211_recalc_idle(local);
846:
847: /* Notify driver scan is starting, keep order of operations
848: * same as normal software scan, in case that matters. */
849: drv_sw_scan_start(local, sdata, local->scan_addr);
850:
851: ieee80211_configure_filter(local); /* accept probe-responses */
852:
853: /* We need to ensure power level is at max for scanning. */
854: ieee80211_hw_conf_chan(local);
855:
856: if ((req->channels[0]->flags & (IEEE80211_CHAN_NO_IR |
857: IEEE80211_CHAN_RADAR)) ||
858: !req->n_ssids) {
859: next_delay = IEEE80211_PASSIVE_CHANNEL_TIME;
860: if (req->n_ssids)
861: set_bit(SCAN_BEACON_WAIT, &local->scanning);
862: } else {
863: ieee80211_scan_state_send_probe(local, &next_delay);
864: next_delay = IEEE80211_CHANNEL_TIME;
865: }
866:
867: /* Now, just wait a bit and we are all done! */
868: wiphy_delayed_work_queue(local->hw.wiphy, &local->scan_work,
869: next_delay);
870: return 0;
871: } else {
872: /* Do normal software scan */
873: __set_bit(SCAN_SW_SCANNING, &local->scanning);
874: }
875:
876: ieee80211_recalc_idle(local);
877:
878: if (hw_scan) {
879: WARN_ON(!ieee80211_prep_hw_scan(sdata));
880: rc = drv_hw_scan(local, sdata, local->hw_scan_req);
881: } else {
882: rc = ieee80211_start_sw_scan(local, sdata);
883: }
884:
885: if (rc) {
886: kfree(local->hw_scan_req);
887: local->hw_scan_req = NULL;
888: local->scanning = 0;
889:
890: ieee80211_recalc_idle(local);
891:
892: local->scan_req = NULL;
893: RCU_INIT_POINTER(local->scan_sdata, NULL);
894: }
895:
896: if (hw_scan && rc == 1) {
897: /*
898: * we can't fall back to software for P2P-GO
899: * as it must update NoA etc.
]
|
| 12/2 |
2026/06/16 00:04 |
llm |
expert |
0m
Model:
Tokens:
input: 12311
output: 50
thoughts: 117
Thoughts: **Analyzing the Hardware Scan Cancellation**
Okay, so the alert is tripped when `ieee80211_prep_hw_scan` throws a `false` return. Let's break down the logic behind that. It looks like `false` is returned under three specific conditions. First, if the `SCAN_HW_CANCELLED` bit is set in the `local->scanning` flag. That's straightforward; the scan has been canceled. Second, if `local->hw_scan_band` is equal to `NUM_NL80211_BANDS`, which is likely an out-of-bounds error. Finally, and this is where it gets interesting, it fails if `ielen < 0`.
The negative integer from `ielen` is the critical point. This indicates something went wrong when calculating the size of the information elements (IEs). I need to check `ieee80211_build_preq_ies` because that function must be where `ielen` is calculated. It's likely that a logic error within that function is producing a negative value, which will cause this early termination of the hardware scan.
|
| 13/2 |
2026/06/16 00:04 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:net/mac80211/scan.c Name:ieee80211_build_preq_ies]
Results: map[SourceCode:1494: int ieee80211_build_preq_ies(struct ieee80211_sub_if_data *sdata, u8 *buffer,
1495: size_t buffer_len,
1496: struct ieee80211_scan_ies *ie_desc,
1497: const u8 *ie, size_t ie_len,
1498: u8 bands_used, u32 *rate_masks,
1499: struct cfg80211_chan_def *chandef,
1500: u32 flags)
1501: {
1502: struct sk_buff *skb = alloc_skb(buffer_len, GFP_KERNEL);
1503: uintptr_t offs;
1504: int ret, i;
1505: u8 *start;
1506:
1507: if (!skb)
1508: return -ENOMEM;
1509:
1510: start = skb_tail_pointer(skb);
1511: memset(start, 0, skb_tailroom(skb));
1512: ret = ieee80211_put_preq_ies(skb, sdata, ie_desc, ie, ie_len,
1513: bands_used, rate_masks, chandef,
1514: flags);
1515: if (ret < 0) {
1516: goto out;
1517: }
1518:
1519: if (skb->len > buffer_len) {
1520: ret = -ENOBUFS;
1521: goto out;
1522: }
1523:
1524: memcpy(buffer, start, skb->len);
1525:
1526: /* adjust ie_desc for copy */
1527: for (i = 0; i < NUM_NL80211_BANDS; i++) {
1528: offs = ie_desc->ies[i] - start;
1529: ie_desc->ies[i] = buffer + offs;
1530: }
1531: offs = ie_desc->common_ies - start;
1532: ie_desc->common_ies = buffer + offs;
1533:
1534: ret = skb->len;
1535: out:
1536: consume_skb(skb);
1537: return ret;
1538: }
SourceFile:net/mac80211/util.c]
|
| 14/2 |
2026/06/16 00:04 |
llm |
expert |
0m
Model:
Tokens:
input: 13464
output: 41
thoughts: 189
Thoughts: **Analyzing Potential Scan Failures**
Okay, so I'm digging into this scan initiation code and trying to understand potential failure points. `ieee80211_build_preq_ies` is the first place I'm looking, and it can hand back an error code, like `-ENOMEM` or `-ENOBUFS`, or whatever garbage `ieee80211_put_preq_ies` throws back. Thatβs expected. But thereβs something else throwing a wrench in the works: if `ieee80211_prep_hw_scan` returns `false`, `WARN_ON` gets triggered. Thatβs not ideal and I need to figure out why this might happen.
Is it possible that we're dealing with a scan that's already been cancelled (`test_bit(SCAN_HW_CANCELLED, &local->scanning)` is true)? Or perhaps the hardware scan band is somehow misconfigured (`local->hw_scan_band == NUM_NL80211_BANDS`)? The band shouldnβt be that. Also, a negative `ielen` is a red flag. Where does this negative value come from?
A negative `ielen` could happen because of a memory allocation issue (`ENOMEM` or `ENOBUFS`) β a failing call to something that sets the length. That will also trigger the `WARN_ON`. I need to review where those errors are propagated and how `ielen` can end up negative.
Okay, time to re-examine the `__ieee80211_start_scan` function.
|
| 15/2 |
2026/06/16 00:04 |
tool |
read-file |
0m
Args: map[File:net/mac80211/scan.c FirstLine:750 LineCount:100]
Results: map[Contents: 750: if (!__ieee80211_can_leave_ch(sdata, req))
751: return -EBUSY;
752:
753: if (!ieee80211_can_scan(local, sdata, req)) {
754: /* wait for the work to finish/time out */
755: rcu_assign_pointer(local->scan_req, req);
756: rcu_assign_pointer(local->scan_sdata, sdata);
757: return 0;
758: }
759:
760: again:
761: if (hw_scan) {
762: u8 *ies;
763:
764: local->hw_scan_ies_bufsize = local->scan_ies_len + req->ie_len;
765:
766: if (ieee80211_hw_check(&local->hw, SINGLE_SCAN_ON_ALL_BANDS)) {
767: int i, n_bands = 0;
768: u8 bands_counted = 0;
769:
770: for (i = 0; i < req->n_channels; i++) {
771: if (bands_counted & BIT(req->channels[i]->band))
772: continue;
773: bands_counted |= BIT(req->channels[i]->band);
774: n_bands++;
775: }
776:
777: local->hw_scan_ies_bufsize *= n_bands;
778: }
779:
780: local->hw_scan_req = kmalloc(struct_size(local->hw_scan_req,
781: req.channels,
782: req->n_channels) +
783: local->hw_scan_ies_bufsize,
784: GFP_KERNEL);
785: if (!local->hw_scan_req)
786: return -ENOMEM;
787:
788: local->hw_scan_req->req.ssids = req->ssids;
789: local->hw_scan_req->req.n_ssids = req->n_ssids;
790: /* None of the channels are actually set
791: * up but let UBSAN know the boundaries.
792: */
793: local->hw_scan_req->req.n_channels = req->n_channels;
794:
795: ies = (u8 *)local->hw_scan_req +
796: sizeof(*local->hw_scan_req) +
797: req->n_channels * sizeof(req->channels[0]);
798: local->hw_scan_req->req.ie = ies;
799: local->hw_scan_req->req.flags = req->flags;
800: eth_broadcast_addr(local->hw_scan_req->req.bssid);
801: local->hw_scan_req->req.duration = req->duration;
802: local->hw_scan_req->req.duration_mandatory =
803: req->duration_mandatory;
804: local->hw_scan_req->req.tsf_report_link_id =
805: req->tsf_report_link_id;
806:
807: local->hw_scan_band = 0;
808: local->hw_scan_req->req.n_6ghz_params = req->n_6ghz_params;
809: local->hw_scan_req->req.scan_6ghz_params =
810: req->scan_6ghz_params;
811: local->hw_scan_req->req.scan_6ghz = req->scan_6ghz;
812: local->hw_scan_req->req.first_part = req->first_part;
813:
814: /*
815: * After allocating local->hw_scan_req, we must
816: * go through until ieee80211_prep_hw_scan(), so
817: * anything that might be changed here and leave
818: * this function early must not go after this
819: * allocation.
820: */
821: }
822:
823: rcu_assign_pointer(local->scan_req, req);
824: rcu_assign_pointer(local->scan_sdata, sdata);
825:
826: if (req->flags & NL80211_SCAN_FLAG_RANDOM_ADDR)
827: get_random_mask_addr(local->scan_addr,
828: req->mac_addr,
829: req->mac_addr_mask);
830: else
831: memcpy(local->scan_addr, sdata->vif.addr, ETH_ALEN);
832:
833: if (hw_scan) {
834: __set_bit(SCAN_HW_SCANNING, &local->scanning);
835: } else if ((req->n_channels == 1) &&
836: (req->channels[0] == local->hw.conf.chandef.chan)) {
837: /*
838: * If we are scanning only on the operating channel
839: * then we do not need to stop normal activities
840: */
841: unsigned long next_delay;
842:
843: __set_bit(SCAN_ONCHANNEL_SCANNING, &local->scanning);
844:
845: ieee80211_recalc_idle(local);
846:
847: /* Notify driver scan is starting, keep order of operations
848: * same as normal software scan, in case that matters. */
849: drv_sw_scan_start(local, sdata, local->scan_addr);
]
|
| 16/2 |
2026/06/16 00:04 |
llm |
expert |
0m
Model:
Tokens:
input: 15747
output: 50
thoughts: 287
Thoughts: **Analyzing a Potential Hardware Scan Issue**
Okay, so I'm diving into this `ieee80211_prep_hw_scan` function. I see it's called within `__ieee80211_start_scan` β specifically at line 879. The interesting part is that if `ieee80211_prep_hw_scan` returns `false`, it triggers a `WARN_ON`. That's a red flag. I need to understand *why* it would return false.
My initial thought is to check if `ielen < 0`. That seems like a likely culprit, but where does that value come from? Ah, right, `ieee80211_build_preq_ies`. That function is responsible for the Interactive Extended Services (IES) preparation. Now, I see `ieee80211_build_preq_ies` allocates an skb (socket buffer) using `alloc_skb` with `buffer_len` that is derived from `local->hw_scan_ies_bufsize`. If the `alloc_skb` fails, then `ielen` will be `-ENOMEM`. Also, the `skb->len > buffer_len` returns `-ENOBUFS`.
Okay, so looking at how `local->hw_scan_ies_bufsize` is calculated, I see it's the sum of `local->scan_ies_len + req->ie_len`. And if `SINGLE_SCAN_ON_ALL_BANDS` is set, it gets multiplied by `n_bands`. So that means `skb->len > buffer_len` is indeed a possibility, especially if we're dealing with multiple bands and large IE lengths. I'll need to double check the logic in `ieee80211_put_preq_ies`.
|
| 17/2 |
2026/06/16 00:05 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:net/mac80211/util.c Name:ieee80211_put_preq_ies]
Results: map[SourceCode:1451: static int ieee80211_put_preq_ies(struct sk_buff *skb,
1452: struct ieee80211_sub_if_data *sdata,
1453: struct ieee80211_scan_ies *ie_desc,
1454: const u8 *ie, size_t ie_len,
1455: u8 bands_used, u32 *rate_masks,
1456: struct cfg80211_chan_def *chandef,
1457: u32 flags)
1458: {
1459: size_t custom_ie_offset = 0;
1460: int i, err;
1461:
1462: memset(ie_desc, 0, sizeof(*ie_desc));
1463:
1464: for (i = 0; i < NUM_NL80211_BANDS; i++) {
1465: if (bands_used & BIT(i)) {
1466: ie_desc->ies[i] = skb_tail_pointer(skb);
1467: err = ieee80211_put_preq_ies_band(skb, sdata,
1468: ie, ie_len,
1469: &custom_ie_offset,
1470: i, rate_masks[i],
1471: chandef, flags);
1472: if (err)
1473: return err;
1474: ie_desc->len[i] = skb_tail_pointer(skb) -
1475: ie_desc->ies[i];
1476: }
1477: }
1478:
1479: /* add any remaining custom IEs */
1480: if (ie && ie_len) {
1481: if (WARN_ONCE(skb_tailroom(skb) < ie_len - custom_ie_offset,
1482: "not enough space for preq custom IEs\n"))
1483: return -ENOBUFS;
1484: ie_desc->common_ies = skb_tail_pointer(skb);
1485: skb_put_data(skb, ie + custom_ie_offset,
1486: ie_len - custom_ie_offset);
1487: ie_desc->common_ie_len = skb_tail_pointer(skb) -
1488: ie_desc->common_ies;
1489: }
1490:
1491: return 0;
1492: };
SourceFile:net/mac80211/util.c]
|
| 18/2 |
2026/06/16 00:05 |
llm |
expert |
0m
Model:
Tokens:
input: 17259
output: 52
thoughts: 60
Thoughts: **Analyzing Potential Buffer Overflow in IEEE 802.11 Probe Request IE Handling**
Okay, so I'm digging into this `ieee80211_put_preq_ies_band` function. The documentation is telling me it has the potential to return `-ENOBUFS` which is a critical warning sign. That generally means the system is running out of space to build the packet. Specifically, it's indicating that the `skb_tailroom` might not be large enough for the Information Elements we're trying to add to the Probe Request frame within the wireless communication protocol.
This is something I really need to drill down into. If we're hitting `-ENOBUFS` here, it points to a potential buffer overflow vulnerability or a miscalculation in how we're allocating or sizing our packets. We could be setting ourselves up for a crash or, worse, a security exploit if an attacker can control the size or content of these IEs to trigger an overflow. I need to fully understand the conditions that lead to this `-ENOBUFS` return and how `skb_tailroom` is being managed in relation to the IEs. The implications of this are significant and require a deep dive into the code.
|
| 19/2 |
2026/06/16 00:05 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:net/mac80211/util.c Name:ieee80211_put_preq_ies_band]
Results: map[SourceCode:1258: static int ieee80211_put_preq_ies_band(struct sk_buff *skb,
1259: struct ieee80211_sub_if_data *sdata,
1260: const u8 *ie, size_t ie_len,
1261: size_t *offset,
1262: enum nl80211_band band,
1263: u32 rate_mask,
1264: struct cfg80211_chan_def *chandef,
1265: u32 flags)
1266: {
1267: struct ieee80211_local *local = sdata->local;
1268: struct ieee80211_supported_band *sband;
1269: int i, err;
1270: size_t noffset;
1271: bool have_80mhz = false;
1272:
1273: *offset = 0;
1274:
1275: sband = local->hw.wiphy->bands[band];
1276: if (WARN_ON_ONCE(!sband))
1277: return 0;
1278:
1279: /* For direct scan add S1G IE and consider its override bits */
1280: if (band == NL80211_BAND_S1GHZ)
1281: return ieee80211_put_s1g_cap(skb, &sband->s1g_cap);
1282:
1283: err = ieee80211_put_srates_elem(skb, sband, 0,
1284: ~rate_mask, WLAN_EID_SUPP_RATES);
1285: if (err)
1286: return err;
1287:
1288: /* insert "request information" if in custom IEs */
1289: if (ie && ie_len) {
1290: static const u8 before_extrates[] = {
1291: WLAN_EID_SSID,
1292: WLAN_EID_SUPP_RATES,
1293: WLAN_EID_REQUEST,
1294: };
1295: noffset = ieee80211_ie_split(ie, ie_len,
1296: before_extrates,
1297: ARRAY_SIZE(before_extrates),
1298: *offset);
1299: if (skb_tailroom(skb) < noffset - *offset)
1300: return -ENOBUFS;
1301: skb_put_data(skb, ie + *offset, noffset - *offset);
1302: *offset = noffset;
1303: }
1304:
1305: err = ieee80211_put_srates_elem(skb, sband, 0,
1306: ~rate_mask, WLAN_EID_EXT_SUPP_RATES);
1307: if (err)
1308: return err;
1309:
1310: if (chandef->chan && sband->band == NL80211_BAND_2GHZ) {
1311: if (skb_tailroom(skb) < 3)
1312: return -ENOBUFS;
1313: skb_put_u8(skb, WLAN_EID_DS_PARAMS);
1314: skb_put_u8(skb, 1);
1315: skb_put_u8(skb,
1316: ieee80211_frequency_to_channel(chandef->chan->center_freq));
1317: }
1318:
1319: if (flags & IEEE80211_PROBE_FLAG_MIN_CONTENT)
1320: return 0;
1321:
1322: /* insert custom IEs that go before HT */
1323: if (ie && ie_len) {
1324: static const u8 before_ht[] = {
1325: /*
1326: * no need to list the ones split off already
1327: * (or generated here)
1328: */
1329: WLAN_EID_DS_PARAMS,
1330: WLAN_EID_SUPPORTED_REGULATORY_CLASSES,
1331: };
1332: noffset = ieee80211_ie_split(ie, ie_len,
1333: before_ht, ARRAY_SIZE(before_ht),
1334: *offset);
1335: if (skb_tailroom(skb) < noffset - *offset)
1336: return -ENOBUFS;
1337: skb_put_data(skb, ie + *offset, noffset - *offset);
1338: *offset = noffset;
1339: }
1340:
1341: if (sband->ht_cap.ht_supported) {
1342: u8 *pos;
1343:
1344: if (skb_tailroom(skb) < 2 + sizeof(struct ieee80211_ht_cap))
1345: return -ENOBUFS;
1346:
1347: pos = skb_put(skb, 2 + sizeof(struct ieee80211_ht_cap));
1348: ieee80211_ie_build_ht_cap(pos, &sband->ht_cap,
1349: sband->ht_cap.cap);
1350: }
1351:
1352: /* insert custom IEs that go before VHT */
1353: if (ie && ie_len) {
1354: static const u8 before_vht[] = {
1355: /*
1356: * no need to list the ones split off already
1357: * (or generated here)
1358: */
1359: WLAN_EID_BSS_COEX_2040,
1360: WLAN_EID_EXT_CAPABILITY,
1361: WLAN_EID_SSID_LIST,
1362: WLAN_EID_CHANNEL_USAGE,
1363: WLAN_EID_INTERWORKING,
1364: WLAN_EID_MESH_ID,
1365: /* 60 GHz (Multi-band, DMG, MMS) can't happen */
1366: };
1367: noffset = ieee80211_ie_split(ie, ie_len,
1368: before_vht, ARRAY_SIZE(before_vht),
1369: *offset);
1370: if (skb_tailroom(skb) < noffset - *offset)
1371: return -ENOBUFS;
1372: skb_put_data(skb, ie + *offset, noffset - *offset);
1373: *offset = noffset;
1374: }
1375:
1376: /* Check if any channel in this sband supports at least 80 MHz */
1377: for (i = 0; i < sband->n_channels; i++) {
1378: if (sband->channels[i].flags & (IEEE80211_CHAN_DISABLED |
1379: IEEE80211_CHAN_NO_80MHZ))
1380: continue;
1381:
1382: have_80mhz = true;
1383: break;
1384: }
1385:
1386: if (sband->vht_cap.vht_supported && have_80mhz) {
1387: u8 *pos;
1388:
1389: if (skb_tailroom(skb) < 2 + sizeof(struct ieee80211_vht_cap))
1390: return -ENOBUFS;
1391:
1392: pos = skb_put(skb, 2 + sizeof(struct ieee80211_vht_cap));
1393: ieee80211_ie_build_vht_cap(pos, &sband->vht_cap,
1394: sband->vht_cap.cap);
1395: }
1396:
1397: /* insert custom IEs that go before HE */
1398: if (ie && ie_len) {
1399: static const u8 before_he[] = {
1400: /*
1401: * no need to list the ones split off before VHT
1402: * or generated here
1403: */
1404: WLAN_EID_EXTENSION, WLAN_EID_EXT_FILS_REQ_PARAMS,
1405: WLAN_EID_AP_CSN,
1406: /* TODO: add 11ah/11aj/11ak elements */
1407: };
1408: noffset = ieee80211_ie_split(ie, ie_len,
1409: before_he, ARRAY_SIZE(before_he),
1410: *offset);
1411: if (skb_tailroom(skb) < noffset - *offset)
1412: return -ENOBUFS;
1413: skb_put_data(skb, ie + *offset, noffset - *offset);
1414: *offset = noffset;
1415: }
1416:
1417: if (cfg80211_any_usable_channels(local->hw.wiphy, BIT(sband->band),
1418: IEEE80211_CHAN_NO_HE)) {
1419: err = ieee80211_put_he_cap(skb, sdata, sband, NULL);
1420: if (err)
1421: return err;
1422: }
1423:
1424: if (cfg80211_any_usable_channels(local->hw.wiphy, BIT(sband->band),
1425: IEEE80211_CHAN_NO_HE |
1426: IEEE80211_CHAN_NO_EHT)) {
1427: err = ieee80211_put_eht_cap(skb, sdata, sband, NULL);
1428: if (err)
1429: return err;
1430: }
1431:
1432: err = ieee80211_put_he_6ghz_cap(skb, sdata, IEEE80211_SMPS_OFF);
1433: if (err)
1434: return err;
1435:
1436: if (cfg80211_any_usable_channels(local->hw.wiphy, BIT(sband->band),
1437: IEEE80211_CHAN_NO_UHR)) {
1438: err = ieee80211_put_uhr_cap(skb, sdata, sband);
1439: if (err)
1440: return err;
1441: }
1442:
1443: /*
1444: * If adding more here, adjust code in main.c
1445: * that calculates local->scan_ies_len.
1446: */
1447:
1448: return 0;
1449: }
SourceFile:net/mac80211/util.c]
|
| 20/2 |
2026/06/16 00:05 |
llm |
expert |
0m
Model:
Tokens:
input: 20931
output: 22
thoughts: 70
Thoughts: **Analyzing Potential Buffer Issues**
Okay, so I'm digging into this code and I've just realized something potentially significant. It looks like `local->scan_ies_len` is being calculated in `main.c`. My immediate concern is that if this length isn't large enough, we could run into a problem with `skb_tailroom` returning `-ENOBUFS` due to insufficient buffer space. That's a classic error that can rear its ugly head in network drivers. Therefore, I need to understand this calculation, I need to quickly determine where `local->scan_ies_len` is calculated, to ensure that the code will correctly estimate the length of the Information Element (IE) scan data. Then I will need to look at how we are allocating the data buffer.
|
| 21/2 |
2026/06/16 00:05 |
tool |
grepper |
0m
Args: map[Expression:local->scan_ies_len =]
Results: map[Output:net/mac80211/main.c=1134=int ieee80211_register_hw(struct ieee80211_hw *hw)
--
net/mac80211/main.c-1432- */
net/mac80211/main.c:1433: local->scan_ies_len = 4 + max_bitrates /* (ext) supp rates */ +
net/mac80211/main.c-1434- 3 /* DS Params */;
]
|
| 22/2 |
2026/06/16 00:05 |
llm |
expert |
0m
Model:
Tokens:
input: 21338
output: 41
thoughts: 17
Thoughts: Okay, let's dive in.
***
**Digging into the Code at `main.c`**
Alright, I'm thinking I need to understand what's happening at line 1433 in `main.c`. It's time to pull up the file and take a look. I'm hoping whatever is there will immediately illuminate the issue or the next step in debugging. Let's see what that area of the code is doing and quickly parse the logic. My expert eye should be able to sift through that section of the source pretty quickly. From there I'll be able to confirm or modify my current hypothesis.
|
| 23/2 |
2026/06/16 00:05 |
tool |
read-file |
0m
Args: map[File:net/mac80211/main.c FirstLine:1420 LineCount:50]
Results: map[Contents:1420: NL80211_EXT_FEATURE_EXT_KEY_ID);
1421: }
1422:
1423: if (local->hw.wiphy->interface_modes & BIT(NL80211_IFTYPE_ADHOC))
1424: wiphy_ext_feature_set(local->hw.wiphy,
1425: NL80211_EXT_FEATURE_DEL_IBSS_STA);
1426:
1427: /*
1428: * Calculate scan IE length -- we need this to alloc
1429: * memory and to subtract from the driver limit. It
1430: * includes the DS Params, (extended) supported rates, and HT
1431: * information -- SSID is the driver's responsibility.
1432: */
1433: local->scan_ies_len = 4 + max_bitrates /* (ext) supp rates */ +
1434: 3 /* DS Params */;
1435: if (supp_ht)
1436: local->scan_ies_len += 2 + sizeof(struct ieee80211_ht_cap);
1437:
1438: if (supp_vht)
1439: local->scan_ies_len +=
1440: 2 + sizeof(struct ieee80211_vht_cap);
1441:
1442: if (supp_s1g)
1443: local->scan_ies_len += 2 + sizeof(struct ieee80211_s1g_cap);
1444:
1445: /*
1446: * HE cap element is variable in size - set len to allow max size */
1447: if (supp_he) {
1448: local->scan_ies_len +=
1449: 3 + sizeof(struct ieee80211_he_cap_elem) +
1450: sizeof(struct ieee80211_he_mcs_nss_supp) +
1451: IEEE80211_HE_PPE_THRES_MAX_LEN;
1452:
1453: if (supp_eht)
1454: local->scan_ies_len +=
1455: 3 + sizeof(struct ieee80211_eht_cap_elem) +
1456: sizeof(struct ieee80211_eht_mcs_nss_supp) +
1457: IEEE80211_EHT_PPE_THRES_MAX_LEN;
1458: }
1459:
1460: if (supp_uhr)
1461: local->scan_ies_len +=
1462: 3 + sizeof(struct ieee80211_uhr_cap) +
1463: sizeof(struct ieee80211_uhr_cap_phy);
1464:
1465: if (!local->ops->hw_scan) {
1466: /* For hw_scan, driver needs to set these up. */
1467: local->hw.wiphy->max_scan_ssids = 4;
1468: local->hw.wiphy->max_scan_ie_len = IEEE80211_MAX_DATA_LEN;
1469: }
]
|
| 24/2 |
2026/06/16 00:05 |
llm |
expert |
0m
Model:
Tokens:
input: 22447
output: 53
thoughts: 398
Thoughts: **Investigating HE 6 GHz Capability in Scan IEs**
Okay, hold on a second. I just saw that `ieee80211_put_preq_ies_band` includes a call to `ieee80211_put_he_6ghz_cap`. It's adding that HE 6 GHz capability element, which is important. But... is `he_6ghz_cap` actually accounted for in `local->scan_ies_len`? I need to verify this because the length calculation is critical for the correct allocation of scan IEs.
Let's look at `main.c`. Hmm, I see entries for HE, EHT, and UHR capabilities, which makes sense. I see the addition to the scan length calculations based on `supp_he`, `supp_eht`, and `supp_uhr` values. But... where's the HE 6 GHz capability? I don't see anything explicitly adding to `local->scan_ies_len` for it. That's a definite oversight!
I need to dig deeper. I'm going to check the implementation of `ieee80211_put_he_6ghz_cap` right now to understand how it's handled, and to confirm that it's not somehow indirectly captured elsewhere. This needs immediate attention, otherwise our scan IEs will be truncated, leading to incorrect behavior.
|
| 25/2 |
2026/06/16 00:05 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:net/mac80211/util.c Name:ieee80211_put_he_6ghz_cap]
Results: map[SourceCode:2723: int ieee80211_put_he_6ghz_cap(struct sk_buff *skb,
2724: struct ieee80211_sub_if_data *sdata,
2725: enum ieee80211_smps_mode smps_mode)
2726: {
2727: struct ieee80211_supported_band *sband;
2728: const struct ieee80211_sband_iftype_data *iftd;
2729: enum nl80211_iftype iftype = ieee80211_vif_type_p2p(&sdata->vif);
2730: __le16 cap;
2731:
2732: if (!cfg80211_any_usable_channels(sdata->local->hw.wiphy,
2733: BIT(NL80211_BAND_6GHZ),
2734: IEEE80211_CHAN_NO_HE))
2735: return 0;
2736:
2737: sband = sdata->local->hw.wiphy->bands[NL80211_BAND_6GHZ];
2738:
2739: iftd = ieee80211_get_sband_iftype_data(sband, iftype);
2740: if (!iftd)
2741: return 0;
2742:
2743: /* Check for device HE 6 GHz capability before adding element */
2744: if (!iftd->he_6ghz_capa.capa)
2745: return 0;
2746:
2747: cap = iftd->he_6ghz_capa.capa;
2748: cap &= cpu_to_le16(~IEEE80211_HE_6GHZ_CAP_SM_PS);
2749:
2750: switch (smps_mode) {
2751: case IEEE80211_SMPS_AUTOMATIC:
2752: case IEEE80211_SMPS_NUM_MODES:
2753: WARN_ON(1);
2754: fallthrough;
2755: case IEEE80211_SMPS_OFF:
2756: cap |= le16_encode_bits(WLAN_HT_CAP_SM_PS_DISABLED,
2757: IEEE80211_HE_6GHZ_CAP_SM_PS);
2758: break;
2759: case IEEE80211_SMPS_STATIC:
2760: cap |= le16_encode_bits(WLAN_HT_CAP_SM_PS_STATIC,
2761: IEEE80211_HE_6GHZ_CAP_SM_PS);
2762: break;
2763: case IEEE80211_SMPS_DYNAMIC:
2764: cap |= le16_encode_bits(WLAN_HT_CAP_SM_PS_DYNAMIC,
2765: IEEE80211_HE_6GHZ_CAP_SM_PS);
2766: break;
2767: }
2768:
2769: if (skb_tailroom(skb) < 2 + 1 + sizeof(cap))
2770: return -ENOBUFS;
2771:
2772: skb_put_u8(skb, WLAN_EID_EXTENSION);
2773: skb_put_u8(skb, 1 + sizeof(cap));
2774: skb_put_u8(skb, WLAN_EID_EXT_HE_6GHZ_CAPA);
2775: skb_put_data(skb, &cap, sizeof(cap));
2776: return 0;
2777: }
SourceFile:net/mac80211/util.c]
|
| 26/2 |
2026/06/16 00:05 |
llm |
expert |
0m
Model:
Tokens:
input: 24306
output: 23
thoughts: 1283
Thoughts: **Analyzing the IEEE 802.11 Pre-Request IE Generation**
Okay, so I'm digging into this IE generation for the pre-request frame. I see that `ieee80211_put_he_6ghz_cap` adds 5 bytes, specifically `2 + 1 + sizeof(cap)`. The immediate question is, are there any other missing elements? Let's trace through the code. I need to re-examine `ieee80211_put_preq_ies_band`.
I note the conditional calls for HE and EHT capabilities based on usable channels, then the *unconditional* call to `ieee80211_put_he_6ghz_cap`. That feels odd, doesn't it? My intuition suggests a possible bug. Then I check inside the function. Ah, it conditionally adds the element *if* 6 GHz is usable. But wait - it's added for *every* band if 6 GHz is usable, even if the scan is on 2.4 or 5 GHz. Could that be right?
Now, if `SINGLE_SCAN_ON_ALL_BANDS` is enabled, the code calls `ieee80211_build_preq_ies` with multiple bands in `bands_used`. `ieee80211_put_preq_ies` iterates across those bands. So if we have, say, 2.4 GHz, 5 GHz, and 6 GHz in `bands_used`, `ieee80211_put_preq_ies_band` is called three times, each adding the `he_6ghz_cap` IE if 6 GHz is usable. This is key.
Then I remember that `local->scan_ies_len` is allocated per band *if* `SINGLE_SCAN_ON_ALL_BANDS` is set. So, the allocation is multiplied by the number of bands scanned. This could be where the problem lies.
So if the 5 bytes for `he_6ghz_cap` are missing from the *per-band* `local->scan_ies_len`, then the total buffer size is short by `5 * n_bands`. That means we will get a `skb_tailroom(skb) < ...` failure, which returns `-ENOBUFS`. That's bad. Then `ieee80211_prep_hw_scan` returns `false`, causing the `WARN_ON` to trigger.
So, the next step is verification. I have to verify that `he_6ghz_cap` is indeed missing from `local->scan_ies_len`. This is likely the root cause. This discrepancy will cause the buffer to be too small, causing the scan to fail and the `WARN_ON` to fire.
|
| 27/2 |
2026/06/16 00:05 |
tool |
grepper |
0m
Args: map[Expression:local->scan_ies_len \+=]
Results: map[Output:net/mac80211/main.c=1134=int ieee80211_register_hw(struct ieee80211_hw *hw)
--
net/mac80211/main.c-1435- if (supp_ht)
net/mac80211/main.c:1436: local->scan_ies_len += 2 + sizeof(struct ieee80211_ht_cap);
net/mac80211/main.c-1437-
net/mac80211/main.c-1438- if (supp_vht)
net/mac80211/main.c:1439: local->scan_ies_len +=
net/mac80211/main.c-1440- 2 + sizeof(struct ieee80211_vht_cap);
--
net/mac80211/main.c-1442- if (supp_s1g)
net/mac80211/main.c:1443: local->scan_ies_len += 2 + sizeof(struct ieee80211_s1g_cap);
net/mac80211/main.c-1444-
--
net/mac80211/main.c-1447- if (supp_he) {
net/mac80211/main.c:1448: local->scan_ies_len +=
net/mac80211/main.c-1449- 3 + sizeof(struct ieee80211_he_cap_elem) +
--
net/mac80211/main.c-1453- if (supp_eht)
net/mac80211/main.c:1454: local->scan_ies_len +=
net/mac80211/main.c-1455- 3 + sizeof(struct ieee80211_eht_cap_elem) +
--
net/mac80211/main.c-1460- if (supp_uhr)
net/mac80211/main.c:1461: local->scan_ies_len +=
net/mac80211/main.c-1462- 3 + sizeof(struct ieee80211_uhr_cap) +
]
|
| 28/2 |
2026/06/16 00:05 |
llm |
expert |
0m
Model:
Tokens:
input: 26866
output: 39
thoughts: 406
Thoughts: **Analyzing Potential Length Discrepancies in Beacon IEs**
Okay, so I'm looking at how we're calculating the length of the Information Elements (IEs) in our beacon frames. It looks like `he_6ghz_cap` isn't currently being added to `local->scan_ies_len`. Hmm, but wait a minute, `ieee80211_put_he_6ghz_cap` *does* add 5 bytes (2 for the element ID and length, 1 for the element itself, and the size of the capability). So why isn't that reflected in the length calculation? That's definitely a point to investigate.
Let me think⦠is that the only missing piece? I should also check if we're accounting for `ieee80211_put_eht_cap`. In `main.c`, I see that if `supp_eht` is true, we are indeed adding the right size, which is:
```c
3 + sizeof(struct ieee80211_eht_cap_elem) +
sizeof(struct ieee80211_eht_mcs_nss_supp) +
IEEE80211_EHT_PPE_THRES_MAX_LEN;
```
What about `ieee80211_put_uhr_cap`? Okay, that part looks fine too:
```c
if (supp_uhr)
local->scan_ies_len +=
3 + sizeof(struct ieee80211_uhr_cap) +
sizeof(struct ieee80211_uhr_cap_phy);
```
And finally, `ieee80211_put_he_cap`:
```c
local->scan_ies_len +=
3 + sizeof(struct ieee80211_he_cap_elem) +
sizeof(struct ieee80211_he_mcs_nss_supp) +
IEEE80211_HE_PPE_THRES_MAX_LEN;
```
Ah, right, so the `ieee80211_put_he_6ghz_cap` was added recently, wasn't it? Let's quickly pull up the git log to verify when that function was introduced and if there are any related changes that might explain this.
|
| 29/2 |
2026/06/16 00:05 |
tool |
git-log |
10m
Error:
Args: map[CodeRegexp:ieee80211_put_he_6ghz_cap Count:10]
Results:
|
| 30/2 |
2026/06/16 00:15 |
llm |
expert |
0m
Model:
Tokens:
input: 27890
output: 57
thoughts: 19
Thoughts: Okay, here's my attempt at summarizing the thought process, as requested, geared toward an expert audience, and from a first-person perspective:
**Diving Deep into `net/mac80211/util.c`**
Alright, I need to focus my attention. Let's drill down into `net/mac80211/util.c`. This is where the core of some critical utility functions for mac80211 reside, and understanding these is key to troubleshooting or optimizing anything related to 802.11 wireless within the kernel. I know this file is a treasure trove of functionality. I need to refresh my memory on the critical areas: the data structures, error handling, or performance-critical routines. My goal is to use my knowledge to understand a specific problem I am looking at.
|
| 31/2 |
2026/06/16 00:16 |
tool |
git-log |
0m
Args: map[CodeRegexp:ieee80211_put_he_6ghz_cap Count:10 PathPrefix:net/mac80211/util.c]
Results: map[Output:28aa895bb0b3 wifi: mac80211: convert ieee80211_ie_build_he_cap() to SKB use
07095d167749 wifi: mac80211: start building elements in SKBs
552a26b3854e wifi: mac80211: rename ieee80211_ie_build_he_6ghz_cap()
]
|
| 32/2 |
2026/06/16 00:16 |
llm |
expert |
0m
Model:
Tokens:
input: 28268
output: 47
thoughts: 28
Thoughts: Here's my take on the thought process, summarized as you requested:
**Diving into the HE 6 GHz Capability Code**
Okay, time to get to the heart of this. My gut tells me the place to start digging for information related to High Efficiency (HE) 6 GHz capabilities is within the `net/mac80211` directory. Specifically, I'm betting the main implementation file, `main.c`, is the best starting point. I need to understand how the driver handles and represents this capability, so I'm focusing my search on the symbol `he_6ghz_cap`. Hopefully, it's a straightforward variable, structure member, or function call that I can quickly trace. Iβm expecting to find related structures and definitions around this symbol, maybe even some conditional logic that controls whether HE features are enabled. Let's see what we can uncover!
|
| 33/2 |
2026/06/16 00:16 |
tool |
git-log |
0m
Args: map[CodeRegexp:he_6ghz_cap Count:10 PathPrefix:net/mac80211/main.c]
Results:
|
| 34/2 |
2026/06/16 00:16 |
llm |
expert |
0m
Model:
Tokens:
input: 28545
output: 40
thoughts: 851
Thoughts: **Analyzing Potential Hardware Scan Issues**
Okay, so I'm looking at this hardware scan sequence and a potential problem is jumping out at me. I see that `he_6ghz_cap` was never explicitly added to `local->scan_ies_len` in `main.c`. That's the first thing that's concerning. I need to make sure this capability is accounted for, and I can see that `ieee80211_put_he_6ghz_cap` *does* add 5 bytes.
Now, if `local->scan_ies_len` is too small, `ieee80211_put_preq_ies_band` will return `-ENOBUFS`. Then, `ieee80211_prep_hw_scan` is supposed to return `false`. This would lead to a `WARN_ON` call. Originally, I thought that `WARN_ON` would prevent `drv_hw_scan` from executing, but that's not how it works!
So, even if `ieee80211_prep_hw_scan` returns `false`, `drv_hw_scan` *is* still called! This is where things get really interesting. If `ieee80211_prep_hw_scan` fails, then `local->hw_scan_req` could be in an incomplete state. Specifically, the length of the Information Elements (`IEs`) might be messed up.
Looking deeper, `ieee80211_prep_hw_scan` will return `false` if `ielen < 0`. I see the key bit in the code. If `ielen < 0`, `local->hw_scan_req->req.ie_len` is *not* updated. That means that `local->hw_scan_req->req.ie_len` remains uninitialized, which is a big problem.
Going back to where `local->hw_scan_req` is allocated in `__ieee80211_start_scan`, it's allocated with `kmalloc`, not `kzalloc`. This means the memory isn't zero-initialized. Therefore, `local->hw_scan_req->req.ie_len` is effectively garbage when `ieee80211_prep_hw_scan` is called. It's not explicitly initialized before that call! So the length of my IEs is potentially wrong, or uninitialized. That could lead to all sorts of issues when the driver tries to use this request. I should re-examine `__ieee80211_start_scan` to verify my analysis.
|
| 35/2 |
2026/06/16 00:16 |
tool |
read-file |
0m
Args: map[File:net/mac80211/scan.c FirstLine:780 LineCount:40]
Results: map[Contents: 780: local->hw_scan_req = kmalloc(struct_size(local->hw_scan_req,
781: req.channels,
782: req->n_channels) +
783: local->hw_scan_ies_bufsize,
784: GFP_KERNEL);
785: if (!local->hw_scan_req)
786: return -ENOMEM;
787:
788: local->hw_scan_req->req.ssids = req->ssids;
789: local->hw_scan_req->req.n_ssids = req->n_ssids;
790: /* None of the channels are actually set
791: * up but let UBSAN know the boundaries.
792: */
793: local->hw_scan_req->req.n_channels = req->n_channels;
794:
795: ies = (u8 *)local->hw_scan_req +
796: sizeof(*local->hw_scan_req) +
797: req->n_channels * sizeof(req->channels[0]);
798: local->hw_scan_req->req.ie = ies;
799: local->hw_scan_req->req.flags = req->flags;
800: eth_broadcast_addr(local->hw_scan_req->req.bssid);
801: local->hw_scan_req->req.duration = req->duration;
802: local->hw_scan_req->req.duration_mandatory =
803: req->duration_mandatory;
804: local->hw_scan_req->req.tsf_report_link_id =
805: req->tsf_report_link_id;
806:
807: local->hw_scan_band = 0;
808: local->hw_scan_req->req.n_6ghz_params = req->n_6ghz_params;
809: local->hw_scan_req->req.scan_6ghz_params =
810: req->scan_6ghz_params;
811: local->hw_scan_req->req.scan_6ghz = req->scan_6ghz;
812: local->hw_scan_req->req.first_part = req->first_part;
813:
814: /*
815: * After allocating local->hw_scan_req, we must
816: * go through until ieee80211_prep_hw_scan(), so
817: * anything that might be changed here and leave
818: * this function early must not go after this
819: * allocation.
]
|
| 36/2 |
2026/06/16 00:16 |
llm |
expert |
0m
Model:
Tokens:
input: 30774
output: 24
thoughts: 636
Thoughts: **Uninitialized Memory Vulnerability During Hardware Scan**
Okay, so I've been digging into this hardware scan process and, yep, it looks like there's a serious issue. My gut feeling was right: `local->hw_scan_req->req.ie_len` is *not* guaranteed to be initialized. In fact, if `ieee80211_prep_hw_scan` returns `false`, that crucial length value is left holding garbage. And then `drv_hw_scan` gets called with that uninitialized `ie_len`!
My immediate concern is an out-of-bounds read. The driver is going to try to read `ie_len` bytes from `ie`. Although `ie` *is* initialized to point to the `ies` buffer allocated at the end of `local->hw_scan_req`, if `ie_len` is garbage, especially a large value, it's going to read far past the end of the buffer! Kernel memory could be leaked, or worse, there's a good chance of a crash.
I also see that `mac_addr` and `mac_addr_mask` also might be left uninitialized, and this can be caused by the fact that `ieee80211_prep_hw_scan` could return false. I see that `bssid` is initialized to the broadcast address, so that's okay. But `mac_addr` and `mac_addr_mask` are set in `ieee80211_prep_hw_scan`, so if *that* returns `false`, they're also uninitialized!
The plot thickens: What else could cause `ieee80211_prep_hw_scan` to return `false`? Ah, right, a scan cancellation. There's a check for `SCAN_HW_CANCELLED`. And if that's set, it *also* returns `false`.
But wait a second... even if `SCAN_HW_CANCELLED` is set and `ieee80211_prep_hw_scan` returns `false`, the code *still* calls `drv_hw_scan`! It just throws a `WARN_ON`. That's not good enough! A `WARN_ON` is just a warning, it doesn't prevent execution. So, even though `ie_len`, `mac_addr`, and `mac_addr_mask` are uninitialized, the driver is still called with those uninitialized values! This is a massive bug! A scan cancellation can lead to a call to the driver with garbage data, potentially leading to all sorts of problems. I need to track down where `SCAN_HW_CANCELLED` is set and how the code is structured in that scenario.
|
| 37/2 |
2026/06/16 00:16 |
tool |
codesearch-find-references |
0m
Error:
Args: map[Name:SCAN_HW_CANCELLED]
Results: map[References:<nil> TruncatedOutput:false]
|
| 38/2 |
2026/06/16 00:16 |
llm |
expert |
0m
Model:
Tokens:
input: 32052
output: 20
thoughts: 13
Thoughts: Here's my take on those thoughts, tailored for an expert audience:
**Debugging a Hardware Scan Cancellation**
Alright, so I need to figure out why this hardware scan is getting cancelled. The first thing that pops into my head is to jump straight to grepping for the `SCAN_HW_CANCELLED` string. It's the most direct route to find where in the codebase the cancellation is being triggered. I'm assuming that string is unique enough to narrow down the search without too many false positives, and I can quickly filter the results. I'll need to remember to look at surrounding code, not just the exact line, to understand *why* the cancellation is happening. What conditions are being met? Are there any obvious race conditions or resource limitations at play? Time to get to work!
|
| 39/2 |
2026/06/16 00:16 |
tool |
grepper |
0m
Args: map[Expression:SCAN_HW_CANCELLED]
Results: map[Output:net/mac80211/ieee80211_i.h=1365=struct tpt_led_trigger {
--
net/mac80211/ieee80211_i.h-1390- * a scan complete for an aborted scan.
net/mac80211/ieee80211_i.h:1391: * @SCAN_HW_CANCELLED: Set for our scan work function when the scan is being
net/mac80211/ieee80211_i.h-1392- * cancelled.
--
net/mac80211/ieee80211_i.h=1397=enum mac80211_scan_flags {
--
net/mac80211/ieee80211_i.h-1402- SCAN_ABORTED,
net/mac80211/ieee80211_i.h:1403: SCAN_HW_CANCELLED,
net/mac80211/ieee80211_i.h-1404- SCAN_BEACON_WAIT,
--
net/mac80211/scan.c=379=static bool ieee80211_prep_hw_scan(struct ieee80211_sub_if_data *sdata)
--
net/mac80211/scan.c-391-
net/mac80211/scan.c:392: if (test_bit(SCAN_HW_CANCELLED, &local->scanning))
net/mac80211/scan.c-393- return false;
--
net/mac80211/scan.c=1275=void ieee80211_scan_cancel(struct ieee80211_local *local)
--
net/mac80211/scan.c-1307- test_bit(SCAN_COMPLETED, &local->scanning)) {
net/mac80211/scan.c:1308: set_bit(SCAN_HW_CANCELLED, &local->scanning);
net/mac80211/scan.c-1309- return;
--
net/mac80211/scan.c-1316- */
net/mac80211/scan.c:1317: set_bit(SCAN_HW_CANCELLED, &local->scanning);
net/mac80211/scan.c-1318- if (local->ops->cancel_hw_scan)
]
|
| 40/2 |
2026/06/16 00:16 |
llm |
expert |
0m
Model:
Tokens:
input: 32930
output: 46
thoughts: 618
Thoughts: **Vulnerability Analysis: Uninitialized Memory in Hardware Scan Request**
Okay, let's break this down. It seems we have a concurrency issue. `SCAN_HW_CANCELLED` can be set concurrently with the scan initiation. If the scan is cancelled mid-flight via `ieee80211_scan_cancel`, `ieee80211_prep_hw_scan` returns `false`. This triggers a sequence that's immediately concerning. `__ieee80211_start_scan` is still called, leading to a `WARN_ON` and a call to `drv_hw_scan`. The problem? `ie_len`, `mac_addr`, and `mac_addr_mask` are passed to the driver *uninitialized*.
The `local->hw_scan_req` structure, where these are stored, is allocated with `kmalloc`. Now, historically `kmalloc` doesn't guarantee zero initialization, especially in production kernels. Although newer kernels have mitigations like `init_on_alloc`, that's not guaranteed to be the default, and we need to consider the more common, production builds. So the memory is potentially uninitialized.
This means the driver will read `ie_len` from uninitialized memory. If that uninitialized value is large, the driver might read *out of bounds* of the `ie` buffer, which is itself part of `local->hw_scan_req`. Is this exploitable? That's the key question. We have uninitialized memory being used as the length field. The driver will subsequently copy `ie_len` bytes from the `ie` buffer.
Depending on *how* the driver uses this length and copies, we have potential vectors. If it copies to another buffer, we could be looking at a heap overflow in the driver. If it copies to the hardware directly, this potentially leaks kernel memory to the hardware β and potentially over the air through probe requests! Then, the uninitialized `mac_addr` and `mac_addr_mask` could leak kernel memory as well.
Now, wait... even if `kmalloc` *were* to zero the memory, in which case `ie_len` would be zero, that's safe. But KMSAN would detect uninitialized memory. The syzbot report is a *WARNING*, not a KMSAN report, so this suggests the memory isn't zeroed, and this indicates a more serious issue. The `ieee80211_prep_hw_scan` returning `false` is the trigger. We know this specific scenario arises from `nl80211_trigger_scan` -> `rdev_scan` -> `__ieee80211_start_scan`.
Crucially, this is a user-space triggerable bug via netlink (`nl80211_trigger_scan`). *That* is significant. User-space can trigger it. Netlink sockets are opened by unprivileged users with `CAP_NET_ADMIN` in the network namespace. So, we need to verify: does `nl80211_trigger_scan` actually require `CAP_NET_ADMIN`? If it does, and the checks are missing, this is a potential privilege escalation vector. I should double check the permissions there.
|
| 41/2 |
2026/06/16 00:16 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:net/wireless/nl80211.c Name:nl80211_trigger_scan]
Results: map[SourceCode:10814: static int nl80211_trigger_scan(struct sk_buff *skb, struct genl_info *info)
10815: {
10816: struct cfg80211_registered_device *rdev = info->user_ptr[0];
10817: struct wireless_dev *wdev = info->user_ptr[1];
10818: struct cfg80211_scan_request_int *request;
10819: struct nlattr *scan_freqs = NULL;
10820: bool scan_freqs_khz = false;
10821: struct nlattr *attr;
10822: struct wiphy *wiphy;
10823: int err, tmp, n_ssids = 0, n_channels, i;
10824: size_t ie_len, size;
10825: size_t ssids_offset, ie_offset;
10826:
10827: wiphy = &rdev->wiphy;
10828:
10829: if (wdev->iftype == NL80211_IFTYPE_NAN)
10830: return -EOPNOTSUPP;
10831:
10832: if (!rdev->ops->scan)
10833: return -EOPNOTSUPP;
10834:
10835: if (rdev->scan_req || rdev->scan_msg)
10836: return -EBUSY;
10837:
10838: if (info->attrs[NL80211_ATTR_SCAN_FREQ_KHZ]) {
10839: if (!wiphy_ext_feature_isset(wiphy,
10840: NL80211_EXT_FEATURE_SCAN_FREQ_KHZ))
10841: return -EOPNOTSUPP;
10842: scan_freqs = info->attrs[NL80211_ATTR_SCAN_FREQ_KHZ];
10843: scan_freqs_khz = true;
10844: } else if (info->attrs[NL80211_ATTR_SCAN_FREQUENCIES])
10845: scan_freqs = info->attrs[NL80211_ATTR_SCAN_FREQUENCIES];
10846:
10847: if (scan_freqs) {
10848: n_channels = validate_scan_freqs(scan_freqs);
10849: if (!n_channels)
10850: return -EINVAL;
10851: } else {
10852: n_channels = ieee80211_get_num_supported_channels(wiphy);
10853: }
10854:
10855: if (info->attrs[NL80211_ATTR_SCAN_SSIDS])
10856: nla_for_each_nested(attr, info->attrs[NL80211_ATTR_SCAN_SSIDS], tmp)
10857: n_ssids++;
10858:
10859: if (n_ssids > wiphy->max_scan_ssids)
10860: return -EINVAL;
10861:
10862: if (info->attrs[NL80211_ATTR_IE])
10863: ie_len = nla_len(info->attrs[NL80211_ATTR_IE]);
10864: else
10865: ie_len = 0;
10866:
10867: if (ie_len > wiphy->max_scan_ie_len)
10868: return -EINVAL;
10869:
10870: size = struct_size(request, req.channels, n_channels);
10871: ssids_offset = size;
10872: size = size_add(size, array_size(sizeof(*request->req.ssids), n_ssids));
10873: ie_offset = size;
10874: size = size_add(size, ie_len);
10875: request = kzalloc(size, GFP_KERNEL);
10876: if (!request)
10877: return -ENOMEM;
10878:
10879: if (n_ssids)
10880: request->req.ssids = (void *)request + ssids_offset;
10881: request->req.n_ssids = n_ssids;
10882: if (ie_len)
10883: request->req.ie = (void *)request + ie_offset;
10884:
10885: i = 0;
10886: if (scan_freqs) {
10887: /* user specified, bail out if channel not found */
10888: nla_for_each_nested(attr, scan_freqs, tmp) {
10889: struct ieee80211_channel *chan;
10890: int freq = nla_get_u32(attr);
10891:
10892: if (!scan_freqs_khz)
10893: freq = MHZ_TO_KHZ(freq);
10894:
10895: chan = ieee80211_get_channel_khz(wiphy, freq);
10896: if (!chan) {
10897: err = -EINVAL;
10898: goto out_free;
10899: }
10900:
10901: /* Ignore disabled / no primary channels */
10902: if (chan->flags & IEEE80211_CHAN_DISABLED ||
10903: chan->flags & IEEE80211_CHAN_S1G_NO_PRIMARY ||
10904: !cfg80211_wdev_channel_allowed(wdev, chan))
10905: continue;
10906:
10907: request->req.channels[i] = chan;
10908: i++;
10909: }
10910: } else {
10911: enum nl80211_band band;
10912:
10913: /* all channels */
10914: for (band = 0; band < NUM_NL80211_BANDS; band++) {
10915: int j;
10916:
10917: if (!wiphy->bands[band])
10918: continue;
10919: for (j = 0; j < wiphy->bands[band]->n_channels; j++) {
10920: struct ieee80211_channel *chan;
10921:
10922: chan = &wiphy->bands[band]->channels[j];
10923:
10924: if (chan->flags & IEEE80211_CHAN_DISABLED ||
10925: chan->flags &
10926: IEEE80211_CHAN_S1G_NO_PRIMARY ||
10927: !cfg80211_wdev_channel_allowed(wdev, chan))
10928: continue;
10929:
10930: request->req.channels[i] = chan;
10931: i++;
10932: }
10933: }
10934: }
10935:
10936: if (!i) {
10937: err = -EINVAL;
10938: goto out_free;
10939: }
10940:
10941: request->req.n_channels = i;
10942:
10943: for (i = 0; i < request->req.n_channels; i++) {
10944: struct ieee80211_channel *chan = request->req.channels[i];
10945:
10946: /* if we can go off-channel to the target channel we're good */
10947: if (cfg80211_off_channel_oper_allowed(wdev, chan))
10948: continue;
10949:
10950: if (!cfg80211_wdev_on_sub_chan(wdev, chan, true)) {
10951: err = -EBUSY;
10952: goto out_free;
10953: }
10954: }
10955:
10956: i = 0;
10957: if (n_ssids) {
10958: nla_for_each_nested(attr, info->attrs[NL80211_ATTR_SCAN_SSIDS], tmp) {
10959: if (nla_len(attr) > IEEE80211_MAX_SSID_LEN) {
10960: err = -EINVAL;
10961: goto out_free;
10962: }
10963: request->req.ssids[i].ssid_len = nla_len(attr);
10964: memcpy(request->req.ssids[i].ssid,
10965: nla_data(attr), nla_len(attr));
10966: i++;
10967: }
10968: }
10969:
10970: if (info->attrs[NL80211_ATTR_IE]) {
10971: request->req.ie_len = nla_len(info->attrs[NL80211_ATTR_IE]);
10972: memcpy((void *)request->req.ie,
10973: nla_data(info->attrs[NL80211_ATTR_IE]),
10974: request->req.ie_len);
10975: }
10976:
10977: for (i = 0; i < NUM_NL80211_BANDS; i++)
10978: if (wiphy->bands[i])
10979: request->req.rates[i] =
10980: (1 << wiphy->bands[i]->n_bitrates) - 1;
10981:
10982: if (info->attrs[NL80211_ATTR_SCAN_SUPP_RATES]) {
10983: nla_for_each_nested(attr,
10984: info->attrs[NL80211_ATTR_SCAN_SUPP_RATES],
10985: tmp) {
10986: int band = nla_type(attr);
10987:
10988: if (band < 0 || band >= NUM_NL80211_BANDS) {
10989: err = -EINVAL;
10990: goto out_free;
10991: }
10992:
10993: if (!wiphy->bands[band])
10994: continue;
10995:
10996: err = ieee80211_get_ratemask(wiphy->bands[band],
10997: nla_data(attr),
10998: nla_len(attr),
10999: &request->req.rates[band]);
11000: if (err)
11001: goto out_free;
11002: }
11003: }
11004:
11005: if (info->attrs[NL80211_ATTR_MEASUREMENT_DURATION]) {
11006: request->req.duration =
11007: nla_get_u16(info->attrs[NL80211_ATTR_MEASUREMENT_DURATION]);
11008: request->req.duration_mandatory =
11009: nla_get_flag(info->attrs[NL80211_ATTR_MEASUREMENT_DURATION_MANDATORY]);
11010: }
11011:
11012: err = nl80211_check_scan_flags_reg(wiphy, wdev, info->attrs, request);
11013: if (err)
11014: goto out_free;
11015:
11016: request->req.no_cck =
11017: nla_get_flag(info->attrs[NL80211_ATTR_TX_NO_CCK_RATE]);
11018:
11019: /* Initial implementation used NL80211_ATTR_MAC to set the specific
11020: * BSSID to scan for. This was problematic because that same attribute
11021: * was already used for another purpose (local random MAC address). The
11022: * NL80211_ATTR_BSSID attribute was added to fix this. For backwards
11023: * compatibility with older userspace components, also use the
11024: * NL80211_ATTR_MAC value here if it can be determined to be used for
11025: * the specific BSSID use case instead of the random MAC address
11026: * (NL80211_ATTR_SCAN_FLAGS is used to enable random MAC address use).
11027: */
11028: if (info->attrs[NL80211_ATTR_BSSID])
11029: memcpy(request->req.bssid,
11030: nla_data(info->attrs[NL80211_ATTR_BSSID]), ETH_ALEN);
11031: else if (!(request->req.flags & NL80211_SCAN_FLAG_RANDOM_ADDR) &&
11032: info->attrs[NL80211_ATTR_MAC])
11033: memcpy(request->req.bssid,
11034: nla_data(info->attrs[NL80211_ATTR_MAC]),
11035: ETH_ALEN);
11036: else
11037: eth_broadcast_addr(request->req.bssid);
11038:
11039: request->req.tsf_report_link_id =
11040: nl80211_link_id_or_invalid(info->attrs);
11041: request->req.wdev = wdev;
11042: request->req.wiphy = &rdev->wiphy;
11043: request->req.scan_start = jiffies;
11044:
11045: rdev->scan_req = request;
11046: err = cfg80211_scan(rdev);
11047:
11048: if (err)
11049: goto out_free;
11050:
11051: nl80211_send_scan_start(rdev, wdev);
11052: dev_hold(wdev->netdev);
11053:
11054: return 0;
11055:
11056: out_free:
11057: rdev->scan_req = NULL;
11058: kfree(request);
11059:
11060: return err;
11061: }
SourceFile:net/wireless/nl80211.c]
|
| 42/2 |
2026/06/16 00:16 |
llm |
expert |
0m
Model:
Tokens:
input: 38677
output: 26
thoughts: 55
Thoughts: Okay, let's see...
**Investigating a Network Scan Trigger Requirement**
Hold on a second, why is `nl80211_trigger_scan` demanding `GENL_ADMIN_PERM`? That seems a bit... restrictive. I need to understand the reasoning behind this. Let me quickly cross-reference that with the `nl80211_ops` structure. Specifically, I'll need to check the definition for `NL80211_CMD_TRIGGER_SCAN`. What exactly are the permissions associated with initiating a network scan through that command? I need to clarify if this is standard behavior, a potential security measure, or perhaps an oversight. The implications are potentially significant for a broader design choice.
|
| 43/2 |
2026/06/16 00:16 |
tool |
grepper |
0m
Args: map[Expression:NL80211_CMD_TRIGGER_SCAN]
Results: map[Output:include/uapi/linux/nl80211.h-499- * command was planned for has been provided with cleaner design with the
include/uapi/linux/nl80211.h:500: * option to specify additional IEs in NL80211_CMD_TRIGGER_SCAN,
include/uapi/linux/nl80211.h-501- * NL80211_CMD_AUTHENTICATE, NL80211_CMD_ASSOCIATE,
--
include/uapi/linux/nl80211.h-504- * @NL80211_CMD_GET_SCAN: get scan results
include/uapi/linux/nl80211.h:505: * @NL80211_CMD_TRIGGER_SCAN: trigger a new scan with the given parameters
include/uapi/linux/nl80211.h-506- * %NL80211_ATTR_TX_NO_CCK_RATE is used to decide whether to send the
--
include/uapi/linux/nl80211.h=1421=enum nl80211_commands {
--
include/uapi/linux/nl80211.h-1469- NL80211_CMD_GET_SCAN,
include/uapi/linux/nl80211.h:1470: NL80211_CMD_TRIGGER_SCAN,
include/uapi/linux/nl80211.h-1471- NL80211_CMD_NEW_SCAN_RESULTS,
--
include/uapi/linux/nl80211.h-2205- * applications use this attribute.
include/uapi/linux/nl80211.h:2206: * This attribute is used with %NL80211_CMD_TRIGGER_SCAN and
include/uapi/linux/nl80211.h-2207- * %NL80211_CMD_FRAME commands.
--
include/uapi/linux/nl80211.h-2595- * maximum measurement duration allowed. This attribute is used with
include/uapi/linux/nl80211.h:2596: * measurement requests. It can also be used with %NL80211_CMD_TRIGGER_SCAN
include/uapi/linux/nl80211.h-2597- * if the scan is used for beacon report radio measurement.
--
include/uapi/linux/nl80211.h=7157=enum nl80211_timeout_reason {
--
include/uapi/linux/nl80211.h-7167- * Scan request control flags are used to control the handling
include/uapi/linux/nl80211.h:7168: * of NL80211_CMD_TRIGGER_SCAN and NL80211_CMD_START_SCHED_SCAN
include/uapi/linux/nl80211.h-7169- * requests.
--
net/wireless/nl80211.c=19154=static const struct genl_small_ops nl80211_small_ops[] = {
--
net/wireless/nl80211.c-19369- {
net/wireless/nl80211.c:19370: .cmd = NL80211_CMD_TRIGGER_SCAN,
net/wireless/nl80211.c-19371- .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
--
net/wireless/nl80211.c=20209=void nl80211_send_scan_start(struct cfg80211_registered_device *rdev,
--
net/wireless/nl80211.c-20218- if (nl80211_prep_scan_msg(msg, rdev, wdev, 0, 0, 0,
net/wireless/nl80211.c:20219: NL80211_CMD_TRIGGER_SCAN) < 0) {
net/wireless/nl80211.c-20220- nlmsg_free(msg);
]
|
| 44/2 |
2026/06/16 00:16 |
llm |
expert |
0m
Model:
Tokens:
input: 40034
output: 42
thoughts: 31
Thoughts: Okay, here's my take on those thoughts, framed as an expert's internal monologue:
**Diving into the Scan Trigger Operations**
Alright, so we're looking at the scan trigger command, `NL80211_CMD_TRIGGER_SCAN`. Right away, my mind jumps to the relevant operations structure, `nl80211_small_ops`. I need to understand how the system *actually* handles the trigger. I need to see the function pointers. Are we talking about a simple immediate scan trigger or a more complex one? How is the scan defined? How is it communicated across the NL80211 interface? What kind of arguments are we dealing with? What is the function that is executed upon receiving this command? Is this function also used by other commands or is it dedicated for this particular command? My immediate goal is to understand how the trigger action is handled at the lowest level - the actual code path. I want to see how this trigger translates into actions within the wireless driver and, ultimately, the hardware. The `nl80211_small_ops` is where the core logic resides, or at least, the pointers to the core logic. Time to get my hands dirty.
|
| 45/2 |
2026/06/16 00:16 |
tool |
read-file |
0m
Args: map[File:net/wireless/nl80211.c FirstLine:19365 LineCount:20]
Results: map[Contents:19365: .doit = nl80211_update_mesh_config,
19366: .flags = GENL_UNS_ADMIN_PERM,
19367: .internal_flags = IFLAGS(NL80211_FLAG_NEED_NETDEV_UP),
19368: },
19369: {
19370: .cmd = NL80211_CMD_TRIGGER_SCAN,
19371: .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
19372: .doit = nl80211_trigger_scan,
19373: .flags = GENL_UNS_ADMIN_PERM,
19374: .internal_flags = IFLAGS(NL80211_FLAG_NEED_WDEV_UP),
19375: },
19376: {
19377: .cmd = NL80211_CMD_ABORT_SCAN,
19378: .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
19379: .doit = nl80211_abort_scan,
19380: .flags = GENL_UNS_ADMIN_PERM,
19381: .internal_flags = IFLAGS(NL80211_FLAG_NEED_WDEV_UP),
19382: },
19383: {
19384: .cmd = NL80211_CMD_GET_SCAN,
]
|
| 46/2 |
2026/06/16 00:16 |
llm |
expert |
0m
Model:
Tokens:
input: 40805
output: 21
thoughts: 1012
Thoughts: **Analyzing a Potential Kernel Vulnerability**
Okay, so I'm looking at this code and my initial thought is: this `.flags = GENL_UNS_ADMIN_PERM` thing. That means the call requires `CAP_NET_ADMIN` in the user namespace, which is interesting because that means user namespaces can trigger this! But wait... `GENL_UNS_ADMIN_PERM` actually means the *owning* namespace of the network namespace. Okay, yes, this is still accessible from user namespaces.
Alright, let's lay out the potential issue here, step-by-step, to make sure I've got this right:
1. We have `nl80211_trigger_scan` called from a user namespace with the necessary `CAP_NET_ADMIN` privilege.
2. That calls `rdev_scan`, which then hits `__ieee80211_start_scan`.
3. Inside `__ieee80211_start_scan`, we have `local->hw_scan_req` allocated with `kmalloc`. Now, `kmalloc` *doesn't* zero out memory, which is a potential issue if this is uninitialized data. We need to check those fields carefully.
4. Then, `ieee80211_prep_hw_scan` gets called. That, in turn, calls `ieee80211_build_preq_ies`.
5. `ieee80211_build_preq_ies` allocates an `skb` with the size of `local->hw_scan_ies_bufsize`.
6. `ieee80211_put_preq_ies` adds various IEs. Crucially, the code doesn't account for fields like `he_6ghz_cap` in `local->scan_ies_len` and that leads to insufficient `skb_tailroom(skb)`. That's a classic overflow scenario!
7. `ieee80211_put_preq_ies_band` returns `-ENOBUFS` because the buffer is too small.
8. `ieee80211_build_preq_ies` then returns `-ENOBUFS` (a negative value), signaling an error.
9. `ieee80211_prep_hw_scan` returns `false`.
10. `WARN_ON(!ieee80211_prep_hw_scan(sdata))` triggers, which is not ideal, but not the root cause.
11. Eventually, `drv_hw_scan` is called with `local->hw_scan_req`.
12. *This* is where it gets interesting: `local->hw_scan_req->req.ie_len` is uninitialized.
13. The driver *reads* `ie_len` bytes from `ie`, which is bad news. This could be an out-of-bounds read, potentially leading to memory disclosure or a crash, if we can control `ie_len`.
Wait, let's back up a second. Is `ie_len` *really* uninitialized? Let me double-check that allocation again:
```c
local->hw_scan_req = kmalloc(struct_size(local->hw_scan_req,
req.channels,
req->n_channels) +
local->hw_scan_ies_bufsize,
GFP_KERNEL);
```
Yep, `kmalloc` does *not* zero memory. Okay, so that's confirmed. Now, wait a minute, `struct cfg80211_scan_request` has an `ie_len` field:
```c
struct cfg80211_scan_request {
struct cfg80211_ssid *ssids;
int n_ssids;
struct cfg80211_channel **channels;
int n_channels;
const u8 *ie;
size_t ie_len;
...
```
Right, and `local->hw_scan_req` is of type `struct ieee80211_hw_scan_req`, which contains a `cfg80211_scan_request`!
```c
struct ieee80211_hw_scan_req {
struct cfg80211_scan_request req;
struct ieee80211_scan_ies ies;
};
```
Yes, `req
|
| 47/2 |
2026/06/16 00:17 |
tool |
codesearch-find-references |
0m
Error:
Args:
Results: map[References:<nil> TruncatedOutput:false]
|
| 48/2 |
2026/06/16 00:17 |
llm |
expert |
0m
Model:
Tokens:
input: 42884
output: 20
thoughts: 20
Thoughts: Okay, here's my summary, taking the perspective of someone knowledgeable in network driver development:
**Hunting Down Hardware Scanning Implementations**
Right, time to dig into the wireless drivers. My goal is to understand how different hardware platforms handle the scanning process. I need to get a grip on where the `hw_scan` functionality is defined and implemented. Therefore, I need to look for examples of `.hw_scan =` within the wireless network driver directory. I will use `grep` to efficiently search the source code for usages of that. With that, I should get a pretty good overview.
|
| 49/2 |
2026/06/16 00:17 |
tool |
grepper |
0m
Args: map[Expression:\.hw_scan = ]
Results: map[Output:drivers/net/wireless/atmel/at76c50x-usb.c=2174=static const struct ieee80211_ops at76_ops = {
--
drivers/net/wireless/atmel/at76c50x-usb.c-2187- .stop = at76_mac80211_stop,
drivers/net/wireless/atmel/at76c50x-usb.c:2188: .hw_scan = at76_hw_scan,
drivers/net/wireless/atmel/at76c50x-usb.c-2189- .set_key = at76_set_key,
--
drivers/net/wireless/intel/iwlegacy/3945-mac.c=3399=static struct ieee80211_ops il3945_mac_ops __ro_after_init = {
--
drivers/net/wireless/intel/iwlegacy/3945-mac.c-3416- .bss_info_changed = il_mac_bss_info_changed,
drivers/net/wireless/intel/iwlegacy/3945-mac.c:3417: .hw_scan = il_mac_hw_scan,
drivers/net/wireless/intel/iwlegacy/3945-mac.c-3418- .sta_add = il3945_mac_sta_add,
--
drivers/net/wireless/intel/iwlegacy/3945-mac.c=3830=il3945_init(void)
--
drivers/net/wireless/intel/iwlegacy/3945-mac.c-3842- pr_info("hw_scan is disabled\n");
drivers/net/wireless/intel/iwlegacy/3945-mac.c:3843: il3945_mac_ops.hw_scan = NULL;
drivers/net/wireless/intel/iwlegacy/3945-mac.c-3844- }
--
drivers/net/wireless/intel/iwlegacy/4965-mac.c=6308=static const struct ieee80211_ops il4965_mac_ops = {
--
drivers/net/wireless/intel/iwlegacy/4965-mac.c-6327- .ampdu_action = il4965_mac_ampdu_action,
drivers/net/wireless/intel/iwlegacy/4965-mac.c:6328: .hw_scan = il_mac_hw_scan,
drivers/net/wireless/intel/iwlegacy/4965-mac.c-6329- .sta_add = il4965_mac_sta_add,
--
drivers/net/wireless/intel/iwlwifi/dvm/mac80211.c=1572=const struct ieee80211_ops iwlagn_hw_ops = {
--
drivers/net/wireless/intel/iwlwifi/dvm/mac80211.c-1596- .ampdu_action = iwlagn_mac_ampdu_action,
drivers/net/wireless/intel/iwlwifi/dvm/mac80211.c:1597: .hw_scan = iwlagn_mac_hw_scan,
drivers/net/wireless/intel/iwlwifi/dvm/mac80211.c-1598- .sta_notify = iwlagn_mac_sta_notify,
--
drivers/net/wireless/intel/iwlwifi/mld/mac80211.c=2780=const struct ieee80211_ops iwl_mld_hw_ops = {
--
drivers/net/wireless/intel/iwlwifi/mld/mac80211.c-2803- .set_key = iwl_mld_mac80211_set_key,
drivers/net/wireless/intel/iwlwifi/mld/mac80211.c:2804: .hw_scan = iwl_mld_mac80211_hw_scan,
drivers/net/wireless/intel/iwlwifi/mld/mac80211.c-2805- .cancel_hw_scan = iwl_mld_mac80211_cancel_hw_scan,
--
drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c=6345=const struct ieee80211_ops iwl_mvm_hw_ops = {
--
drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c-6360- .bss_info_changed = iwl_mvm_bss_info_changed,
drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c:6361: .hw_scan = iwl_mvm_mac_hw_scan,
drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c-6362- .cancel_hw_scan = iwl_mvm_mac_cancel_hw_scan,
--
drivers/net/wireless/intel/iwlwifi/mvm/mld-mac80211.c=889=const struct ieee80211_ops iwl_mvm_mld_hw_ops = {
--
drivers/net/wireless/intel/iwlwifi/mvm/mld-mac80211.c-905- .vif_cfg_changed = iwl_mvm_mld_vif_cfg_changed,
drivers/net/wireless/intel/iwlwifi/mvm/mld-mac80211.c:906: .hw_scan = iwl_mvm_mac_hw_scan,
drivers/net/wireless/intel/iwlwifi/mvm/mld-mac80211.c-907- .cancel_hw_scan = iwl_mvm_mac_cancel_hw_scan,
--
drivers/net/wireless/mediatek/mt76/mt7615/main.c=1318=const struct ieee80211_ops mt7615_ops = {
--
drivers/net/wireless/mediatek/mt76/mt7615/main.c-1353- .set_coverage_class = mt7615_set_coverage_class,
drivers/net/wireless/mediatek/mt76/mt7615/main.c:1354: .hw_scan = mt7615_hw_scan,
drivers/net/wireless/mediatek/mt76/mt7615/main.c-1355- .cancel_hw_scan = mt7615_cancel_hw_scan,
--
drivers/net/wireless/mediatek/mt76/mt7921/main.c=1531=const struct ieee80211_ops mt7921_ops = {
--
drivers/net/wireless/mediatek/mt76/mt7921/main.c-1565- .set_coverage_class = mt792x_set_coverage_class,
drivers/net/wireless/mediatek/mt76/mt7921/main.c:1566: .hw_scan = mt7921_hw_scan,
drivers/net/wireless/mediatek/mt76/mt7921/main.c-1567- .cancel_hw_scan = mt7921_cancel_hw_scan,
--
drivers/net/wireless/mediatek/mt76/mt7925/main.c=2413=const struct ieee80211_ops mt7925_ops = {
--
drivers/net/wireless/mediatek/mt76/mt7925/main.c-2446- .set_coverage_class = mt792x_set_coverage_class,
drivers/net/wireless/mediatek/mt76/mt7925/main.c:2447: .hw_scan = mt7925_hw_scan,
drivers/net/wireless/mediatek/mt76/mt7925/main.c-2448- .cancel_hw_scan = mt7925_cancel_hw_scan,
--
drivers/net/wireless/mediatek/mt76/mt7996/main.c=2505=const struct ieee80211_ops mt7996_ops = {
--
drivers/net/wireless/mediatek/mt76/mt7996/main.c-2528- .wake_tx_queue = mt76_wake_tx_queue,
drivers/net/wireless/mediatek/mt76/mt7996/main.c:2529: .hw_scan = mt76_hw_scan,
drivers/net/wireless/mediatek/mt76/mt7996/main.c-2530- .cancel_hw_scan = mt76_cancel_hw_scan,
--
drivers/net/wireless/rsi/rsi_91x_mac80211.c=1982=static const struct ieee80211_ops mac80211_ops = {
--
drivers/net/wireless/rsi/rsi_91x_mac80211.c-2011-#endif
drivers/net/wireless/rsi/rsi_91x_mac80211.c:2012: .hw_scan = rsi_mac80211_hw_scan_start,
drivers/net/wireless/rsi/rsi_91x_mac80211.c-2013- .cancel_hw_scan = rsi_mac80211_cancel_hw_scan,
--
drivers/net/wireless/ti/wl1251/main.c=1354=static const struct ieee80211_ops wl1251_ops = {
--
drivers/net/wireless/ti/wl1251/main.c-1368- .set_key = wl1251_op_set_key,
drivers/net/wireless/ti/wl1251/main.c:1369: .hw_scan = wl1251_op_hw_scan,
drivers/net/wireless/ti/wl1251/main.c-1370- .bss_info_changed = wl1251_op_bss_info_changed,
--
drivers/net/wireless/ti/wlcore/main.c=5989=static const struct ieee80211_ops wl1271_ops = {
--
drivers/net/wireless/ti/wlcore/main.c-6004- .set_key = wlcore_op_set_key,
drivers/net/wireless/ti/wlcore/main.c:6005: .hw_scan = wl1271_op_hw_scan,
drivers/net/wireless/ti/wlcore/main.c-6006- .cancel_hw_scan = wl1271_op_cancel_hw_scan,
--
drivers/net/wireless/virtual/mac80211_hwsim.c=4356=static const struct ieee80211_ops mac80211_hwsim_ops = {
--
drivers/net/wireless/virtual/mac80211_hwsim.c-4367-#define HWSIM_CHANCTX_OPS \
drivers/net/wireless/virtual/mac80211_hwsim.c:4368: .hw_scan = mac80211_hwsim_hw_scan, \
drivers/net/wireless/virtual/mac80211_hwsim.c-4369- .cancel_hw_scan = mac80211_hwsim_cancel_hw_scan, \
]
|
| 50/2 |
2026/06/16 00:17 |
llm |
expert |
0m
Model:
Tokens:
input: 46096
output: 56
thoughts: 41
Thoughts: Here's a summary of my thought process:
**Diving into the mac80211_hwsim Scanner**
Alright, time to dig into this. I need to refresh my memory on how the hardware scan functionality is handled within the mac80211_hwsim module. Specifically, I'm going to jump into the `drivers/net/wireless/virtual/mac80211_hwsim.c` file and zero in on the `mac80211_hwsim_hw_scan` function. I want to see how this virtual hardware is emulating or responding to scan requests. I'm expecting to find the key interaction points with the mac80211 core and the simulated hardware behavior within this function. I'll need to understand how it mimics the scanning process and handles results.
|
| 51/2 |
2026/06/16 00:17 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/net/wireless/virtual/mac80211_hwsim.c Name:mac80211_hwsim_hw_scan]
Results: map[SourceCode:3180: static int mac80211_hwsim_hw_scan(struct ieee80211_hw *hw,
3181: struct ieee80211_vif *vif,
3182: struct ieee80211_scan_request *hw_req)
3183: {
3184: struct mac80211_hwsim_data *hwsim = hw->priv;
3185: struct cfg80211_scan_request *req = &hw_req->req;
3186:
3187: mutex_lock(&hwsim->mutex);
3188: if (WARN_ON(hwsim->tmp_chan || hwsim->hw_scan_request)) {
3189: mutex_unlock(&hwsim->mutex);
3190: return -EBUSY;
3191: }
3192: hwsim->hw_scan_request = req;
3193: hwsim->hw_scan_vif = vif;
3194: hwsim->scan_chan_idx = 0;
3195: if (req->flags & NL80211_SCAN_FLAG_RANDOM_ADDR)
3196: get_random_mask_addr(hwsim->scan_addr,
3197: hw_req->req.mac_addr,
3198: hw_req->req.mac_addr_mask);
3199: else
3200: memcpy(hwsim->scan_addr, vif->addr, ETH_ALEN);
3201: memset(hwsim->survey_data, 0, sizeof(hwsim->survey_data));
3202: mutex_unlock(&hwsim->mutex);
3203:
3204: mac80211_hwsim_config_mac_nl(hw, hwsim->scan_addr, true);
3205: wiphy_dbg(hw->wiphy, "hwsim hw_scan request\n");
3206:
3207: ieee80211_queue_delayed_work(hwsim->hw, &hwsim->hw_scan, 0);
3208:
3209: return 0;
3210: }
SourceFile:drivers/net/wireless/virtual/mac80211_hwsim.c]
|
| 52/2 |
2026/06/16 00:17 |
llm |
expert |
0m
Model:
Tokens:
input: 47011
output: 58
thoughts: 43
Thoughts: Here's my attempt at summarizing the thought process, tailored for an expert audience:
**Diving into the iwl_mvm_mac_hw_scan Implementation**
Okay, time to get my hands dirty. I need to take a look at the hardware scanning function within the iwl_mvm driver. Let's start by navigating to `drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c`. Specifically, I'm after `iwl_mvm_mac_hw_scan`. That's where the core logic for hardware-assisted scanning, specific to the Intel wireless hardware using the MVM architecture, will be. I need to understand how the driver orchestrates the scan process from a mac80211 perspective, what commands it issues to the hardware, how it handles the scan results, and any specific optimizations or quirks it employs. I'm expecting to find details on beacon/probe request transmission, channel hopping, interrupt handling related to scan completion, and potential power management considerations during the scan operation. This will be the starting point to understand the interactions between the software layers.
|
| 53/2 |
2026/06/16 00:17 |
tool |
codesearch-definition-source |
0m
Error:
Args: map[ContextFile:drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c Name:iwl_mvm_mac_hw_scan]
Results: map[SourceCode: SourceFile:]
|
| 54/2 |
2026/06/16 00:17 |
llm |
expert |
0m
Model:
Tokens:
input: 47374
output: 25
thoughts: 18
Thoughts: Here's my thought process, summarized as you requested:
**Debugging a Network Driver**
Okay, so I'm diving into this network driver issue, and the first thing that pops into my head is to pinpoint where the problem might be occurring, especially since it relates to scanning functionality. Immediately, I think, "Let's use `grep`! That's the go-to tool for this kind of investigation." I figure I need to search the driver's code for specific functions or modules related to the scanning process. The specific kernel module `iwl_mvm_mac_hw_scan` sounds relevant, so that's the keyword I'll use. Grepping for that should highlight the relevant sections of code. This should be a good starting point to identify the relevant files or functions related to my issue. I'll focus on the returned lines to try and understand the issue.
|
| 55/2 |
2026/06/16 00:17 |
tool |
grepper |
0m
Args: map[Expression:iwl_mvm_mac_hw_scan]
Results: map[Output:drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c=3157=static void iwl_mvm_bss_info_changed(struct ieee80211_hw *hw,
--
drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c-3192-
drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c:3193:int iwl_mvm_mac_hw_scan(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c-3194- struct ieee80211_scan_request *hw_req)
--
drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c=6345=const struct ieee80211_ops iwl_mvm_hw_ops = {
--
drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c-6360- .bss_info_changed = iwl_mvm_bss_info_changed,
drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c:6361: .hw_scan = iwl_mvm_mac_hw_scan,
drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c-6362- .cancel_hw_scan = iwl_mvm_mac_cancel_hw_scan,
--
drivers/net/wireless/intel/iwlwifi/mvm/mld-mac80211.c=889=const struct ieee80211_ops iwl_mvm_mld_hw_ops = {
--
drivers/net/wireless/intel/iwlwifi/mvm/mld-mac80211.c-905- .vif_cfg_changed = iwl_mvm_mld_vif_cfg_changed,
drivers/net/wireless/intel/iwlwifi/mvm/mld-mac80211.c:906: .hw_scan = iwl_mvm_mac_hw_scan,
drivers/net/wireless/intel/iwlwifi/mvm/mld-mac80211.c-907- .cancel_hw_scan = iwl_mvm_mac_cancel_hw_scan,
--
drivers/net/wireless/intel/iwlwifi/mvm/mvm.h=2707=void iwl_mvm_configure_filter(struct ieee80211_hw *hw,
--
drivers/net/wireless/intel/iwlwifi/mvm/mvm.h-2709- unsigned int *total_flags, u64 multicast);
drivers/net/wireless/intel/iwlwifi/mvm/mvm.h:2710:int iwl_mvm_mac_hw_scan(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
drivers/net/wireless/intel/iwlwifi/mvm/mvm.h-2711- struct ieee80211_scan_request *hw_req);
]
|
| 56/2 |
2026/06/16 00:17 |
llm |
expert |
0m
Model:
Tokens:
input: 48458
output: 52
thoughts: 43
Thoughts: Okay, let's dive into this. Here's my take on `iwl_mvm_mac_hw_scan` in `drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c`.
**Diving Deep into the iwl_mvm Hardware Scan**
Alright, so I need to get into the heart of how this Intel Wi-Fi driver, specifically the MVM (Mesh Virtualization Manager) part, handles hardware scans. `iwl_mvm_mac_hw_scan` sounds like the prime function to examine. Given the function name, I'm expecting this is where the interaction between the MAC layer and the hardware for initiating and managing a scan resides. I'm keen to understand how the driver orchestrates the scan process, and I want to see:
* **How the scan request is prepared:** What data structures are filled? What parameters are passed to the hardware? I'll be looking for things like channel lists, scan types (active, passive, etc.), and any specific hardware flags or configurations related to the scan operation.
* **The interaction with the firmware:** How is this information communicated to the firmware that manages the radio? I'm anticipating some form of command queue or message exchange mechanism. I want to see how the driver deals with firmware responses, errors, and progress reports related to the scan. Is there a polling mechanism or interrupt-driven model?
* **Resource Management:** How does the driver handle the necessary resources, such as DMA buffers, interrupts, or other hardware registers during the scan? I'll be curious about the synchronization and locking mechanisms it uses to ensure thread-safety and prevent conflicts.
* **Integration with the Mac80211 layer:** How does this function relate to the broader Mac80211 framework? I expect to see calls to Mac80211 functions for things like registering scan results or handling scan completion events. I'll need to see how the hardware scan integrates with the higher-level scanning framework.
* **Error Handling:** What happens if the hardware scan fails? How does the driver report errors back to the Mac80211 layer? I'll be looking for any specific error codes or retry mechanisms the function might employ.
* **Power Management Consideration:** Is there any consideration for power management during the scan? Does it handle any power-saving mechanisms to reduce the impact of the hardware scan on the system's power consumption?
Basically, I want to understand the complete control flow of the hardware scan, from the perspective of the kernel driver. I'm hoping I'll be able to trace how this function manages the scan, and also where the main interactions with the hardware occur.
|
| 57/2 |
2026/06/16 00:17 |
tool |
read-file |
0m
Args: map[File:drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c FirstLine:3193 LineCount:50]
Results: map[Contents:3193: int iwl_mvm_mac_hw_scan(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
3194: struct ieee80211_scan_request *hw_req)
3195: {
3196: struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
3197:
3198: if (hw_req->req.n_channels == 0 ||
3199: hw_req->req.n_channels > mvm->fw->ucode_capa.n_scan_channels)
3200: return -EINVAL;
3201:
3202: guard(mvm)(mvm);
3203: return iwl_mvm_reg_scan_start(mvm, vif, &hw_req->req, &hw_req->ies);
3204: }
3205:
3206: void iwl_mvm_mac_cancel_hw_scan(struct ieee80211_hw *hw,
3207: struct ieee80211_vif *vif)
3208: {
3209: struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
3210:
3211: guard(mvm)(mvm);
3212:
3213: /* Due to a race condition, it's possible that mac80211 asks
3214: * us to stop a hw_scan when it's already stopped. This can
3215: * happen, for instance, if we stopped the scan ourselves,
3216: * called ieee80211_scan_completed() and the userspace called
3217: * cancel scan before ieee80211_scan_work() could run.
3218: * To handle that, simply return if the scan is not running.
3219: */
3220: if (mvm->scan_status & IWL_MVM_SCAN_REGULAR)
3221: iwl_mvm_scan_stop(mvm, IWL_MVM_SCAN_REGULAR, true);
3222: }
3223:
3224: void
3225: iwl_mvm_mac_allow_buffered_frames(struct ieee80211_hw *hw,
3226: struct ieee80211_sta *sta, u16 tids,
3227: int num_frames,
3228: enum ieee80211_frame_release_type reason,
3229: bool more_data)
3230: {
3231: struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
3232:
3233: /* Called when we need to transmit (a) frame(s) from mac80211 */
3234:
3235: iwl_mvm_sta_modify_sleep_tx_count(mvm, sta, reason, num_frames,
3236: tids, more_data, false);
3237: }
3238:
3239: void
3240: iwl_mvm_mac_release_buffered_frames(struct ieee80211_hw *hw,
3241: struct ieee80211_sta *sta, u16 tids,
3242: int num_frames,
]
|
| 58/2 |
2026/06/16 00:17 |
llm |
expert |
0m
Model:
Tokens:
input: 50118
output: 53
thoughts: 17
Thoughts: Okay, here's my attempt at summarizing that thought process, keeping in mind I'm speaking to a fellow expert:
**Diving into `iwl_mvm_reg_scan_start`**
Alright, time to dig into this. "Let's check `iwl_mvm_reg_scan_start`." That's the first step. I need to understand how this function is working. I'm going to look at its definition, its call sites, and what its overall purpose is within the broader iwl_mvm context. I'm particularly interested in how it relates to channel scanning. Is it the entry point? Does it manage the hardware setup for the scan, or handle the results? What kind of state does it manage and how does it relate to the register scanning hardware? I need to quickly get a sense of the flow, the key data structures involved, and any potential areas of concern for performance or stability. Let's see what we can find.
|
| 59/2 |
2026/06/16 00:17 |
tool |
codesearch-definition-source |
0m
Error:
Args: map[ContextFile:drivers/net/wireless/intel/iwlwifi/mvm/scan.c Name:iwl_mvm_reg_scan_start]
Results: map[SourceCode: SourceFile:]
|
| 60/2 |
2026/06/16 00:17 |
llm |
expert |
0m
Model:
Tokens:
input: 50418
output: 25
thoughts: 18
Thoughts: Here's my attempt at summarizing the thought process, tailored for an expert audience:
**Diving into the Wireless Kernel Module**
Okay, so I need to understand what's happening with the wireless networking driver, specifically, something related to the regulatory scan initiation. My initial instinct is to pinpoint the exact function responsible. Let's start with a classic: I'm going to reach for `grep`. I'm thinking I'll search for `iwl_mvm_reg_scan_start`. That function name feels right, like the place where the regulatory scanning process is kicked off within the `iwlwifi` module, specifically the MVM (Mesh Virtualization Manager) part. This should give me a good entry point to trace the call chain or see where this function is utilized, hopefully to understand the triggers and context surrounding the start of a regulatory scan within the `iwlwifi` driver.
|
| 61/2 |
2026/06/16 00:17 |
tool |
grepper |
0m
Args: map[Expression:iwl_mvm_reg_scan_start]
Results: map[Output:drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c=3193=int iwl_mvm_mac_hw_scan(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
--
drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c-3202- guard(mvm)(mvm);
drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c:3203: return iwl_mvm_reg_scan_start(mvm, vif, &hw_req->req, &hw_req->ies);
drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c-3204-}
--
drivers/net/wireless/intel/iwlwifi/mvm/mvm.h=2036=int iwl_mvm_update_quotas(struct iwl_mvm *mvm, bool force_upload,
--
drivers/net/wireless/intel/iwlwifi/mvm/mvm.h-2039-/* Scanning */
drivers/net/wireless/intel/iwlwifi/mvm/mvm.h:2040:int iwl_mvm_reg_scan_start(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
drivers/net/wireless/intel/iwlwifi/mvm/mvm.h-2041- struct cfg80211_scan_request *req,
--
drivers/net/wireless/intel/iwlwifi/mvm/scan.c=2966=static int _iwl_mvm_single_scan_start(struct iwl_mvm *mvm,
--
drivers/net/wireless/intel/iwlwifi/mvm/scan.c-3068-
drivers/net/wireless/intel/iwlwifi/mvm/scan.c:3069:int iwl_mvm_reg_scan_start(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
drivers/net/wireless/intel/iwlwifi/mvm/scan.c-3070- struct cfg80211_scan_request *req,
]
|
| 62/2 |
2026/06/16 00:17 |
llm |
expert |
0m
Model:
Tokens:
input: 51242
output: 47
thoughts: 38
Thoughts: Here's a first-person summary, tailored as requested:
**Diving into the iwl_mvm_reg_scan_start function**
Okay, let's get into the nitty-gritty of the Intel wireless driver. I need to understand how the regulatory scan is initiated in the context of the MVM (Mesh Virtual Machine) architecture. So, I'm heading straight for the `iwl_mvm_reg_scan_start` function. Let's see how it's implemented within `drivers/net/wireless/intel/iwlwifi/mvm/scan.c`. I'm especially interested in how the driver interfaces with the firmware to actually start the regulatory scan process. What's the triggering mechanism? What parameters are passed? How does the firmware signal scan completion or any regulatory issues? I'm hoping to dissect how the MVM handles channel selection and power constraints during this process, and how they interact to find and comply with the regulatory rules set for the operating region. My immediate goal is to understand the control flow, any critical data structures, and the overall strategy here.
|
| 63/2 |
2026/06/16 00:17 |
tool |
read-file |
0m
Args: map[File:drivers/net/wireless/intel/iwlwifi/mvm/scan.c FirstLine:3069 LineCount:50]
Results: map[Contents:3069: int iwl_mvm_reg_scan_start(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
3070: struct cfg80211_scan_request *req,
3071: struct ieee80211_scan_ies *ies)
3072: {
3073: return _iwl_mvm_single_scan_start(mvm, vif, req, ies,
3074: IWL_MVM_SCAN_REGULAR);
3075: }
3076:
3077: int iwl_mvm_sched_scan_start(struct iwl_mvm *mvm,
3078: struct ieee80211_vif *vif,
3079: struct cfg80211_sched_scan_request *req,
3080: struct ieee80211_scan_ies *ies,
3081: int type)
3082: {
3083: struct iwl_host_cmd hcmd = {
3084: .len = { iwl_mvm_scan_size(mvm), },
3085: .data = { mvm->scan_cmd, },
3086: .dataflags = { IWL_HCMD_DFL_NOCOPY, },
3087: };
3088: struct iwl_mvm_scan_params params = {};
3089: int ret, uid;
3090: int i, j;
3091: bool non_psc_included = false;
3092:
3093: lockdep_assert_held(&mvm->mutex);
3094:
3095: if (iwl_mvm_is_lar_supported(mvm) && !mvm->lar_regdom_set) {
3096: IWL_ERR(mvm, "sched-scan while LAR regdomain is not set\n");
3097: return -EBUSY;
3098: }
3099:
3100: ret = iwl_mvm_check_running_scans(mvm, type);
3101: if (ret)
3102: return ret;
3103:
3104: /* we should have failed registration if scan_cmd was NULL */
3105: if (WARN_ON(!mvm->scan_cmd))
3106: return -ENOMEM;
3107:
3108:
3109: params.n_ssids = req->n_ssids;
3110: params.flags = req->flags;
3111: params.n_channels = req->n_channels;
3112: params.ssids = req->ssids;
3113: params.channels = req->channels;
3114: params.mac_addr = req->mac_addr;
3115: params.mac_addr_mask = req->mac_addr_mask;
3116: params.no_cck = false;
3117: params.pass_all = iwl_mvm_scan_pass_all(mvm, req);
3118: params.n_match_sets = req->n_match_sets;
]
|
| 64/2 |
2026/06/16 00:17 |
llm |
expert |
0m
Model:
Tokens:
input: 52459
output: 48
thoughts: 18
Thoughts: Okay, here's my interpretation of what's going through my mind as I approach this code:
**Diving into `_iwl_mvm_single_scan_start`**
Alright, let's get into this. I'm looking at `_iwl_mvm_single_scan_start`. Given the naming convention and my understanding of the Intel Wireless driver, "iwl_mvm", I'm betting this is the function responsible for initiating a single scan operation within the MVM (Mesh Virtualization Manager) framework. My immediate thoughts are around its role in the overall scanning process. It probably sets up the scan parameters, tells the firmware what to do, and perhaps initiates some hardware-specific configurations.
I'm expecting to see a clear sequence here: setting up scan parameters such as the channels, duration and type of scan (active, passive etc). I'm looking for the context which triggers this scan, so I will be looking for what calls this function, and what other actions take place around it.
My expert intuition suggests this will involve some interaction with the firmware β likely writing commands or data structures to the device's registers. I'm keeping an eye out for potential synchronization issues or race conditions, especially given that we're dealing with concurrent hardware and software tasks in a wireless context. I'm also ready to see some error handling β a good scan function needs to be robust.
Essentially, I'm expecting this to be the core "kick-off" point for a single wireless scan, and I'm eager to understand the specifics of how it's orchestrated within the MVM architecture.
|
| 65/2 |
2026/06/16 00:17 |
tool |
read-file |
0m
Args: map[File:drivers/net/wireless/intel/iwlwifi/mvm/scan.c FirstLine:2966 LineCount:100]
Results: map[Contents:2966: static int _iwl_mvm_single_scan_start(struct iwl_mvm *mvm,
2967: struct ieee80211_vif *vif,
2968: struct cfg80211_scan_request *req,
2969: struct ieee80211_scan_ies *ies,
2970: int type)
2971: {
2972: struct iwl_host_cmd hcmd = {
2973: .len = { iwl_mvm_scan_size(mvm), },
2974: .data = { mvm->scan_cmd, },
2975: .dataflags = { IWL_HCMD_DFL_NOCOPY, },
2976: };
2977: struct iwl_mvm_scan_params params = {};
2978: int ret, uid;
2979: struct cfg80211_sched_scan_plan scan_plan = { .iterations = 1 };
2980:
2981: lockdep_assert_held(&mvm->mutex);
2982:
2983: if (iwl_mvm_is_lar_supported(mvm) && !mvm->lar_regdom_set) {
2984: IWL_ERR(mvm, "scan while LAR regdomain is not set\n");
2985: return -EBUSY;
2986: }
2987:
2988: ret = iwl_mvm_check_running_scans(mvm, type);
2989: if (ret)
2990: return ret;
2991:
2992: /* we should have failed registration if scan_cmd was NULL */
2993: if (WARN_ON(!mvm->scan_cmd))
2994: return -ENOMEM;
2995:
2996: if (!iwl_mvm_scan_fits(mvm, req->n_ssids, ies, req->n_channels))
2997: return -ENOBUFS;
2998:
2999: params.n_ssids = req->n_ssids;
3000: params.flags = req->flags;
3001: params.n_channels = req->n_channels;
3002: params.delay = 0;
3003: params.ssids = req->ssids;
3004: params.channels = req->channels;
3005: params.mac_addr = req->mac_addr;
3006: params.mac_addr_mask = req->mac_addr_mask;
3007: params.no_cck = req->no_cck;
3008: params.pass_all = true;
3009: params.n_match_sets = 0;
3010: params.match_sets = NULL;
3011: ether_addr_copy(params.bssid, req->bssid);
3012:
3013: params.scan_plans = &scan_plan;
3014: params.n_scan_plans = 1;
3015:
3016: params.n_6ghz_params = req->n_6ghz_params;
3017: params.scan_6ghz_params = req->scan_6ghz_params;
3018: params.scan_6ghz = req->scan_6ghz;
3019: iwl_mvm_fill_scan_type(mvm, ¶ms, vif);
3020: iwl_mvm_fill_respect_p2p_go(mvm, ¶ms, vif);
3021:
3022: if (req->duration)
3023: params.iter_notif = true;
3024:
3025: params.tsf_report_link_id = req->tsf_report_link_id;
3026: if (params.tsf_report_link_id < 0)
3027: params.tsf_report_link_id = 0;
3028:
3029: iwl_mvm_build_scan_probe(mvm, vif, ies, ¶ms);
3030:
3031: iwl_mvm_scan_6ghz_passive_scan(mvm, ¶ms, vif);
3032:
3033: uid = iwl_mvm_build_scan_cmd(mvm, vif, &hcmd, ¶ms, type);
3034:
3035: if (uid < 0)
3036: return uid;
3037:
3038: iwl_mvm_pause_tcm(mvm, false);
3039:
3040: ret = iwl_mvm_send_cmd(mvm, &hcmd);
3041: if (ret) {
3042: /* If the scan failed, it usually means that the FW was unable
3043: * to allocate the time events. Warn on it, but maybe we
3044: * should try to send the command again with different params.
3045: */
3046: IWL_ERR(mvm, "Scan failed! ret %d\n", ret);
3047: iwl_mvm_resume_tcm(mvm);
3048: return ret;
3049: }
3050:
3051: IWL_DEBUG_SCAN(mvm, "Scan request send success: type=%u, uid=%u\n",
3052: type, uid);
3053:
3054: mvm->scan_uid_status[uid] = type;
3055: mvm->scan_status |= type;
3056:
3057: if (type == IWL_MVM_SCAN_REGULAR) {
3058: mvm->scan_vif = iwl_mvm_vif_from_mac80211(vif);
3059: schedule_delayed_work(&mvm->scan_timeout_dwork,
3060: msecs_to_jiffies(SCAN_TIMEOUT));
3061: }
3062:
3063: if (params.enable_6ghz_passive)
3064: mvm->last_6ghz_passive_scan_jiffies = jiffies;
3065:
]
|
| 66/2 |
2026/06/16 00:17 |
llm |
expert |
0m
Model:
Tokens:
input: 54624
output: 53
thoughts: 17
Thoughts: Okay, let's dive into this. Here's my thought process on checking `iwl_mvm_build_scan_probe`:
**Analyzing `iwl_mvm_build_scan_probe`**
Alright, so the first thing I'm thinking is, "Okay, `iwl_mvm_build_scan_probe`... that's the function within the Intel wireless driver (likely the MVM, or Mesh Virtual Machine, component) responsible for constructing the probe request frames during a Wi-Fi scan."
My immediate questions are: What's the context? What kind of scan is this? Is it passive, active, or something more specialized? Is this function called often, like on a timer? Or is it triggered only on specific events? I know this likely forms the heart of how the driver figures out what access points are available and collects their information.
I'm mentally stepping through what that function likely *does*: I imagine it taking various inputs β probably parameters related to the scan request, maybe some configuration data for the hardware, and maybe some sort of buffer to hold the crafted probe request frame. Internally, I assume it's constructing the frame. I need to be asking myself the following:
* How are the SSID and supported rates (if any) encoded?
* Are there other optional elements being added?
* How does this interaction affect security parameters?
My key concern is, are there any potential buffer overflows or other vulnerabilities related to frame construction? Is there any possibility of malformed probe requests leading to denial-of-service or information disclosure? I'll probably be looking at how input parameters are handled and what data gets copied into the frame buffer. Specifically, I'll be looking for any unchecked lengths or unbounded loops that could become a security concern.
I also wonder about performance. How efficient is this frame construction? Does it minimize the number of copies and calculations? What are the implications of the size of the probe request on scan time and power consumption? Optimizing scan performance is vital for a good user experience. I'll need to check if there are any obvious inefficiencies or areas for improvement in the code.
|
| 67/2 |
2026/06/16 00:18 |
tool |
codesearch-definition-source |
0m
Error:
Args: map[ContextFile:drivers/net/wireless/intel/iwlwifi/mvm/scan.c Name:iwl_mvm_build_scan_probe]
Results: map[SourceCode: SourceFile:]
|
| 68/2 |
2026/06/16 00:18 |
llm |
expert |
0m
Model:
Tokens:
input: 55170
output: 25
thoughts: 18
Thoughts: Here's my attempt at summarizing the thought process, tailored for an expert audience:
**Analyzing the `iwl_mvm_build_scan_probe` Context**
Okay, so I need to understand what's happening with `iwl_mvm_build_scan_probe`. Immediately, my mental approach is to use `grep`. I want to quickly pinpoint the key call sites and contexts surrounding that function within the relevant kernel module. The goal is to quickly understand how that function is being used. I'm thinking, "Where is it called? What data is being passed to it? What are the calling sequences that lead to its invocation?" This will give me a first-pass impression of its functionality, and from there I can delve deeper into the code to confirm its role in the WLAN scan process. Perhaps there are some bugs in related scan processes that can provide insight to the issue. I have a feeling this will involve examining data structures like the scan context or BSS descriptions.
|
| 69/2 |
2026/06/16 00:18 |
tool |
grepper |
0m
Args: map[Expression:iwl_mvm_build_scan_probe]
Results: map[Output:drivers/net/wireless/intel/iwlwifi/mvm/scan.c=751=static void
drivers/net/wireless/intel/iwlwifi/mvm/scan.c:752:iwl_mvm_build_scan_probe(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
drivers/net/wireless/intel/iwlwifi/mvm/scan.c-753- struct ieee80211_scan_ies *ies,
--
drivers/net/wireless/intel/iwlwifi/mvm/scan.c=2966=static int _iwl_mvm_single_scan_start(struct iwl_mvm *mvm,
--
drivers/net/wireless/intel/iwlwifi/mvm/scan.c-3028-
drivers/net/wireless/intel/iwlwifi/mvm/scan.c:3029: iwl_mvm_build_scan_probe(mvm, vif, ies, ¶ms);
drivers/net/wireless/intel/iwlwifi/mvm/scan.c-3030-
--
drivers/net/wireless/intel/iwlwifi/mvm/scan.c=3077=int iwl_mvm_sched_scan_start(struct iwl_mvm *mvm,
--
drivers/net/wireless/intel/iwlwifi/mvm/scan.c-3146-
drivers/net/wireless/intel/iwlwifi/mvm/scan.c:3147: iwl_mvm_build_scan_probe(mvm, vif, ies, ¶ms);
drivers/net/wireless/intel/iwlwifi/mvm/scan.c-3148-
]
|
| 70/2 |
2026/06/16 00:18 |
llm |
expert |
0m
Model:
Tokens:
input: 55860
output: 46
thoughts: 38
Thoughts: Here's a breakdown of my thought process:
**Diving into the iwl_mvm Scan Probe Build**
Okay, so I'm focusing in on `iwl_mvm_build_scan_probe` within the `iwlwifi` driver, specifically the `mvm` directory and the `scan.c` file. Right, that function is critical for building the actual probe request frames that the Intel wireless driver sends out during a scan. I need to understand exactly how the driver constructs these probe requests. What information is being included? Is it optimized for power consumption? Are there any obvious security vulnerabilities based on the information included? I need to analyze its structure, the data fields being populated, and how it interacts with the hardware. Understanding the generation of this probe request is paramount for understanding how a scan functions. I'm hoping I can find the nuances of how the MVM handles things like channel hopping and hidden networks here. Time to get my hands dirty.
|
| 71/2 |
2026/06/16 00:18 |
tool |
read-file |
0m
Args: map[File:drivers/net/wireless/intel/iwlwifi/mvm/scan.c FirstLine:751 LineCount:50]
Results: map[Contents: 751: static void
752: iwl_mvm_build_scan_probe(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
753: struct ieee80211_scan_ies *ies,
754: struct iwl_mvm_scan_params *params)
755: {
756: struct ieee80211_mgmt *frame = (void *)params->preq.buf;
757: u8 *pos, *newpos;
758: const u8 *mac_addr = params->flags & NL80211_SCAN_FLAG_RANDOM_ADDR ?
759: params->mac_addr : NULL;
760:
761: /*
762: * Unfortunately, right now the offload scan doesn't support randomising
763: * within the firmware, so until the firmware API is ready we implement
764: * it in the driver. This means that the scan iterations won't really be
765: * random, only when it's restarted, but at least that helps a bit.
766: */
767: if (mac_addr)
768: get_random_mask_addr(frame->sa, mac_addr,
769: params->mac_addr_mask);
770: else
771: memcpy(frame->sa, vif->addr, ETH_ALEN);
772:
773: frame->frame_control = cpu_to_le16(IEEE80211_STYPE_PROBE_REQ);
774: eth_broadcast_addr(frame->da);
775: ether_addr_copy(frame->bssid, params->bssid);
776: frame->seq_ctrl = 0;
777:
778: pos = frame->u.probe_req.variable;
779: *pos++ = WLAN_EID_SSID;
780: *pos++ = 0;
781:
782: params->preq.mac_header.offset = 0;
783: params->preq.mac_header.len = cpu_to_le16(24 + 2);
784:
785: /* Insert ds parameter set element on 2.4 GHz band */
786: newpos = iwl_mvm_copy_and_insert_ds_elem(mvm,
787: ies->ies[NL80211_BAND_2GHZ],
788: ies->len[NL80211_BAND_2GHZ],
789: pos);
790: params->preq.band_data[0].offset = cpu_to_le16(pos - params->preq.buf);
791: params->preq.band_data[0].len = cpu_to_le16(newpos - pos);
792: pos = newpos;
793:
794: memcpy(pos, ies->ies[NL80211_BAND_5GHZ],
795: ies->len[NL80211_BAND_5GHZ]);
796: params->preq.band_data[1].offset = cpu_to_le16(pos - params->preq.buf);
797: params->preq.band_data[1].len =
798: cpu_to_le16(ies->len[NL80211_BAND_5GHZ]);
799: pos += ies->len[NL80211_BAND_5GHZ];
800:
]
|
| 72/2 |
2026/06/16 00:18 |
llm |
expert |
0m
Model:
Tokens:
input: 57153
output: 52
thoughts: 602
Thoughts: **Uninitialized Memory Vulnerability in `iwl_mvm_build_scan_probe`**
Okay, so I'm looking at `iwl_mvm_build_scan_probe` and something's not right. It's using `ies->ies` and `ies->len`, and `ies` is a `struct ieee80211_scan_ies *ies`. This `ies` pointer is coming from `hw_req->ies`. Now, where does `hw_req->ies` get initialized? Ah, here it is: `ieee80211_prep_hw_scan`.
Hang on a second... if `ieee80211_prep_hw_scan` returns `false`, then `local->hw_scan_req->ies` *isn't* initialized! Now, I remember `local->hw_scan_req` is allocated with `kmalloc`. That means `local->hw_scan_req->ies` contains uninitialized memory!
Back in `iwl_mvm_build_scan_probe`, there's this line:
```c
newpos = iwl_mvm_copy_and_insert_ds_elem(mvm,
ies->ies[NL80211_BAND_2GHZ],
ies->len[NL80211_BAND_2GHZ],
pos);
```
Both `ies->len[NL80211_BAND_2GHZ]` and `ies->ies[NL80211_BAND_2GHZ]` are completely uninitialized! So, we're going to read from a wild pointer, `ies->ies[NL80211_BAND_2GHZ]` with a wild length. This is a classic uninitialized pointer dereference waiting to happen.
Since `local->hw_scan_req` is kmalloc'd, a clever attacker could spray the heap and potentially control the contents of `local->hw_scan_req->ies`. That means the attacker gets to control both `ies->ies[NL80211_BAND_2GHZ]` (which is a pointer) and `ies->len[NL80211_BAND_2GHZ]` (the length of the copy operation). `iwl_mvm_copy_and_insert_ds_elem` will happily copy `ies->len` bytes from `ies->ies` into `pos`.
Now, where does `pos` point? It's related to `params->preq.buf`. I need to confirm whether `params->preq.buf` is on the stack or the heap because that is critical in determining the impact of this vulnerability. Let's dig into `params->preq`...
|
| 73/2 |
2026/06/16 00:18 |
tool |
codesearch-definition-source |
0m
Error:
Args: map[ContextFile:drivers/net/wireless/intel/iwlwifi/mvm/mvm.h Name:iwl_mvm_scan_params]
Results: map[SourceCode: SourceFile:]
|
| 74/2 |
2026/06/16 00:18 |
llm |
expert |
0m
Model:
Tokens:
input: 58439
output: 25
thoughts: 18
Thoughts: Here's my thought process, as if I were analyzing that text:
**Diving into the iwl_mvm_scan_params Structure**
Okay, so the task at hand is to find all instances where the `struct iwl_mvm_scan_params` is used within the code base. That's a pretty straightforward request, and the best way to do that is absolutely to use `grep`. I want to quickly identify where this structure is defined and used, ideally within the context of the Intel Wireless driver (iwlwifi), specifically the MVM (Mesh Virtual Machine) component. Knowing this is the focus will help me narrow any further queries. From there, I can begin to unpack the data within the struct and how it is used.
|
| 75/2 |
2026/06/16 00:18 |
tool |
grepper |
0m
Args: map[Expression:struct iwl_mvm_scan_params \{]
Results: map[Output:drivers/net/wireless/intel/iwlwifi/mvm/scan.c=59=static struct iwl_mvm_scan_timing_params scan_timing[] = {
--
drivers/net/wireless/intel/iwlwifi/mvm/scan.c-81-
drivers/net/wireless/intel/iwlwifi/mvm/scan.c:82:struct iwl_mvm_scan_params {
drivers/net/wireless/intel/iwlwifi/mvm/scan.c-83- /* For CDB this is low band scan type, for non-CDB - type. */
]
|
| 76/2 |
2026/06/16 00:18 |
llm |
expert |
0m
Model:
Tokens:
input: 58797
output: 45
thoughts: 37
Thoughts: Here's my take on the `iwl_mvm_scan_params` structure:
**Deconstructing `iwl_mvm_scan_params`**
Alright, let's dive into this `iwl_mvm_scan_params` structure within the `iwlwifi` driver. My initial thought is to understand how the MVM (Mesh Virtual Machine) handles scanning. This structure *has* to define the parameters that are passed into the scan request, and, as an expert, I know these parameters are the key to configuring how aggressively the driver searches for networks. I'm expecting to see things like:
* **Channel Lists:** Obvious, this should specify what channels the firmware should sweep across. Different regulatory domains, and different operating modes, necessitate that we be flexible in how this is specified.
* **Scan Types:** Are we talking active scans (probing) or passive (listening)? Different levels of power usage and interference. Must have different modes.
* **Duration/Timeout:** How long should the driver dwell on a channel? Short dwells would be very efficient, long dwells may find more beacons.
* **Scan Flags:** Fine-grained control flags to configure things like background scans, hidden SSIDs and how to handle them, what kind of report should we get back?
* **Probe Requests:** The specific probe requests being sent out. Do we specify SSIDs in our probe requests? Or are we going to broadcast general requests? How do we handle directed scans.
* **Power Management:** How does the scan interact with power saving modes? I would expect we should see ways to influence how the radio interacts with power constraints.
* **Regulatory Restrictions:** Must take into account regulatory constraints of the current country code, which in turn influences channel selection and allowed transmission power during scans.
I'm also curious about its relationship to any overarching scan state or context. Is this a standalone data structure, or is it part of a larger scan configuration? Are there any associated locks or synchronization primitives used to manage concurrent access to this data? I anticipate a good amount of complexity due to the need to coordinate scan requests between the host and the firmware, which in turn can lead to several race conditions. Let's see how they've handled that. Now, let me get to reading the code itself.
|
| 77/2 |
2026/06/16 00:18 |
tool |
read-file |
0m
Args: map[File:drivers/net/wireless/intel/iwlwifi/mvm/scan.c FirstLine:82 LineCount:50]
Results: map[Contents: 82: struct iwl_mvm_scan_params {
83: /* For CDB this is low band scan type, for non-CDB - type. */
84: enum iwl_mvm_scan_type type;
85: enum iwl_mvm_scan_type hb_type;
86: u32 n_channels;
87: u16 delay;
88: int n_ssids;
89: struct cfg80211_ssid *ssids;
90: struct ieee80211_channel **channels;
91: u32 flags;
92: u8 *mac_addr;
93: u8 *mac_addr_mask;
94: bool no_cck;
95: bool pass_all;
96: int n_match_sets;
97: struct iwl_scan_probe_req preq;
98: struct cfg80211_match_set *match_sets;
99: int n_scan_plans;
100: struct cfg80211_sched_scan_plan *scan_plans;
101: bool iter_notif;
102: struct cfg80211_scan_6ghz_params *scan_6ghz_params;
103: u32 n_6ghz_params;
104: bool scan_6ghz;
105: bool enable_6ghz_passive;
106: bool respect_p2p_go, respect_p2p_go_hb;
107: s8 tsf_report_link_id;
108: u8 bssid[ETH_ALEN] __aligned(2);
109: };
110:
111: static inline void *iwl_mvm_get_scan_req_umac_data(struct iwl_mvm *mvm)
112: {
113: struct iwl_scan_req_umac *cmd = mvm->scan_cmd;
114:
115: if (iwl_mvm_is_adaptive_dwell_v2_supported(mvm))
116: return (void *)&cmd->v8.data;
117:
118: if (iwl_mvm_is_adaptive_dwell_supported(mvm))
119: return (void *)&cmd->v7.data;
120:
121: if (iwl_mvm_cdb_scan_api(mvm))
122: return (void *)&cmd->v6.data;
123:
124: return (void *)&cmd->v1.data;
125: }
126:
127: static inline struct iwl_scan_umac_chan_param *
128: iwl_mvm_get_scan_req_umac_channel(struct iwl_mvm *mvm)
129: {
130: struct iwl_scan_req_umac *cmd = mvm->scan_cmd;
131:
]
|
| 78/2 |
2026/06/16 00:18 |
llm |
expert |
0m
Model:
Tokens:
input: 60223
output: 50
thoughts: 15
Thoughts: Okay, let's dive into this. Here's my take on those thoughts, summarized from an expert's perspective:
**Diving into the `iwl_scan_probe_req` Structure**
Right, let's take a look at the `struct iwl_scan_probe_req`. I know this is a core structure within the Intel Wireless driver, crucial for how it handles probing during scanning operations. I'm going to want to understand its fields, how they are populated, and how this structure fits into the larger scanning workflow. I need to be able to quickly recall and correlate this structure with any potential performance bottlenecks or troubleshooting scenarios in the future. I want to see how the request interacts with the firmware and the hardware to initiate those probe requests. Any potential issues with this structure would manifest as scan failures or delays. Okay, let's dissect the details.
|
| 79/2 |
2026/06/16 00:18 |
tool |
codesearch-definition-source |
0m
Error:
Args: map[ContextFile:drivers/net/wireless/intel/iwlwifi/mvm/scan.c Name:iwl_scan_probe_req]
Results: map[SourceCode: SourceFile:]
|
| 80/2 |
2026/06/16 00:18 |
llm |
expert |
0m
Model:
Tokens:
input: 60493
output: 24
thoughts: 17
Thoughts: Okay, here's my summarized thought process, presented as if I were thinking it:
**Digging into the iwlwifi Scan Probe Request Structure**
Alright, time to get my hands dirty. I need to understand the structure of the scan probe request within the iwlwifi driver. Where does it live? Time to find it. The quickest way to isolate it is to start with a grep. Specifically, let's grep for the string `struct iwl_scan_probe_req {`. That should bring up the declaration, assuming it's correctly named, and then I can dig into the specifics and understand its members. This is the starting point for really comprehending the underlying scan mechanism. This will be the key to debugging and modifying it.
|
| 81/2 |
2026/06/16 00:18 |
tool |
grepper |
0m
Args: map[Expression:struct iwl_scan_probe_req \{]
Results: map[Output:drivers/net/wireless/intel/iwlwifi/fw/api/scan.h=247=struct iwl_scan_probe_req_v1 {
--
drivers/net/wireless/intel/iwlwifi/fw/api/scan.h-260- */
drivers/net/wireless/intel/iwlwifi/fw/api/scan.h:261:struct iwl_scan_probe_req {
drivers/net/wireless/intel/iwlwifi/fw/api/scan.h-262- struct iwl_scan_probe_segment mac_header;
]
|
| 82/2 |
2026/06/16 00:18 |
llm |
expert |
0m
Model:
Tokens:
input: 60843
output: 47
thoughts: 37
Thoughts: Okay, let's dive into this. Here's my take on those thoughts:
**Analyzing `iwl_scan_probe_req` for Intel Wireless Firmware Interaction**
Alright, I'm going to pull up `struct iwl_scan_probe_req` from the `drivers/net/wireless/intel/iwlwifi/fw/api/scan.h` file. I'm assuming, given the location and the name, that this structure defines the format for probe request frames used during wireless scans within the Intel iwlwifi driver framework, and the firmware API. I need to understand this structure to dissect the scan process as implemented, and how the driver communicates the desired scanning parameters to the firmware. I suspect it holds fields related to SSID lists, channel preferences, scan types, and possibly even more advanced scan control parameters. Understanding this structure is crucial for debugging scan-related issues, optimizing scan behavior, or even extending the driver with new scanning capabilities. It's time to see what information it encodes.
|
| 83/2 |
2026/06/16 00:18 |
tool |
read-file |
0m
Args: map[File:drivers/net/wireless/intel/iwlwifi/fw/api/scan.h FirstLine:261 LineCount:20]
Results: map[Contents: 261: struct iwl_scan_probe_req {
262: struct iwl_scan_probe_segment mac_header;
263: struct iwl_scan_probe_segment band_data[SCAN_NUM_BAND_PROBE_DATA_V_2];
264: struct iwl_scan_probe_segment common_data;
265: u8 buf[SCAN_OFFLOAD_PROBE_REQ_SIZE];
266: } __packed;
267:
268: enum iwl_scan_channel_flags {
269: IWL_SCAN_CHANNEL_FLAG_EBS = BIT(0),
270: IWL_SCAN_CHANNEL_FLAG_EBS_ACCURATE = BIT(1),
271: IWL_SCAN_CHANNEL_FLAG_CACHE_ADD = BIT(2),
272: IWL_SCAN_CHANNEL_FLAG_EBS_FRAG = BIT(3),
273: IWL_SCAN_CHANNEL_FLAG_FORCE_EBS = BIT(4),
274: IWL_SCAN_CHANNEL_FLAG_ENABLE_CHAN_ORDER = BIT(5),
275: IWL_SCAN_CHANNEL_FLAG_6G_PSC_NO_FILTER = BIT(6),
276: };
277:
278: /**
279: * struct iwl_scan_channel_opt - CHANNEL_OPTIMIZATION_API_S
280: * @flags: enum iwl_scan_channel_flags
]
|
| 84/2 |
2026/06/16 00:18 |
llm |
expert |
0m
Model:
Tokens:
input: 61558
output: 27
thoughts: 38
Thoughts: Okay, here's my interpretation of those thoughts, tailored for an expert audience, presented in the first person:
**Analyzing the Buffer Size for Probe Requests**
Right, so I'm focusing on `SCAN_OFFLOAD_PROBE_REQ_SIZE`. That name immediately tells me it's related to the size of a buffer, likely `buf`, used for handling probe requests in the scan offload process. The fact that it's a constant suggests it's a critical, well-defined value. Now, my immediate thought is: what's the rationale behind this specific size? Is it dictated by the expected size of the probe request frame itself, including all the essential fields like SSID, supported rates, capabilities, vendor-specific elements, and so on? Or is there some kind of padding factored in for alignment or to accommodate potential future extensions or fragmentation needs? I need to dig into the definition of `SCAN_OFFLOAD_PROBE_REQ_SIZE` to understand where this value originates. Are there any constraints, maybe a maximum MTU for the relevant interface? Is there a reason it is this size and is it likely to be an issue in the future? Is it configurable? I'll check its definition to get the full picture and ensure it's robust.
|
| 85/2 |
2026/06/16 00:18 |
tool |
grepper |
0m
Args: map[Expression:#define SCAN_OFFLOAD_PROBE_REQ_SIZE]
Results: map[Output:drivers/net/wireless/intel/iwlwifi/fw/api/scan.h=44=struct iwl_ssid_ie {
--
drivers/net/wireless/intel/iwlwifi/fw/api/scan.h-54-#define IWL_SCAN_MAX_PROFILES_V2 8
drivers/net/wireless/intel/iwlwifi/fw/api/scan.h:55:#define SCAN_OFFLOAD_PROBE_REQ_SIZE 512
drivers/net/wireless/intel/iwlwifi/fw/api/scan.h-56-#define SCAN_NUM_BAND_PROBE_DATA_V_1 2
]
|
| 86/2 |
2026/06/16 00:18 |
llm |
expert |
0m
Model:
Tokens:
input: 62056
output: 50
thoughts: 808
Thoughts: **Vulnerability Assessment: Stack Buffer Overflow in Intel Wireless Driver (iwlwifi)**
Okay, so I've been digging into this Intel wireless driver code, specifically around the scan request handling. It's becoming clear this is a potential exploit. I've found a classic stack buffer overflow.
I started by looking at `iwl_mvm_build_scan_probe` and noticed something fishy right away. This `ies->len[NL80211_BAND_2GHZ]` is uninitialized. That immediately raised a red flag. It's used as the length parameter in `iwl_mvm_copy_and_insert_ds_elem`. If that uninitialized value is large enough, the copy will write far beyond what's intended.
Then I realized something critical. The destination of this copy, `params.preq.buf`, is on the *stack* within `_iwl_mvm_single_scan_start`. Bingo. If `iwl_mvm_copy_and_insert_ds_elem` writes more than 512 bytes (the size of `params.preq.buf`), we're overflowing the stack.
And the attacker controls this length (`ies->len`) and the source pointer (`ies->ies`)! The `local->hw_scan_req` structure, containing the attacker-controlled data, is allocated using `kmalloc` in `__ieee80211_start_scan`. This means an attacker can use heap spraying to potentially place a malicious `struct ieee80211_scan_ies` structure at a predictable address. When the driver calls `iwl_mvm_build_scan_probe`, it will interpret the attacker's fake data as the scan request information.
So, in essence, the attacker crafts a heap spray, places a malicious `struct ieee80211_scan_ies` with a crafted `ies->len` and `ies->ies`. Then, the `iwl_mvm_copy_and_insert_ds_elem` copies a controlled amount of data, controlled by the attacker, from attacker-controlled memory on the heap to the stack, overflowing the stack buffer.
This gives the attacker arbitrary read/write, and thus, I see this as *arbitrary code execution*. This is definitely exploitable.
Now, I need to verify that `ies->len` is really uninitialized, and that `ieee80211_build_preq_ies` doesn't initialize it under some conditions. Let's look at `ieee80211_prep_hw_scan` and dive into that `ieee80211_build_preq_ies` function.
|
| 87/2 |
2026/06/16 00:19 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:net/mac80211/util.c Name:ieee80211_build_preq_ies]
Results: map[SourceCode:1494: int ieee80211_build_preq_ies(struct ieee80211_sub_if_data *sdata, u8 *buffer,
1495: size_t buffer_len,
1496: struct ieee80211_scan_ies *ie_desc,
1497: const u8 *ie, size_t ie_len,
1498: u8 bands_used, u32 *rate_masks,
1499: struct cfg80211_chan_def *chandef,
1500: u32 flags)
1501: {
1502: struct sk_buff *skb = alloc_skb(buffer_len, GFP_KERNEL);
1503: uintptr_t offs;
1504: int ret, i;
1505: u8 *start;
1506:
1507: if (!skb)
1508: return -ENOMEM;
1509:
1510: start = skb_tail_pointer(skb);
1511: memset(start, 0, skb_tailroom(skb));
1512: ret = ieee80211_put_preq_ies(skb, sdata, ie_desc, ie, ie_len,
1513: bands_used, rate_masks, chandef,
1514: flags);
1515: if (ret < 0) {
1516: goto out;
1517: }
1518:
1519: if (skb->len > buffer_len) {
1520: ret = -ENOBUFS;
1521: goto out;
1522: }
1523:
1524: memcpy(buffer, start, skb->len);
1525:
1526: /* adjust ie_desc for copy */
1527: for (i = 0; i < NUM_NL80211_BANDS; i++) {
1528: offs = ie_desc->ies[i] - start;
1529: ie_desc->ies[i] = buffer + offs;
1530: }
1531: offs = ie_desc->common_ies - start;
1532: ie_desc->common_ies = buffer + offs;
1533:
1534: ret = skb->len;
1535: out:
1536: consume_skb(skb);
1537: return ret;
1538: }
SourceFile:net/mac80211/util.c]
|
| 88/2 |
2026/06/16 00:19 |
llm |
expert |
0m
Model:
Tokens:
input: 64248
output: 50
thoughts: 42
Thoughts: Okay, here's my take on those thoughts, tailored for an expert audience:
**Analyzing the IEEE 802.11 Probe Request IE Insertion**
Right, so `ieee80211_put_preq_ies` just got triggered. That immediately piques my interest. I need to dive into how this function is handling the insertion of Information Elements (IEs) into a Probe Request frame. I want to quickly evaluate its implementation. I'll need to refresh my memory on the specific calling context and which IEs are currently relevant for this particular probe request. Is this about adding vendor-specific IEs? Are we dealing with RSN capabilities? Or something else entirely? Time to get down into the code. Let's see how `ieee80211_put_preq_ies` handles the data structures involved, the allocation, the length calculations, and especially any potential for buffer overflows or incorrect IE ordering. I'll be looking for optimization opportunities too, naturally.
|
| 89/2 |
2026/06/16 00:19 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:net/mac80211/util.c Name:ieee80211_put_preq_ies]
Results: map[SourceCode:1451: static int ieee80211_put_preq_ies(struct sk_buff *skb,
1452: struct ieee80211_sub_if_data *sdata,
1453: struct ieee80211_scan_ies *ie_desc,
1454: const u8 *ie, size_t ie_len,
1455: u8 bands_used, u32 *rate_masks,
1456: struct cfg80211_chan_def *chandef,
1457: u32 flags)
1458: {
1459: size_t custom_ie_offset = 0;
1460: int i, err;
1461:
1462: memset(ie_desc, 0, sizeof(*ie_desc));
1463:
1464: for (i = 0; i < NUM_NL80211_BANDS; i++) {
1465: if (bands_used & BIT(i)) {
1466: ie_desc->ies[i] = skb_tail_pointer(skb);
1467: err = ieee80211_put_preq_ies_band(skb, sdata,
1468: ie, ie_len,
1469: &custom_ie_offset,
1470: i, rate_masks[i],
1471: chandef, flags);
1472: if (err)
1473: return err;
1474: ie_desc->len[i] = skb_tail_pointer(skb) -
1475: ie_desc->ies[i];
1476: }
1477: }
1478:
1479: /* add any remaining custom IEs */
1480: if (ie && ie_len) {
1481: if (WARN_ONCE(skb_tailroom(skb) < ie_len - custom_ie_offset,
1482: "not enough space for preq custom IEs\n"))
1483: return -ENOBUFS;
1484: ie_desc->common_ies = skb_tail_pointer(skb);
1485: skb_put_data(skb, ie + custom_ie_offset,
1486: ie_len - custom_ie_offset);
1487: ie_desc->common_ie_len = skb_tail_pointer(skb) -
1488: ie_desc->common_ies;
1489: }
1490:
1491: return 0;
1492: };
SourceFile:net/mac80211/util.c]
|
| 90/2 |
2026/06/16 00:19 |
llm |
expert |
0m
Model:
Tokens:
input: 65322
output: 51
thoughts: 1430
Thoughts: **Analyzing a Potential Use-After-Free Vulnerability in Wireless Scanning**
Okay, so let me break this down. First, I see that `ieee80211_put_preq_ies` starts by zeroing out `ie_desc`. That's important; it means `ie_desc` and its associated `ies` structure are starting from a known state. If `ieee80211_put_preq_ies_band` then returns an error, the `ie_desc` structure is only *partially* filled. The key thing is that if it errors, the `ieee80211_build_preq_ies` function also returns an error, leading `ieee80211_prep_hw_scan` to return `false` indicating a hardware scan shouldn't be performed. This seems to be where the issue is.
If `ieee80211_put_preq_ies_band` fails, the `ies->len` remains at zero, and `ies->ies` will either be NULL or point to a valid skb buffer allocated in another process. However, if the function *succeeds*, `ie_desc->ies[i]` is updated to point to the skb buffer via `skb_tail_pointer(skb)`. Crucially, `ie_desc->len[i]` is only set *after* a successful return from `ieee80211_put_preq_ies_band`. And that `skb` is freed in the `ieee80211_build_preq_ies` function when the function *completes*.
This looks like trouble. I see a `consume_skb(skb)` call within the `out:` label. That's a classic sign. So, if `ieee80211_put_preq_ies_band` succeeds for one band (e.g., 2.4GHz) but fails for another (e.g., 5GHz), then `ie_desc->len[0]` would be non-zero while `ie_desc->ies[0]` is a *dangling pointer* to a *freed* skb buffer. This is a clear Use-After-Free (UAF) situation. The `drv_hw_scan` function, called later, then uses `iwl_mvm_copy_and_insert_ds_elem` which will attempt to read from `ies->ies[0]` using `ies->len[0]`. Thus, we're copying data from a freed buffer!
I have to consider the pointer adjustment within `ieee80211_build_preq_ies` because that is significant. The crucial part is this: the adjustment of the pointer in `ie_desc->ies[i]` is *only* done if `ret < 0`. If `ret < 0` we `goto out;`, meaning `ie_desc->ies[i]` will still point to the freed skb buffer! This confirms the UAF read is possible!
The question now is, what conditions create this scenario? Can we have a scenario where 2.4GHz succeeds and 5GHz fails? Yes, I can see that this is possible. If we have a situation where the buffer is just large enough to hold the 2.4GHz information but not the 5GHz information, this failure scenario becomes likely. The missing bytes per band, combined with a tight buffer allocation, makes this highly possible.
Now, I need to consider a different aspect. I see that the `local->hw_scan_req->req.ie_len` is uninitialized. This is allocated via `kmalloc`, but its initial value is not assigned. If `ieee80211_prep_hw_scan` returns `false`, then `req.ie_len` is *not* updated. This is significant because this uninitialized value is later used in `iwl_mvm_scan_fits` via `iwl_mvm_reg_scan_start` -> `_iwl_mvm_single_scan_start`. Now I have to determine if this impacts the UAF that I have identified.
|
| 91/2 |
2026/06/16 00:19 |
tool |
codesearch-definition-source |
0m
Error:
Args: map[ContextFile:drivers/net/wireless/intel/iwlwifi/mvm/scan.c Name:iwl_mvm_scan_fits]
Results: map[SourceCode: SourceFile:]
|
| 92/2 |
2026/06/16 00:19 |
llm |
expert |
0m
Model:
Tokens:
input: 67747
output: 23
thoughts: 16
Thoughts: Okay, here's my attempt at summarizing that thought process, keeping in mind I'm speaking to a fellow expert:
**Investigating `iwl_mvm_scan_fits`**
Alright, let's get down to it. My initial thought process? I need to understand what's happening with `iwl_mvm_scan_fits`. This feels like a good starting point. I could probably dig around in the source code or debug logs, but I'll start with a quick and dirty way to get a broader scope, a `grep`. That should quickly reveal where this function is used and provide some clues about its role within the broader system. I'm hoping to get a quick overview of how and where the scan functions are used. Maybe there's a problem here, maybe not, but this is a good first step to map the landscape before getting too deep. A quick `grep` will get me started.
|
| 93/2 |
2026/06/16 00:19 |
tool |
grepper |
0m
Args: map[Expression:iwl_mvm_scan_fits]
Results: map[Output:drivers/net/wireless/intel/iwlwifi/mvm/scan.c=821=static void iwl_mvm_scan_lmac_dwell(struct iwl_mvm *mvm,
--
drivers/net/wireless/intel/iwlwifi/mvm/scan.c-833-
drivers/net/wireless/intel/iwlwifi/mvm/scan.c:834:static inline bool iwl_mvm_scan_fits(struct iwl_mvm *mvm, int n_ssids,
drivers/net/wireless/intel/iwlwifi/mvm/scan.c-835- struct ieee80211_scan_ies *ies,
--
drivers/net/wireless/intel/iwlwifi/mvm/scan.c=2966=static int _iwl_mvm_single_scan_start(struct iwl_mvm *mvm,
--
drivers/net/wireless/intel/iwlwifi/mvm/scan.c-2995-
drivers/net/wireless/intel/iwlwifi/mvm/scan.c:2996: if (!iwl_mvm_scan_fits(mvm, req->n_ssids, ies, req->n_channels))
drivers/net/wireless/intel/iwlwifi/mvm/scan.c-2997- return -ENOBUFS;
--
drivers/net/wireless/intel/iwlwifi/mvm/scan.c=3077=int iwl_mvm_sched_scan_start(struct iwl_mvm *mvm,
--
drivers/net/wireless/intel/iwlwifi/mvm/scan.c-3176-
drivers/net/wireless/intel/iwlwifi/mvm/scan.c:3177: if (!iwl_mvm_scan_fits(mvm, req->n_ssids, ies, params.n_channels)) {
drivers/net/wireless/intel/iwlwifi/mvm/scan.c-3178- ret = -ENOBUFS;
]
|
| 94/2 |
2026/06/16 00:19 |
llm |
expert |
0m
Model:
Tokens:
input: 68498
output: 46
thoughts: 15
Thoughts: Okay, let's dive into this `iwl_mvm_scan_fits` function. I need to understand how this crucial bit of the Intel wireless driver figures out if a scan is actually going to be useful. I'm expecting this to be where the driver makes its first, quick judgment calls before engaging in the heavier lifting of a full scan. Itβs likely a trade-off between power efficiency, responsiveness, and the need to stay connected.
I'm thinking this function will probably examine some critical parameters: Is the current connection stable? What's the signal strength like? Are there any obvious issues indicating a scan is warranted, like excessive retransmissions or frequent disconnects? I'd imagine there'd be some thresholding involved, and this could be a good place to look for subtle performance optimizations.
I expect to see the driver consider factors such as the user's current configuration, any recent changes to the environment, and perhaps even historical data about this network. I'll be looking to see if it integrates any dynamic thresholds, perhaps adapting based on usage patterns or system load. Iβm also curious to see if it efficiently handles situations where the device is already in a state of flux β perhaps when roaming or under heavy interference.
Overall, I'm hoping this function is a well-crafted piece of code that intelligently decides whether to invest the resources in a full scan. Let's see how they've implemented that.
|
| 95/2 |
2026/06/16 00:19 |
tool |
read-file |
0m
Args: map[File:drivers/net/wireless/intel/iwlwifi/mvm/scan.c FirstLine:834 LineCount:20]
Results: map[Contents: 834: static inline bool iwl_mvm_scan_fits(struct iwl_mvm *mvm, int n_ssids,
835: struct ieee80211_scan_ies *ies,
836: int n_channels)
837: {
838: return ((n_ssids <= PROBE_OPTION_MAX) &&
839: (n_channels <= mvm->fw->ucode_capa.n_scan_channels) &&
840: (ies->common_ie_len +
841: ies->len[NL80211_BAND_2GHZ] + ies->len[NL80211_BAND_5GHZ] +
842: ies->len[NL80211_BAND_6GHZ] <=
843: iwl_mvm_max_scan_ie_fw_cmd_room(mvm)));
844: }
845:
846: static inline bool iwl_mvm_scan_use_ebs(struct iwl_mvm *mvm,
847: struct ieee80211_vif *vif)
848: {
849: const struct iwl_ucode_capabilities *capa = &mvm->fw->ucode_capa;
850: bool low_latency;
851:
852: if (iwl_mvm_is_cdb_supported(mvm))
853: low_latency = iwl_mvm_low_latency_band(mvm, NL80211_BAND_5GHZ);
]
|
| 96/2 |
2026/06/16 00:19 |
llm |
expert |
0m
Model:
Tokens:
input: 69311
output: 41
thoughts: 152
Thoughts: **Analyzing the Data Structure in the Wireless Driver**
Okay, so I'm looking at this code and it's using `ies->common_ie_len` and `ies->len`, and I need to understand this better. Now, hang on a second...I remember `ies` is initialized to zero within `ieee80211_put_preq_ies`. That means `ies->common_ie_len` and `ies->len` are either going to be zero, or they'll contain valid lengths *if* certain radio bands have successfully produced data. That suggests `iwl_mvm_scan_fits` should work without issue, but I need to make sure.
Now, that brings up another point. What about `req->ie_len`? Hmm, it looks like it's *not* actually used inside `iwl_mvm_scan_fits`. Okay, that's interesting. I need to trace this further. I wonder if `req->ie_len` is used at all inside `iwl_mvm_reg_scan_start`. I should double-check that. Let me review that function.
|
| 97/2 |
2026/06/16 00:19 |
tool |
grepper |
0m
Args: map[Expression:ie_len PathPrefix:drivers/net/wireless/intel/iwlwifi/mvm/scan.c]
Results: map[Output:drivers/net/wireless/intel/iwlwifi/mvm/scan.c=303=static int iwl_mvm_max_scan_ie_fw_cmd_room(struct iwl_mvm *mvm)
--
drivers/net/wireless/intel/iwlwifi/mvm/scan.c-318-
drivers/net/wireless/intel/iwlwifi/mvm/scan.c:319:int iwl_mvm_max_scan_ie_len(struct iwl_mvm *mvm)
drivers/net/wireless/intel/iwlwifi/mvm/scan.c-320-{
drivers/net/wireless/intel/iwlwifi/mvm/scan.c:321: int max_ie_len = iwl_mvm_max_scan_ie_fw_cmd_room(mvm);
drivers/net/wireless/intel/iwlwifi/mvm/scan.c-322-
--
drivers/net/wireless/intel/iwlwifi/mvm/scan.c-332- */
drivers/net/wireless/intel/iwlwifi/mvm/scan.c:333: return max_ie_len;
drivers/net/wireless/intel/iwlwifi/mvm/scan.c-334-}
--
drivers/net/wireless/intel/iwlwifi/mvm/scan.c=752=iwl_mvm_build_scan_probe(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
--
drivers/net/wireless/intel/iwlwifi/mvm/scan.c-806- pos += ies->len[NL80211_BAND_6GHZ];
drivers/net/wireless/intel/iwlwifi/mvm/scan.c:807: memcpy(pos, ies->common_ies, ies->common_ie_len);
drivers/net/wireless/intel/iwlwifi/mvm/scan.c-808- params->preq.common_data.offset = cpu_to_le16(pos - params->preq.buf);
--
drivers/net/wireless/intel/iwlwifi/mvm/scan.c-812- IWL_UCODE_TLV_CAPA_WFA_TPC_REP_IE_SUPPORT)) {
drivers/net/wireless/intel/iwlwifi/mvm/scan.c:813: iwl_mvm_add_tpc_report_ie(pos + ies->common_ie_len);
drivers/net/wireless/intel/iwlwifi/mvm/scan.c:814: params->preq.common_data.len = cpu_to_le16(ies->common_ie_len +
drivers/net/wireless/intel/iwlwifi/mvm/scan.c-815- WFA_TPC_IE_LEN);
drivers/net/wireless/intel/iwlwifi/mvm/scan.c-816- } else {
drivers/net/wireless/intel/iwlwifi/mvm/scan.c:817: params->preq.common_data.len = cpu_to_le16(ies->common_ie_len);
drivers/net/wireless/intel/iwlwifi/mvm/scan.c-818- }
--
drivers/net/wireless/intel/iwlwifi/mvm/scan.c=834=static inline bool iwl_mvm_scan_fits(struct iwl_mvm *mvm, int n_ssids,
--
drivers/net/wireless/intel/iwlwifi/mvm/scan.c-839- (n_channels <= mvm->fw->ucode_capa.n_scan_channels) &&
drivers/net/wireless/intel/iwlwifi/mvm/scan.c:840: (ies->common_ie_len +
drivers/net/wireless/intel/iwlwifi/mvm/scan.c-841- ies->len[NL80211_BAND_2GHZ] + ies->len[NL80211_BAND_5GHZ] +
]
|
| 98/2 |
2026/06/16 00:19 |
llm |
expert |
0m
Model:
Tokens:
input: 70778
output: 42
thoughts: 1000
Thoughts: **Vulnerability Discovery: Use-After-Free and Information Leak in Wireless Drivers**
Okay, so I've been digging into this wireless driver code, and something's not right. I'm focusing on how Probe Request IEs are handled. The initial observation is that `req->ie_len` appears unused; the driver seems to rely solely on `ies->len` and `ies->common_ie_len`, which are then zeroed out in `ieee80211_put_preq_ies`. That's the first red flag. If those lengths are zero, the copy function `iwl_mvm_build_scan_probe` will effectively copy zero bytes.
But here's where things get interesting. What if the `ieee80211_put_preq_ies_band` function succeeds for 2.4 GHz but fails for 5 GHz? Now, `ies->len[NL80211_BAND_2GHZ]` would be greater than zero. The corresponding `ies->ies[NL80211_BAND_2GHZ]` pointer would point to the `skb` buffer. However, this `skb` is freed in `ieee80211_build_preq_ies` because of an `-ENOBUFS` return.
This means the driver will attempt to read a number of bytes specified by `ies->len[NL80211_BAND_2GHZ]` *from a freed `skb` buffer*! That's a classic Use-After-Free (UAF) read, and it's a huge potential vulnerability.
Now, can this be exploited? The attacker can trigger this UAF. The data read from the freed buffer ends up in `params->preq.buf` on the stack. The whole `params` structure is then sent to the firmware via `iwl_mvm_send_cmd(mvm, &hcmd)`. The firmware then uses this data as the Probe Request IE. Crucially, that Probe Request is transmitted over the air! The upshot: an attacker can leak kernel heap memory (specifically, the contents of that freed `skb`) over the wireless network. This is an information leak. This is a *remote* information leak triggered locally by an unprivileged user.
The real kicker? `CAP_NET_ADMIN` privileges in a user namespace give the unprivileged user access. This makes it highly exploitable: an unprivileged user can trigger this bug to leak kernel heap memory remotely!
Alright, time to expand the search. I need to know if any other drivers might be vulnerable. What about `mac80211_hwsim`? I spot a few suspicious lines in `mac80211_hwsim_hw_scan`. The code uses `hw_req->req.mac_addr`. But `hw_req->req.mac_addr` is only initialized *after* `ieee80211_build_preq_ies` succeeds. If that function fails, `hw_req->req.mac_addr` is uninitialized. `mac80211_hwsim` will read these uninitialized bytes to generate a MAC address with `get_random_mask_addr`. Since `hw_req` is kmalloc'd, these will be uninitialized heap bytes! This leaks 6 bytes of heap memory during simulation.
Now, to circle back, is `req->ie_len` used by `mac80211_hwsim`? I need to check!
|
| 99/2 |
2026/06/16 00:19 |
tool |
grepper |
0m
Args: map[Expression:ie_len PathPrefix:drivers/net/wireless/virtual/mac80211_hwsim.c]
Results: map[Output:drivers/net/wireless/virtual/mac80211_hwsim.c=3099=static void hw_scan_work(struct work_struct *work)
--
drivers/net/wireless/virtual/mac80211_hwsim.c-3141- req->ssids[i].ssid_len,
drivers/net/wireless/virtual/mac80211_hwsim.c:3142: req->ie_len);
drivers/net/wireless/virtual/mac80211_hwsim.c-3143- if (!probe)
--
drivers/net/wireless/virtual/mac80211_hwsim.c-3149-
drivers/net/wireless/virtual/mac80211_hwsim.c:3150: if (req->ie_len)
drivers/net/wireless/virtual/mac80211_hwsim.c:3151: skb_put_data(probe, req->ie, req->ie_len);
drivers/net/wireless/virtual/mac80211_hwsim.c-3152-
--
drivers/net/wireless/virtual/mac80211_hwsim.c=5580=static int mac80211_hwsim_new_radio(struct genl_info *info,
--
drivers/net/wireless/virtual/mac80211_hwsim.c-5734- hw->wiphy->max_scan_ssids = 255;
drivers/net/wireless/virtual/mac80211_hwsim.c:5735: hw->wiphy->max_scan_ie_len = IEEE80211_MAX_DATA_LEN;
drivers/net/wireless/virtual/mac80211_hwsim.c-5736- hw->wiphy->max_remain_on_channel_duration = 1000;
]
|
| 100/2 |
2026/06/16 00:19 |
llm |
expert |
0m
Model:
Tokens:
input: 73088
output: 50
thoughts: 1228
Thoughts: **Exploiting the `mac80211_hwsim` Scan Request Vulnerability**
Okay, so here's what I've got. It looks like `mac80211_hwsim` uses `req->ie_len`, and *it's uninitialized*! Specifically, within the `nl80211_trigger_scan` path, we're seeing:
```c
if (req->ie_len)
skb_put_data(probe, req->ie, req->ie_len);
```
Since `local->hw_scan_req` (which contains `req`) is allocated with `kmalloc`, the value of `req->ie_len` is attacker-controlled through heap spraying. If `req->ie_len` is sufficiently large, then `skb_put_data` reads `req->ie_len` bytes from `req->ie`, which points past the allocated memory. This is a classic out-of-bounds read! It puts this leaked data into a `probe` skb, which is then, in effect, transmitted "over the air".
Now, the `skb_put_data` function calls `skb_put`, which will panic if `len > skb_tailroom(skb)`. So, the vulnerability can cause both an information leak *and* a kernel panic, depending on the attacker's value for `req->ie_len`. If small, it leaks memory. If large, it causes a DoS. Definitely exploitable.
To break it down:
1. An unprivileged user in a user namespace can trigger `nl80211_trigger_scan`.
2. The bug prevents `ieee80211_prep_hw_scan` from succeeding, which results in a `WARN_ON` but execution continues.
3. `drv_hw_scan` is called with `local->hw_scan_req`.
4. `local->hw_scan_req` is allocated with `kmalloc` and is partially uninitialized.
5. `req->ie_len` is uninitialized.
6. Drivers like `mac80211_hwsim` use `req->ie_len` to copy data from `req->ie` into the packet.
7. This causes an out-of-bounds read, potentially leaking kernel memory *or* triggering a kernel panic if it's too large.
8. Other drivers like `iwlwifi` have the same problem, but their bug is a Use-After-Free.
Now, can an unprivileged user even *trigger* this? I need to double-check `nl80211_trigger_scan`'s reachability. Okay, `GENL_UNS_ADMIN_PERM` is present.
```c
{
.cmd = NL80211_CMD_TRIGGER_SCAN,
.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
.doit = nl80211_trigger_scan,
.flags = GENL_UNS_ADMIN_PERM,
.internal_flags = IFLAGS(NL80211_FLAG_NEED_WDEV_UP),
},
```
That means it can be called by a user with `CAP_NET_ADMIN` in the network namespace. That's reachable: an unprivileged user can create a new user namespace, create a new network namespace, and then they'll have `CAP_NET_ADMIN` in *that* namespace.
But wait. Can they *actually* trigger a scan on a real wireless device? Wireless devices live in a network namespace, and they usually start in the init namespace. They need `CAP_NET_ADMIN` in the *init* namespace to move them. So, the unprivileged user *can't* do that.
So, if the device is in the init namespace, the user in the new namespace can't even see it, much less trigger a scan.
However, what about `mac80211_hwsim`? Can the attacker *create* a `mac80211_hwsim` device? Let's check. Is there a Netlink API for it? `NL80211_CMD_NEW_RADIO`? No... It looks like it is a separate family `HWSIM_CMD_NEW_RADIO`. So, this is a distinct issue.
|
| 101/2 |
2026/06/16 00:20 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/net/wireless/virtual/mac80211_hwsim.c Name:hwsim_genl_family]
Results: map[SourceCode:6916: static struct genl_family hwsim_genl_family __ro_after_init = {
6917: .name = "MAC80211_HWSIM",
6918: .version = 1,
6919: .maxattr = HWSIM_ATTR_MAX,
6920: .policy = hwsim_genl_policy,
6921: .netnsok = true,
6922: .module = THIS_MODULE,
6923: .small_ops = hwsim_ops,
6924: .n_small_ops = ARRAY_SIZE(hwsim_ops),
6925: .resv_start_op = HWSIM_CMD_REPORT_PMSR + 1, // match with __HWSIM_CMD_MAX
6926: .mcgrps = hwsim_mcgrps,
6927: .n_mcgrps = ARRAY_SIZE(hwsim_mcgrps),
6928: };
SourceFile:drivers/net/wireless/virtual/mac80211_hwsim.c]
|
| 102/2 |
2026/06/16 00:20 |
llm |
expert |
0m
Model:
Tokens:
input: 75663
output: 47
thoughts: 10
Thoughts: Okay, let's dive into this. Here's my thought process on this:
**Analyzing `hwsim_ops`**
Right, so the immediate next step is to examine the `hwsim_ops`. It's a critical area, usually the go-to when something isn't behaving as expected with the hardware simulation aspect. I need to refresh my memory, likely, and see what the defined operations are and how they're being used. I'll need to look at both the definition of the structure itself and any code that's calling functions that might be contained within it. Things to look for initially: are there any obvious errors, missing implementations, or unexpected data types being passed? I'll probably start with a general grep search within the relevant codebase to understand its overall scope and then drill down further. I need to trace the usage, understand the flow and context, and think about the implications of any changes or debugging attempts.
|
| 103/2 |
2026/06/16 00:20 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/net/wireless/virtual/mac80211_hwsim.c Name:hwsim_ops]
Results: map[SourceCode:6873: /* Generic Netlink operations array */
6874: static const struct genl_small_ops hwsim_ops[] = {
6875: {
6876: .cmd = HWSIM_CMD_REGISTER,
6877: .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
6878: .doit = hwsim_register_received_nl,
6879: .flags = GENL_UNS_ADMIN_PERM,
6880: },
6881: {
6882: .cmd = HWSIM_CMD_FRAME,
6883: .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
6884: .doit = hwsim_cloned_frame_received_nl,
6885: },
6886: {
6887: .cmd = HWSIM_CMD_TX_INFO_FRAME,
6888: .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
6889: .doit = hwsim_tx_info_frame_received_nl,
6890: },
6891: {
6892: .cmd = HWSIM_CMD_NEW_RADIO,
6893: .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
6894: .doit = hwsim_new_radio_nl,
6895: .flags = GENL_UNS_ADMIN_PERM,
6896: },
6897: {
6898: .cmd = HWSIM_CMD_DEL_RADIO,
6899: .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
6900: .doit = hwsim_del_radio_nl,
6901: .flags = GENL_UNS_ADMIN_PERM,
6902: },
6903: {
6904: .cmd = HWSIM_CMD_GET_RADIO,
6905: .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
6906: .doit = hwsim_get_radio_nl,
6907: .dumpit = hwsim_dump_radio_nl,
6908: },
6909: {
6910: .cmd = HWSIM_CMD_REPORT_PMSR,
6911: .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
6912: .doit = hwsim_pmsr_report_nl,
6913: },
6914: };
SourceFile:drivers/net/wireless/virtual/mac80211_hwsim.c]
|
| 104/2 |
2026/06/16 00:20 |
llm |
expert |
0m
Model:
Tokens:
input: 76712
output: 22
thoughts: 1071
Thoughts: **Vulnerability Analysis: Kernel Wireless Stack**
Okay, let's break this down. My initial thought was that the `HWSIM_CMD_NEW_RADIO` command, due to `GENL_UNS_ADMIN_PERM`, might allow an unprivileged user to create a new `mac80211_hwsim` radio within their user namespace. And that's true; they can, assuming they have `CAP_NET_ADMIN` within that namespace, which they get by creating a new network namespace. They could then create the `mac80211_hwsim` device and call `NL80211_CMD_TRIGGER_SCAN`. This seemed like a clear path to an unprivileged user triggering a scan.
But wait. A crucial question is whether `mac80211_hwsim` is *actually* loaded by default. This is where things get interesting. In production kernels, it *isn't*. It's primarily a testing module. Without `mac80211_hwsim`, the user cannot create a `mac80211_hwsim` device. So, the direct route of device creation and triggering scan seems blocked.
Can they target a physical device? No, because the user doesn't have `CAP_NET_ADMIN` in the init network namespace and cannot move a physical device into their newly created namespace. So, without `mac80211_hwsim`, an unprivileged user can't trigger the bug directly.
Then, I started thinking about privileges. What about users in the `netdev` group, or similar? Maybe they have *some* permissions? The general rule is `CAP_NET_ADMIN` is required. Then I remembered `wpa_supplicant`. It runs as root and can be controlled by unprivileged users via D-Bus or a control socket! An unprivileged user could ask `wpa_supplicant` to scan. `wpa_supplicant` then sends `NL80211_CMD_TRIGGER_SCAN` to the kernel.
A key question is whether the user can control the scan request Information Elements (IEs). *Yes*, `wpa_supplicant` allows custom IEs, which is crucial. If an unprivileged user can trigger this and inject arbitrary IEs, that's a serious problem, and probably the real vulnerability.
Even if we're dealing with a restricted `netdev` group scenario, it's still a privilege escalation to kernel execution. `NetworkManager` can also trigger scans, and that's another avenue to consider.
Focusing on the kernel, the bug requires `NL80211_CMD_TRIGGER_SCAN`. If a user has `CAP_NET_ADMIN` (e.g., root), they can trigger it. User namespaces, as established, are only an issue *if* a wireless device is accessible there. The physical device is out, and `mac80211_hwsim` is usually not available. So, generally speaking, it's *not* accessible from unprivileged processes or user namespaces in a typical production environment without `mac80211_hwsim`.
Wait, but Syzbot triggered it! That's when it hit me: Syzbot loads `mac80211_hwsim`! That's how it's being reproduced. Syzbot loads it for its wireless code testing. In a production environment, this module is *not* loaded by default.
This bug is in `mac80211`, the core wireless stack. Someone with `CAP_NET_ADMIN` (like root) can trigger it. It's exploitable! It's an information leak and DoS, and possibly even RCE via heap overflow *if* `req->ie_len` is used for copying. We saw that in `iwlwifi` the `ies->len` and `ies->ies` caused UAF read. In `mac80211_hwsim`, it's `req->ie_len` and that leads to OOB read and DoS. Now, I need to check other drivers, like `mt76`.
|
| 105/2 |
2026/06/16 00:20 |
tool |
grepper |
0m
Args: map[Expression:\.hw_scan = mt76]
Results: map[Output:drivers/net/wireless/mediatek/mt76/mt7615/main.c=1318=const struct ieee80211_ops mt7615_ops = {
--
drivers/net/wireless/mediatek/mt76/mt7615/main.c-1353- .set_coverage_class = mt7615_set_coverage_class,
drivers/net/wireless/mediatek/mt76/mt7615/main.c:1354: .hw_scan = mt7615_hw_scan,
drivers/net/wireless/mediatek/mt76/mt7615/main.c-1355- .cancel_hw_scan = mt7615_cancel_hw_scan,
--
drivers/net/wireless/mediatek/mt76/mt7996/main.c=2505=const struct ieee80211_ops mt7996_ops = {
--
drivers/net/wireless/mediatek/mt76/mt7996/main.c-2528- .wake_tx_queue = mt76_wake_tx_queue,
drivers/net/wireless/mediatek/mt76/mt7996/main.c:2529: .hw_scan = mt76_hw_scan,
drivers/net/wireless/mediatek/mt76/mt7996/main.c-2530- .cancel_hw_scan = mt76_cancel_hw_scan,
]
|
| 106/2 |
2026/06/16 00:20 |
llm |
expert |
0m
Model:
Tokens:
input: 79104
output: 52
thoughts: 37
Thoughts: Okay, let's dive into this. Here's how I'd approach that kernel code:
**Diving into the `mt76_hw_scan` Function**
Right, so the task at hand is to analyze the `mt76_hw_scan` function. My first instinct, given my experience, is to zero in on its location within the Mediatek driver structure. Specifically, it resides in `drivers/net/wireless/mediatek/mt76/mac80211.c`. That path tells me itβs directly tied to the MediaTek wireless chipsets and, more importantly, interacts with the mac80211 framework. This suggests itβs responsible for the *hardware-accelerated* aspects of the scanning process. Understanding the relationship between the mac80211 core and the hardware interface is crucial in these sorts of analyses. I will have to look at how it interacts with the hardware through the Mediatek-specific register definitions and command structures. I need to figure out what data is fed into this function, how it initiates the scan process on the hardware, and how it handles the resultsβboth the raw data returned from the hardware and how they are parsed and reported back to the mac80211 core. I'll need to pay close attention to potential race conditions, error handling, and any power management considerations within this function, because those are often tricky areas in driver development. Also, this `mac80211.c` file is likely to be large, so I need to make sure I focus my investigation, so I will need to use a static analyzer to give me a high-level view of it before deep-diving into the `mt76_hw_scan` function.
|
| 107/2 |
2026/06/16 00:20 |
tool |
codesearch-definition-source |
0m
Error:
Args: map[ContextFile:drivers/net/wireless/mediatek/mt76/mac80211.c Name:mt76_hw_scan]
Results: map[SourceCode: SourceFile:]
|
| 108/2 |
2026/06/16 00:20 |
llm |
expert |
0m
Model:
Tokens:
input: 79586
output: 21
thoughts: 14
Thoughts: Here's my thought process, summarized as you requested:
**Grepping for `mt76_hw_scan`**
Okay, so I need to get started. My initial instinct is to go straight to the source. Specifically, I need to see what's happening with that `mt76_hw_scan` function. That name is pretty specific, so it's a good starting point for a targeted search. I'm thinking a `grep` should be the quickest way to find where that function is defined, used, or even mentioned in comments or documentation. This should give me a good lay of the land within the codebase. Understanding its context is key to understanding the broader system! Let's get to it.
|
| 109/2 |
2026/06/16 00:20 |
tool |
grepper |
0m
Args: map[Expression:mt76_hw_scan]
Results: map[Output:drivers/net/wireless/mediatek/mt76/mt76.h=1604=int mt76_get_rate(struct mt76_dev *dev,
--
drivers/net/wireless/mediatek/mt76/mt76.h-1606- int idx, bool cck);
drivers/net/wireless/mediatek/mt76/mt76.h:1607:int mt76_hw_scan(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
drivers/net/wireless/mediatek/mt76/mt76.h-1608- struct ieee80211_scan_request *hw_req);
--
drivers/net/wireless/mediatek/mt76/mt7996/main.c=2505=const struct ieee80211_ops mt7996_ops = {
--
drivers/net/wireless/mediatek/mt76/mt7996/main.c-2528- .wake_tx_queue = mt76_wake_tx_queue,
drivers/net/wireless/mediatek/mt76/mt7996/main.c:2529: .hw_scan = mt76_hw_scan,
drivers/net/wireless/mediatek/mt76/mt7996/main.c-2530- .cancel_hw_scan = mt76_cancel_hw_scan,
--
drivers/net/wireless/mediatek/mt76/scan.c=107=void mt76_scan_work(struct work_struct *work)
--
drivers/net/wireless/mediatek/mt76/scan.c-175-
drivers/net/wireless/mediatek/mt76/scan.c:176:int mt76_hw_scan(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
drivers/net/wireless/mediatek/mt76/scan.c-177- struct ieee80211_scan_request *req)
--
drivers/net/wireless/mediatek/mt76/scan.c-215-}
drivers/net/wireless/mediatek/mt76/scan.c:216:EXPORT_SYMBOL_GPL(mt76_hw_scan);
drivers/net/wireless/mediatek/mt76/scan.c-217-
]
|
| 110/2 |
2026/06/16 00:20 |
llm |
expert |
0m
Model:
Tokens:
input: 80405
output: 44
thoughts: 32
Thoughts: Here's my analysis of the provided text, rendered as a first-person expert summary:
**Diving into the MT76 Hardware Scan**
Alright, let's get down to brass tacks. I need to understand the hardware scan functionality within the MT76 wireless driver. My focus is immediately drawn to the `mt76_hw_scan` function. I'll need to open `drivers/net/wireless/mediatek/mt76/scan.c` to properly examine its implementation. I'm expecting this function will be the core of the scan process. I want to see how the driver interacts directly with the MT76 hardware during the active or passive scanning phases. I'll be looking for things like how it configures the radio for scanning, how it receives the results, and how it handles the details of things like channel hopping and the beacon/probe request/response sequence. I'll be paying close attention to any nuances specific to the MT76 chipsets.
|
| 111/2 |
2026/06/16 00:20 |
tool |
read-file |
0m
Args: map[File:drivers/net/wireless/mediatek/mt76/scan.c FirstLine:176 LineCount:40]
Results: map[Contents: 176: int mt76_hw_scan(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
177: struct ieee80211_scan_request *req)
178: {
179: struct mt76_phy *phy = hw->priv;
180: struct mt76_dev *dev = phy->dev;
181: struct mt76_vif_link *mlink;
182: int ret = 0;
183:
184: if (hw->wiphy->n_radio > 1) {
185: phy = dev->band_phys[req->req.channels[0]->band];
186: if (!phy)
187: return -EINVAL;
188: }
189:
190: mutex_lock(&dev->mutex);
191:
192: if (dev->scan.req || phy->roc_vif ||
193: test_bit(MT76_MCU_RESET, &dev->phy.state)) {
194: ret = -EBUSY;
195: goto out;
196: }
197:
198: mlink = mt76_get_vif_phy_link(phy, vif);
199: if (IS_ERR(mlink)) {
200: ret = PTR_ERR(mlink);
201: goto out;
202: }
203:
204: memset(&dev->scan, 0, sizeof(dev->scan));
205: dev->scan.req = &req->req;
206: dev->scan.vif = vif;
207: dev->scan.phy = phy;
208: dev->scan.mlink = mlink;
209: ieee80211_queue_delayed_work(dev->phy.hw, &dev->scan_work, 0);
210:
211: out:
212: mutex_unlock(&dev->mutex);
213:
214: return ret;
215: }
]
|
| 112/2 |
2026/06/16 00:20 |
llm |
expert |
0m
Model:
Tokens:
input: 81320
output: 44
thoughts: 23
Thoughts: Here's my summary, as though I'm thinking through this process:
**Diving into the Scan Workflow**
Okay, so the driver kicked off a scan. I see it's queued up `dev->scan_work`. Now, that's interesting... I need to immediately jump into `mt76_scan_work` to understand precisely what's happening there. What triggers, what checks, what hardware interactions? I need to understand the control flow here, because this is where the meat of the scanning operation resides. Gotta trace this through.
|
| 113/2 |
2026/06/16 00:20 |
tool |
read-file |
0m
Args: map[File:drivers/net/wireless/mediatek/mt76/scan.c FirstLine:107 LineCount:50]
Results: map[Contents: 107: void mt76_scan_work(struct work_struct *work)
108: {
109: struct mt76_dev *dev = container_of(work, struct mt76_dev,
110: scan_work.work);
111: struct cfg80211_scan_request *req = dev->scan.req;
112: struct cfg80211_chan_def chandef = {};
113: struct mt76_phy *phy = dev->scan.phy;
114: int duration = HZ / 9; /* ~110 ms */
115: bool beacon_rx, offchannel = true;
116: int i;
117:
118: if (!phy || !req)
119: return;
120:
121: spin_lock_bh(&dev->scan_lock);
122: beacon_rx = dev->scan.beacon_wait && dev->scan.beacon_received;
123: dev->scan.beacon_wait = false;
124: spin_unlock_bh(&dev->scan_lock);
125:
126: if (beacon_rx)
127: goto probe;
128:
129: if (dev->scan.chan_idx >= req->n_channels) {
130: mt76_scan_complete(dev, false);
131: return;
132: }
133:
134: if (dev->scan.chan && phy->num_sta && phy->offchannel) {
135: dev->scan.chan = NULL;
136: mt76_set_channel(phy, &phy->main_chandef, false);
137: mt76_offchannel_notify(phy, false);
138: goto out;
139: }
140:
141: dev->scan.chan = req->channels[dev->scan.chan_idx++];
142: offchannel = mt76_offchannel_chandef(phy, dev->scan.chan, &chandef);
143:
144: if (offchannel)
145: mt76_offchannel_notify(phy, true);
146: mt76_set_channel(phy, &chandef, offchannel);
147:
148: if (!req->n_ssids)
149: goto out;
150:
151: if (chandef.chan->flags & (IEEE80211_CHAN_NO_IR | IEEE80211_CHAN_RADAR)) {
152: spin_lock_bh(&dev->scan_lock);
153: dev->scan.beacon_received = false;
154: dev->scan.beacon_wait = true;
155: spin_unlock_bh(&dev->scan_lock);
156: goto out;
]
|
| 114/2 |
2026/06/16 00:20 |
llm |
expert |
0m
Model:
Tokens:
input: 82335
output: 44
thoughts: 9
Thoughts: Okay, here's my attempt at summarizing that thought process, keeping in mind I'm speaking to an expert:
**Investigating the `probe` Label**
Alright, let's get down to brass tacks. My initial thought process is to immediately hone in on the `probe` label. It's a critical point of focus, and I need to establish a clear understanding of what it represents, where it's used, and what its implications are within the broader system. I'm already mentally running through potential interpretations β is this a debugging tool, a sensor identifier, a test case marker, or something entirely different? The context will be key, but starting with the label itself is the most efficient first step. I need to quickly establish its definition and associated metadata.
|
| 115/2 |
2026/06/16 00:20 |
tool |
read-file |
0m
Args: map[File:drivers/net/wireless/mediatek/mt76/scan.c FirstLine:157 LineCount:20]
Results: map[Contents: 157: }
158:
159: probe:
160: if (phy->offchannel)
161: duration = HZ / 16; /* ~60 ms */
162: local_bh_disable();
163: for (i = 0; i < req->n_ssids; i++)
164: mt76_scan_send_probe(dev, &req->ssids[i]);
165: local_bh_enable();
166:
167: out:
168: if (dev->scan.chan && phy->offchannel)
169: duration = max_t(int, duration,
170: msecs_to_jiffies(req->duration +
171: (req->duration >> 5)));
172:
173: ieee80211_queue_delayed_work(dev->phy.hw, &dev->scan_work, duration);
174: }
175:
176: int mt76_hw_scan(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
]
|
| 116/2 |
2026/06/16 00:20 |
llm |
expert |
0m
Model:
Tokens:
input: 82893
output: 49
thoughts: 15
Thoughts: Here's my attempt at summarizing the thought process, tailored for an expert audience and written in the first person:
**Diving into `mt76_scan_send_probe`**
Alright, time to dig into `mt76_scan_send_probe`. My primary concern with this function is its role in the scanning process. Specifically, I need to understand its relationship to the broader scanning architecture within the mt76 driver. Is it the function that actually *initiates* the probe requests, or is it responsible for constructing and queueing them after some initial logic? I need to clarify how it interacts with the regulatory domain restrictions, and channel selection. Any potential bottlenecks or race conditions with other concurrent operations are key considerations.
|
| 117/2 |
2026/06/16 00:20 |
tool |
codesearch-definition-source |
0m
Error:
Args: map[ContextFile:drivers/net/wireless/mediatek/mt76/scan.c Name:mt76_scan_send_probe]
Results: map[SourceCode: SourceFile:]
|
| 118/2 |
2026/06/16 00:20 |
llm |
expert |
0m
Model:
Tokens:
input: 83131
output: 23
thoughts: 16
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:
**Investigating a Potential Issue within the mt76 Framework**
Alright, the initial thought process is pretty clear. I'm hitting a problem, and the starting point for diagnosis is to dig into the `mt76` framework. The first step is usually to see if the function `mt76_scan_send_probe` is involved. My mental checklist kicks in: I likely remember seeing that function related to probe requests, likely tied into the scanning process of the hardware. The immediate goal is to understand if there is an error in the probing sequence, or if the system crashes when attempting a scan. Now I need to figure out why this is relevant. Let's see what turns up in the codebase...
|
| 119/2 |
2026/06/16 00:21 |
tool |
grepper |
0m
Args: map[Expression:mt76_scan_send_probe]
Results: map[Output:drivers/net/wireless/mediatek/mt76/scan.c=41=static void
drivers/net/wireless/mediatek/mt76/scan.c:42:mt76_scan_send_probe(struct mt76_dev *dev, struct cfg80211_ssid *ssid)
drivers/net/wireless/mediatek/mt76/scan.c-43-{
--
drivers/net/wireless/mediatek/mt76/scan.c=107=void mt76_scan_work(struct work_struct *work)
--
drivers/net/wireless/mediatek/mt76/scan.c-163- for (i = 0; i < req->n_ssids; i++)
drivers/net/wireless/mediatek/mt76/scan.c:164: mt76_scan_send_probe(dev, &req->ssids[i]);
drivers/net/wireless/mediatek/mt76/scan.c-165- local_bh_enable();
]
|
| 120/2 |
2026/06/16 00:21 |
llm |
expert |
0m
Model:
Tokens:
input: 83612
output: 43
thoughts: 34
Thoughts: Here's my analysis of the provided text, rendered in the first person, assuming I'm an expert in the field:
**Diving into the Probe Process**
Okay, so we're looking at `mt76_scan_send_probe` within `drivers/net/wireless/mediatek/mt76/scan.c`. Immediately, I recognize this as part of the Mediatek wireless driver, specifically within the MT76 family, and the filename strongly suggests we're dealing with the probe request transmission during a Wi-Fi scan. This is a crucial function; it's the heart of how the driver actively seeks out available networks. Knowing the location, I can start to make some educated guesses about the function's internal workings. I expect it handles the formatting of the probe request frame, including setting the appropriate SSID, supported rates, and capabilities. It's likely to deal with channel selection and transmission power as well. The Mediatek driver architecture usually follows a well-defined structure for scan operations, so I'm interested to see how this particular function fits into that flow. We'll be looking for how it interacts with the hardware, the internal state management of the driver, and potential error handling in case of transmission failures or hardware issues. Time to dig in and get a closer look.
|
| 121/2 |
2026/06/16 00:21 |
tool |
read-file |
0m
Args: map[File:drivers/net/wireless/mediatek/mt76/scan.c FirstLine:41 LineCount:50]
Results: map[Contents: 41: static void
42: mt76_scan_send_probe(struct mt76_dev *dev, struct cfg80211_ssid *ssid)
43: {
44: struct cfg80211_scan_request *req = dev->scan.req;
45: struct ieee80211_vif *vif = dev->scan.vif;
46: struct mt76_vif_link *mvif = dev->scan.mlink;
47: enum nl80211_band band = dev->scan.chan->band;
48: struct mt76_phy *phy = dev->scan.phy;
49: struct ieee80211_tx_info *info;
50: struct sk_buff *skb;
51:
52: skb = ieee80211_probereq_get(phy->hw, vif->addr, ssid->ssid,
53: ssid->ssid_len, req->ie_len);
54: if (!skb)
55: return;
56:
57: if (is_unicast_ether_addr(req->bssid)) {
58: struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
59:
60: ether_addr_copy(hdr->addr1, req->bssid);
61: ether_addr_copy(hdr->addr3, req->bssid);
62: }
63:
64: if (req->ie_len)
65: skb_put_data(skb, req->ie, req->ie_len);
66:
67: skb->priority = 7;
68: skb_set_queue_mapping(skb, IEEE80211_AC_VO);
69:
70: rcu_read_lock();
71:
72: if (!ieee80211_tx_prepare_skb(phy->hw, vif, skb, band, NULL))
73: goto out;
74:
75: info = IEEE80211_SKB_CB(skb);
76: if (req->no_cck)
77: info->flags |= IEEE80211_TX_CTL_NO_CCK_RATE;
78: info->control.flags |= IEEE80211_TX_CTRL_DONT_USE_RATE_MASK;
79:
80: mt76_tx(phy, NULL, mvif->wcid, skb);
81:
82: out:
83: rcu_read_unlock();
84: }
85:
86: void mt76_scan_rx_beacon(struct mt76_dev *dev, struct ieee80211_channel *chan)
87: {
88: struct mt76_phy *phy;
89:
90: spin_lock(&dev->scan_lock);
]
|
| 122/2 |
2026/06/16 00:21 |
llm |
expert |
0m
Model:
Tokens:
input: 84814
output: 66
thoughts: 4336
Thoughts: **Vulnerability Discovered: Kernel Memory Leak via Uninitialized Value in Wireless Scan Request**
Okay, so I've been digging into this `mt76_scan_send_probe` function and it looks like we've got a pretty significant issue on our hands. The core problem boils down to an uninitialized value, `req->ie_len`, being used in a crucial spot during wireless scans. Specifically, the code attempts to create a probe request frame using `ieee80211_probereq_get`. The length of the information elements (`IEs`) for this probe request, `req->ie_len`, comes directly from a scan request, but it isn't initialized correctly under certain conditions.
Here's the breakdown: the `ieee80211_probereq_get` function allocates an SKB (Socket Buffer) with enough room for the IEs. Subsequently, `skb_put_data` attempts to copy `req->ie_len` bytes from the `req->ie` buffer *into* the SKB. Now, if `req->ie_len` is uninitialized, it can contain a very large garbage value. This means `skb_put_data` will attempt to read a massive number of bytes from a location that is, in fact, *beyond* the allocated size of the `local->hw_scan_req` buffer. This is a classic out-of-bounds read. This out-of-bounds data is then transmitted over the air via `mt76_tx`! We're talking about a remote information leak, plain and simple, and it's happening on physical wireless devices.
The kicker? This all *requires* `CAP_NET_ADMIN` to trigger, due to the netlink socket involved, and therefore isn't accessible to unprivileged processes, and isn't triggered by external network traffic (it's triggered by a local Netlink request). However, this privilege level exists in android (wpa_supplicant). So in practice this bug is exploitable for an attacker who compromises `wpa_supplicant`
However, after a deeper dive, it appears the root cause of the uninitialized `req->ie_len` value is a bit more subtle, and has to do with how the kernel *internally* builds probe request IEs, and an issue with buffer size calculations. Specifically, the `ieee80211_prep_hw_scan` function can fail in the scenario that the kernel automatically adds a "default" HE/EHT/6GHz capability IE. If the device supports these features and the kernel attempts to add the capabilities, but there isn't enough space calculated for them during the initial scan request, the `ieee80211_build_preq_ies` function will fail due to a lack of buffer room. If `ieee80211_prep_hw_scan` fails, we get the uninitialized `req->ie_len` issue! This happens because `local->scan_ies_len` gets miscalculated. And it's not simply the user not specifying any custom IEs; it's that the size of the *default* IEs added by the kernel exceeds what was calculated.
Even if `req->ie_len` *is* zero (because the user didn't specify IEs), the uninitialized value can still persist because `req.ie_len` is not copied from request. The `hw_scan_req` structure is allocated using `kmalloc` rather than `kzalloc` (zeroed memory). So, if we arrive at a scenario where `ieee80211_prep_hw_scan` fails, the `req.ie_len` is not assigned! This situation occurs when `ieee80211_build_preq_ies` fails because the IEs have overrun the buffer. The crash is predictable due to the HE/EHT/6GHz IE requirements.
Now the real revelation: this doesn't just happen with user-provided IEs! If the device *supports* HE/EHT/6GHz, the kernel *automatically* adds these capability IEs, and the bug triggers *regardless* of whether the user specified any custom IEs or not. This is a game-changer! An unprivileged application, such as an android app, can request a scan, which in turn leads to the kernel trying to add HE/EHT/6GHz IEs, and triggering the bug, leaking kernel memory. Thus, *any* scan request on a vulnerable device leads to an information leak over the air!
I've confirmed with a code inspection that the `local->hw_scan_req->req.ie_len`
|
| 123/2 |
2026/06/16 00:21 |
tool |
set-results |
0m
Args: map[DenialOfService:true Exploitable:true FilesystemTrigger:false NetworkTrigger:false PeripheralTrigger:false RemoteTrigger:false Unprivileged:false UserNamespace:false VMGuestTrigger:false VMHostTrigger:false]
Results: map[DenialOfService:true Exploitable:true FilesystemTrigger:false NetworkTrigger:false PeripheralTrigger:false RemoteTrigger:false Unprivileged:false UserNamespace:false VMGuestTrigger:false VMHostTrigger:false]
|
| 124/2 |
2026/06/16 00:21 |
llm |
expert |
0m
Model:
Tokens:
input: 90305
output: 860
thoughts: 567
Thoughts: **My Analysis of the Wireless Scan Vulnerability**
Okay, the results are in, and now it's time to craft the final response. My analysis has led me to a pretty nasty vulnerability. It seems the core problem lies within the `__ieee80211_start_scan` function. It's allocating `local->hw_scan_req` using `kmalloc`, but crucial fields within it, like `req.ie_len`, `req.mac_addr`, and `req.mac_addr_mask`, are left completely uninitialized. These are *supposed* to be set up properly by `ieee80211_prep_hw_scan`.
Here's the kicker: If `ieee80211_prep_hw_scan` fails (which, as we know, *can* happen), a `WARN_ON` fires, but the code carries on, calling `drv_hw_scan` anyway, with this partially uninitialized `local->hw_scan_req`.
Now, `ieee80211_prep_hw_scan` can fail for a couple of reasons: a miscalculation of `local->scan_ies_len` (specifically, it seems to miss the 5 bytes for `he_6ghz_cap`), leading to `ieee80211_build_preq_ies` choking with `-ENOBUFS` because the `skb_tailroom` isn't big enough. Or, there's a race condition β a concurrent scan cancellation can set the `SCAN_HW_CANCELLED` bit.
So, *when* `drv_hw_scan` gets called with this garbage, all hell breaks loose. Drivers like `mac80211_hwsim` or `mt76` blithely use this totally random `req.ie_len` value to copy data from the uninitialized `req.ie` pointer into a probe request `skb`. Boom, out-of-bounds kernel heap memory read. This then gets transmitted over the air (or simulated in the case of `mac80211_hwsim`), resulting in a remote information leak. And, if that uninitialized `req.ie_len` happens to be larger than the available tailroom, `skb_put` triggers a kernel panic, a delightful Denial of Service. Oh, and it's even worse. Drivers such as `iwlwifi` could end up using `ies->ies`, which could point to a freed `skb` buffer if `ieee80211_build_preq_ies` bombs out, leading to a Use-After-Free read.
The triggering condition involves `CAP_NET_ADMIN` in the network namespace of the wireless device, which is needed to trigger `NL80211_CMD_TRIGGER_SCAN`. While the Netlink command is user-accessible, it isn't accessible to unprivileged users in a standard production environment, unless you're testing modules like `mac80211_hwsim`.
|
| 125/1 |
2026/06/16 00:22 |
action |
format-explanation |
0m
Results: map[Explanation:The bug report indicates a `WARNING` in `__ieee80211_start_scan` when
`ieee80211_prep_hw_scan` returns `false`.
### Bug Analysis
In `__ieee80211_start_scan`, the `local->hw_scan_req` structure is allocated
using `kmalloc`, which leaves its contents uninitialized. Several fields, such
as `req.ie_len`, `req.mac_addr`, and `req.mac_addr_mask`, are expected to be
initialized later by `ieee80211_prep_hw_scan`.
However, `ieee80211_prep_hw_scan` can fail and return `false` in a couple of
scenarios:
1. **Buffer size miscalculation:** The `local->scan_ies_len` calculation in
`ieee80211_register_hw` fails to account for the 5 bytes required by the
`he_6ghz_cap` element. When `ieee80211_build_preq_ies` attempts to append this
element, it runs out of `skb_tailroom` and returns `-ENOBUFS`.
2. **Race condition:** If a scan is concurrently aborted, the
`SCAN_HW_CANCELLED` bit is set, causing `ieee80211_prep_hw_scan` to immediately
return `false`.
When `ieee80211_prep_hw_scan` returns `false`, a `WARN_ON` is triggered, but
**execution does not halt**. The kernel proceeds to call the driver's
`drv_hw_scan` callback with the partially uninitialized `local->hw_scan_req`.
### Security Impact
**Exploitable & Denial of Service:**
This is highly exploitable for both Information Leaks and Denial of Service
(DoS):
- **Out-of-Bounds Read / Info Leak:** Drivers like `mt76` and `mac80211_hwsim`
use the uninitialized `req.ie_len` to copy data from the uninitialized `req.ie`
pointer into a probe request `skb`. Since `req.ie_len` can be a large garbage
value, this results in a massive out-of-bounds read of kernel heap memory. This
leaked memory is then transmitted over the air in the probe request, leading to
a remote information leak that can expose sensitive kernel data or bypass KASLR.
- **Kernel Panic (DoS):** If the uninitialized `req.ie_len` is larger than the
allocated `skb` tailroom, the `skb_put` function will trigger a kernel panic,
resulting in a DoS.
- **Use-After-Free (UAF):** For drivers like `iwlwifi` that rely on `ies->ies`
and `ies->len`, a failure in `ieee80211_build_preq_ies` causes `ies->ies` to
point to a freed `skb` buffer. The driver will then read from this freed buffer
(UAF read) to construct the probe request.
**Privilege Requirements:**
Triggering this bug requires sending the `NL80211_CMD_TRIGGER_SCAN` netlink
command. While this command has the `GENL_UNS_ADMIN_PERM` flag (meaning it can
be called from a user namespace where the user has `CAP_NET_ADMIN`), it requires
a wireless device (`wiphy`) to be present in that network namespace.
Physical wireless devices reside in the init network namespace by default and
cannot be moved to an unprivileged user namespace without root privileges.
Unless a testing module like `mac80211_hwsim` is loaded (which allows
unprivileged creation of virtual radios), an unprivileged user cannot reach this
code path. Therefore, it is not accessible from unprivileged processes or user
namespaces in a typical production environment.]
|