| 0/0 |
2026/05/25 12:55 |
flow |
assessment-security |
46m
Results: map[DenialOfService:true Explanation:**Bug Analysis:**
The bug report indicates a softlockup (RCU stall) in the `caif_serial` network
device driver, specifically within the `handle_tx` function.
1. **Root Cause:**
The `caif_serial` driver registers a line discipline that can be attached to
a TTY (like a UART serial port). When the network stack queues a packet for
transmission via `dev_queue_xmit`, it eventually calls `handle_tx`.
In `handle_tx`, there is a loop that attempts to write the socket buffer
(`skb`) data to the TTY:
```c
while ((skb = skb_peek(&ser->head)) != NULL) {
len = skb->len;
room = tty_write_room(tty);
if (!room)
break;
// ...
tty_wr = tty->ops->write(tty, skb->data, len);
// ...
skb_pull(skb, tty_wr);
}
```
The bug occurs because `tty_write_room()` (which maps to `uart_write_room()`)
can return a value `> 0` while `tty->ops->write()` (which maps to
`uart_write()`) returns `0`. If `tty_wr == 0`, `skb_pull()` does not consume
any data, `skb->len` remains unchanged, and the loop continues infinitely,
causing a CPU softlockup.
This mismatch happens during the TTY shutdown phase. When a UART is being
closed or hung up, `uart_shutdown()` frees the transmission buffer
(`xmit_buf`) and re-initializes the `xmit_fifo`. An empty/uninitialized
`kfifo` reports that it has available room, so `uart_write_room()` returns `>
0`. However, `uart_write()` explicitly checks if `xmit_buf` is `NULL` and
returns `0` if it is. If a packet is queued for transmission during this
narrow shutdown window, the infinite loop is triggered.
2. **Trigger Mechanism:**
In the provided crash report, the `aoe` (ATA over Ethernet) kernel thread
`aoe_tx0` is sending a packet. `aoe` broadcasts discovery packets over all
available network interfaces, including the `caif_serial` interface. If `aoe`
transmits a packet exactly when the `caif_serial` TTY is being closed, the
softlockup occurs.
3. **Security Impact:**
- **Exploitable:** No. The bug is a classic infinite loop leading to a CPU
stall. It does not cause memory corruption, use-after-free, or out-of-bounds
accesses.
- **Denial of Service:** Yes. The infinite loop halts the CPU, leading to a
system-wide Denial of Service (RCU stall / softlockup).
- **Unprivileged / User Namespace:** No. Attaching the `caif_serial` line
discipline to a TTY requires `CAP_SYS_ADMIN` or `CAP_SYS_TTY_CONFIG` in the
**initial** user namespace (`capable()` is used instead of `ns_capable()`).
Therefore, an unprivileged user (even within a user namespace) cannot set up
the vulnerable `caif_serial` interface.
- **Remote / Network / Peripheral:** Triggering the bug requires a highly
specific race condition where a privileged user (or a system daemon) is
actively closing the TTY while network traffic is concurrently routed to it.
While network traffic (like `aoe` broadcasts) is involved, an attacker cannot
reliably trigger the TTY shutdown sequence remotely or via a peripheral
device unless the system is specifically configured to auto-attach and
auto-detach `caif_serial` on hotplug events (which is not the default).
**Conclusion:**
This is a Denial of Service vulnerability caused by a race condition during TTY
shutdown in the `caif_serial` driver. It is not exploitable for privilege
escalation or memory corruption, and it cannot be reached by unprivileged users
or reliably triggered by external attackers. Exploitable:false FilesystemTrigger:false NetworkTrigger:false PeripheralTrigger:false RemoteTrigger:false Unprivileged:false UserNamespace:false VMGuestTrigger:false VMHostTrigger:false]
|
| 1/1 |
2026/05/25 12:55 |
action |
syz-repro-to-c-repro |
0m
Results:
|
| 2/1 |
2026/05/25 12:55 |
action |
kernel-checkouter |
1m
Results: map[KernelSrc:/app/workdir/cache/src/35bd961c46ed3a7403d173683a128de985a55ae0]
|
| 3/1 |
2026/05/25 12:56 |
action |
kernel-builder |
18m
Results: map[KernelObj:/app/workdir/cache/build/e0dbaa63b2efefbc1b1b07dab2454bcd64c1a9ab]
|
| 4/1 |
2026/05/25 13:15 |
action |
codesearch-prepare |
13m
Results: map[Index:codesearch-index]
|
| 5/1 |
2026/05/25 13:28 |
agent |
expert |
13m
Model:
Results: map[DenialOfService:true Exploitable:false 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 greeping
".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 or elevated privileges.
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 completly 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 tranfers, that's 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 exploitabability depends on how exactly the uninit value
is used in the code, and what it affects.
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 Confidetial 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:
rcu: INFO: rcu_preempt detected stalls on CPUs/tasks:
rcu: Tasks blocked on level-0 rcu_node (CPUs 0-1): P6514/1:b..l
rcu: (detected by 1, t=10502 jiffies, g=73437, q=565 ncpus=2)
task:kworker/u8:12 state:R running task stack:24648 pid:6514 tgid:6514 ppid:2 task_flags:0x4208060 flags:0x00080000
Workqueue: iou_exit io_ring_exit_work
Call Trace:
<TASK>
context_switch kernel/sched/core.c:5295 [inline]
__schedule+0xfee/0x6120 kernel/sched/core.c:6908
preempt_schedule_irq+0x50/0x90 kernel/sched/core.c:7235
irqentry_exit+0x17b/0x670 kernel/entry/common.c:239
asm_sysvec_apic_timer_interrupt+0x1a/0x20 arch/x86/include/asm/idtentry.h:697
RIP: 0010:__orc_find+0x3d/0xf0 arch/x86/kernel/unwind_orc.c:105
Code: 53 48 83 ec 08 85 d2 0f 84 99 00 00 00 49 89 fe 48 89 f0 49 39 fc 72 7b 48 b9 00 00 00 00 00 fc ff df 49 89 ff 48 89 fd eb 0c <48> 8d 6b 04 49 89 df 49 39 ec 72 4e 4c 89 e2 48 29 ea 48 89 d6 48
RSP: 0018:ffffc90003187588 EFLAGS: 00000206
RAX: ffffffff9179f9b4 RBX: ffffffff90f2c004 RCX: dffffc0000000000
RDX: ffffffff81d1f6f5 RSI: 0000000000000000 RDI: ffffffff90f2c004
RBP: ffffffff90f2c004 R08: ffffffff9179f9ba R09: 0000000000000007
R10: 0000000000000200 R11: 000000000000d1fa R12: ffffffff90f2c004
R13: ffffffff81d1fa4f R14: ffffffff90f2c004 R15: ffffffff90f2c004
orc_find arch/x86/kernel/unwind_orc.c:238 [inline]
unwind_next_frame+0x2ec/0x1ea0 arch/x86/kernel/unwind_orc.c:510
arch_stack_walk+0x94/0xf0 arch/x86/kernel/stacktrace.c:25
stack_trace_save+0x8e/0xc0 kernel/stacktrace.c:122
kasan_save_stack+0x30/0x50 mm/kasan/common.c:57
kasan_record_aux_stack+0xa7/0xc0 mm/kasan/generic.c:556
__call_rcu_common.constprop.0+0xa5/0x9b0 kernel/rcu/tree.c:3131
slab_free_hook mm/slub.c:2656 [inline]
slab_free mm/slub.c:6143 [inline]
kmem_cache_free+0x44b/0x6a0 mm/slub.c:6273
__io_req_caches_free+0x1a6/0x220 io_uring/io_uring.c:2133
io_req_caches_free+0x24/0x60 io_uring/io_uring.c:2145
io_ring_exit_work+0x3eb/0xce9 io_uring/io_uring.c:2339
process_one_work+0x9d7/0x1920 kernel/workqueue.c:3275
process_scheduled_works kernel/workqueue.c:3358 [inline]
worker_thread+0x5da/0xe40 kernel/workqueue.c:3439
kthread+0x370/0x450 kernel/kthread.c:467
ret_from_fork+0x754/0xd80 arch/x86/kernel/process.c:158
ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245
</TASK>
rcu: rcu_preempt kthread timer wakeup didn't happen for 10536 jiffies! g73437 f0x0 RCU_GP_WAIT_FQS(5) ->state=0x402
rcu: Possible timer handling issue on cpu=1 timer-softirq=79202
rcu: rcu_preempt kthread starved for 10537 jiffies! g73437 f0x0 RCU_GP_WAIT_FQS(5) ->state=0x402 ->cpu=1
rcu: Unless rcu_preempt kthread gets sufficient CPU time, OOM is now expected behavior.
rcu: RCU grace-period kthread stack dump:
task:rcu_preempt state:I stack:27976 pid:16 tgid:16 ppid:2 task_flags:0x208040 flags:0x00080000
Call Trace:
<TASK>
context_switch kernel/sched/core.c:5295 [inline]
__schedule+0xfee/0x6120 kernel/sched/core.c:6908
__schedule_loop kernel/sched/core.c:6990 [inline]
schedule+0xdd/0x390 kernel/sched/core.c:7005
schedule_timeout+0x127/0x280 kernel/time/sleep_timeout.c:99
rcu_gp_fqs_loop+0x1a9/0x900 kernel/rcu/tree.c:2095
rcu_gp_kthread+0x179/0x230 kernel/rcu/tree.c:2297
kthread+0x370/0x450 kernel/kthread.c:467
ret_from_fork+0x754/0xd80 arch/x86/kernel/process.c:158
ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245
</TASK>
rcu: Stack dump where RCU GP kthread last ran:
CPU: 1 UID: 0 PID: 1296 Comm: aoe_tx0 Tainted: G L syzkaller #0 PREEMPT(full)
Tainted: [L]=SOFTLOCKUP
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 02/12/2026
RIP: 0010:__raw_spin_unlock_irqrestore include/linux/spinlock_api_smp.h:179 [inline]
RIP: 0010:_raw_spin_unlock_irqrestore+0x31/0x80 kernel/locking/spinlock.c:194
Code: f5 53 48 8b 74 24 10 48 89 fb 48 83 c7 18 e8 56 21 52 f6 48 89 df e8 3e 71 52 f6 f7 c5 00 02 00 00 75 23 9c 58 f6 c4 02 75 37 <bf> 01 00 00 00 e8 c5 90 42 f6 65 8b 05 5e ee 7a 08 85 c0 74 16 5b
RSP: 0018:ffffc90004e9f968 EFLAGS: 00000246
RAX: 0000000000000006 RBX: ffffffff9b4a14c0 RCX: 0000000000000004
RDX: 0000000000000000 RSI: ffffffff8de72ef9 RDI: ffffffff8c1af6a0
RBP: 0000000000000293 R08: 0000000000000001 R09: 0000000000000000
R10: 0000000000000001 R11: 0000000000000000 R12: ffffffff8f512ba0
R13: ffffffff9b4a15c8 R14: 0000000000000000 R15: ffffffff9b4a1600
FS: 0000000000000000(0000) GS:ffff888124445000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007fceb4f1c008 CR3: 00000000829f9000 CR4: 00000000003526f0
Call Trace:
<TASK>
spin_unlock_irqrestore include/linux/spinlock.h:407 [inline]
uart_port_unlock_irqrestore include/linux/serial_core.h:788 [inline]
uart_port_unlock_deref drivers/tty/serial/serial_core.c:91 [inline]
uart_port_unlock_deref drivers/tty/serial/serial_core.c:88 [inline]
uart_write_room+0x2d2/0x930 drivers/tty/serial/serial_core.c:647
tty_write_room+0x66/0x90 drivers/tty/tty_ioctl.c:69
handle_tx+0x14a/0x620 drivers/net/caif/caif_serial.c:212
__netdev_start_xmit include/linux/netdevice.h:5275 [inline]
netdev_start_xmit include/linux/netdevice.h:5284 [inline]
xmit_one net/core/dev.c:3871 [inline]
dev_hard_start_xmit+0x121/0x7d0 net/core/dev.c:3887
__dev_queue_xmit+0x32c1/0x4800 net/core/dev.c:4840
dev_queue_xmit include/linux/netdevice.h:3384 [inline]
tx+0xc4/0x130 drivers/block/aoe/aoenet.c:62
kthread+0x1d8/0x3c0 drivers/block/aoe/aoecmd.c:1241
kthread+0x370/0x450 kernel/kthread.c:467
ret_from_fork+0x754/0xd80 arch/x86/kernel/process.c:158
ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245
</TASK>
Reply: **Bug Analysis:**
The bug report indicates a softlockup (RCU stall) in the `caif_serial` network device driver, specifically within the `handle_tx` function.
1. **Root Cause:**
The `caif_serial` driver registers a line discipline that can be attached to a TTY (like a UART serial port). When the network stack queues a packet for transmission via `dev_queue_xmit`, it eventually calls `handle_tx`.
In `handle_tx`, there is a loop that attempts to write the socket buffer (`skb`) data to the TTY:
```c
while ((skb = skb_peek(&ser->head)) != NULL) {
len = skb->len;
room = tty_write_room(tty);
if (!room)
break;
// ...
tty_wr = tty->ops->write(tty, skb->data, len);
// ...
skb_pull(skb, tty_wr);
}
```
The bug occurs because `tty_write_room()` (which maps to `uart_write_room()`) can return a value `> 0` while `tty->ops->write()` (which maps to `uart_write()`) returns `0`. If `tty_wr == 0`, `skb_pull()` does not consume any data, `skb->len` remains unchanged, and the loop continues infinitely, causing a CPU softlockup.
This mismatch happens during the TTY shutdown phase. When a UART is being closed or hung up, `uart_shutdown()` frees the transmission buffer (`xmit_buf`) and re-initializes the `xmit_fifo`. An empty/uninitialized `kfifo` reports that it has available room, so `uart_write_room()` returns `> 0`. However, `uart_write()` explicitly checks if `xmit_buf` is `NULL` and returns `0` if it is. If a packet is queued for transmission during this narrow shutdown window, the infinite loop is triggered.
2. **Trigger Mechanism:**
In the provided crash report, the `aoe` (ATA over Ethernet) kernel thread `aoe_tx0` is sending a packet. `aoe` broadcasts discovery packets over all available network interfaces, including the `caif_serial` interface. If `aoe` transmits a packet exactly when the `caif_serial` TTY is being closed, the softlockup occurs.
3. **Security Impact:**
- **Exploitable:** No. The bug is a classic infinite loop leading to a CPU stall. It does not cause memory corruption, use-after-free, or out-of-bounds accesses.
- **Denial of Service:** Yes. The infinite loop halts the CPU, leading to a system-wide Denial of Service (RCU stall / softlockup).
- **Unprivileged / User Namespace:** No. Attaching the `caif_serial` line discipline to a TTY requires `CAP_SYS_ADMIN` or `CAP_SYS_TTY_CONFIG` in the **initial** user namespace (`capable()` is used instead of `ns_capable()`). Therefore, an unprivileged user (even within a user namespace) cannot set up the vulnerable `caif_serial` interface.
- **Remote / Network / Peripheral:** Triggering the bug requires a highly specific race condition where a privileged user (or a system daemon) is actively closing the TTY while network traffic is concurrently routed to it. While network traffic (like `aoe` broadcasts) is involved, an attacker cannot reliably trigger the TTY shutdown sequence remotely or via a peripheral device unless the system is specifically configured to auto-attach and auto-detach `caif_serial` on hotplug events (which is not the default).
**Conclusion:**
This is a Denial of Service vulnerability caused by a race condition during TTY shutdown in the `caif_serial` driver. It is not exploitable for privilege escalation or memory corruption, and it cannot be reached by unprivileged users or reliably triggered by external attackers.
|
| 6/2 |
2026/05/25 13:28 |
llm |
expert |
0m
Model:
Tokens:
input: 8619
output: 41
thoughts: 1734
Thoughts: **RCU Stall Investigation**
Okay, here's what I'm seeing. We've got an RCU preemption stall reported, and that always sets off alarm bells. The report indicates a blocked task, `P6514/1:b..l`, on CPU 0. Time to dig in.
Looking at the first stack trace, it's pretty clear that there's an issue during an RCU operation. Specifically, it looks like `__call_rcu_common` is involved, and that ultimately ties back to freeing an io_uring request cache. The stack contains `kasan_record_aux_stack`, indicating KASAN is active. This can complicate the unwind a bit, but the fundamental issue seems to be something getting held up in memory management while freeing resources associated with an I/O ring.
Now, the second stack trace is where things get interesting. We have a tainted kernel with `SOFTLOCKUP` flagged. The call trace shows `aoe_tx0`, an ATA over Ethernet thread from `aoecmd.c`. This thread is calling `tx`, which then goes through `dev_queue_xmit` and lands in the `caif_serial` driver's `handle_tx` function, hitting `tty_write_room` and then `uart_write_room`. The key here is that it's locking a spinlock with interrupts disabled.
The connection between the traces is unclear at this moment.
The `aoe` protocol allows for the use of any network interface, and this one is using `caif_serial`, which is... CAIF? That's a Compact Asynchronous Interface. I need to refresh my memory on the interactions. I'll need to check the code to see why `aoe` would be using a serial device. Is there a shared lock or resource between the two paths? Are we seeing contention on the UART or serial port driver while the io_uring cleanup is in progress? Something is likely blocking this thread. Could it be a lock inversion, a deadlock, or perhaps some kind of data race between the I/O cleanup and the transmission thread? This warrants further investigation to understand the dependency. Time to dive into `drivers/block/aoe/aoenet.c` and figure out how this `caif_serial` interface is used within the `aoe` context.
|
| 7/2 |
2026/05/25 13:28 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/block/aoe/aoenet.c IncludeLines:true Name:tx]
Results: map[SourceCode: 52: /* enters with txlock held */
53: static int
54: tx(int id) __must_hold(&txlock)
55: {
56: struct sk_buff *skb;
57: struct net_device *ifp;
58:
59: while ((skb = skb_dequeue(&skbtxq))) {
60: spin_unlock_irq(&txlock);
61: ifp = skb->dev;
62: if (dev_queue_xmit(skb) == NET_XMIT_DROP && net_ratelimit())
63: pr_warn("aoe: packet could not be sent on %s. %s\n",
64: ifp ? ifp->name : "netif",
65: "consider increasing tx_queue_len");
66: dev_put(ifp);
67: spin_lock_irq(&txlock);
68: }
69: return 0;
70: }
SourceFile:drivers/block/aoe/aoenet.c]
|
| 8/2 |
2026/05/25 13:28 |
llm |
expert |
0m
Model:
Tokens:
input: 11208
output: 51
thoughts: 54
Thoughts: Okay, here's my interpretation of that thought process, tailored for an expert audience:
**Analyzing Packet Flow in `aoe`**
Alright, let's break this down. My initial thought process is centered on understanding the packet flow within `aoe`. Specifically, I'm observing the interaction between `aoe` and `skbtxq`. My initial understanding is that `aoe` is responsible for retrieving packets from the `skbtxq` queue and then transmitting them using `dev_queue_xmit`.
Now, the critical question becomes: *where* are these packets initially being placed into `skbtxq`? Knowing this upstream source is absolutely vital to fully grasp the end-to-end packet processing. That's the logical next step in tracing this flow. I'm going to dig into the code and determine exactly how the `skbtxq` queue gets populated in the first place. This is where the real interesting stuff is – understanding the upstream queuing mechanisms and any potential bottlenecks before `aoe` even gets a chance to see them.
|
| 9/2 |
2026/05/25 13:28 |
tool |
codesearch-find-references |
0m
Error:
Args: map[ContextFile:drivers/block/aoe/aoenet.c IncludeSnippetLines:0 Name:skbtxq SourceTreePrefix:]
Results: map[References:<nil> TruncatedOutput:false]
|
| 10/2 |
2026/05/25 13:28 |
llm |
expert |
0m
Model:
Tokens:
input: 11557
output: 30
thoughts: 21
Thoughts: Okay, here's my interpretation of those thoughts, tailored for an expert audience:
**Debugging a Potential Global/Static Variable Issue**
Right, so I've stumbled upon something. It looks like we're dealing with a global variable or perhaps a static one in this context. These are always the usual suspects when you start seeing odd behavior that seems to persist across function calls or threads. My immediate instinct is to check where it's declared and initialized, and, more importantly, where it's being accessed and modified. Given the context (assuming this is related to something like an "aoe" network implementation), my attention immediately turns to `aoenet.c`. That file is likely where the core network functionality, and thus the global state relevant to that, resides. Let's dig in and see what we can find. I’ll be looking for declaration, use, and any potential race conditions if this variable is being touched from multiple threads.
|
| 11/2 |
2026/05/25 13:28 |
tool |
codesearch-file-index |
0m
Args: map[SourceFile:drivers/block/aoe/aoenet.c]
Results: map[Entities:[map[Kind:function Name:aoe_iflist_setup] map[Kind:function Name:aoenet_exit] map[Kind:function Name:aoenet_init] map[Kind:function Name:aoenet_rcv] map[Kind:function Name:aoenet_xmit] map[Kind:function Name:is_aoe_netif] map[Kind:function Name:set_aoe_iflist] map[Kind:function Name:tx] map[Kind:global_variable Name:__UNIQUE_ID_modinfo_1224] map[Kind:global_variable Name:__UNIQUE_ID_modinfo_1225] map[Kind:global_variable Name:__param_aoe_iflist] map[Kind:global_variable Name:__param_str_aoe_iflist] map[Kind:global_variable Name:__param_string_aoe_iflist] map[Kind:global_variable Name:__setup_aoe_iflist_setup] map[Kind:global_variable Name:__setup_str_aoe_iflist_setup] map[Kind:global_variable Name:aoe_errlist] map[Kind:global_variable Name:aoe_pt]]]
|
| 12/2 |
2026/05/25 13:28 |
llm |
expert |
0m
Model:
Tokens:
input: 12148
output: 17
thoughts: 30
Thoughts: Here's my thought process, summarized as you requested:
**Investigating a Potentially Obscure Symbol**
Okay, so I've encountered this symbol, `skbtxq`, and it's not immediately obvious what it is. My initial hunch is that it might be defined within the `aoecmd.c` source file. It's a fairly common pattern to organize related functions and data structures within a single source file in C projects, particularly for command-line utilities like this.
Let's quickly verify that assumption. I'm going to search for `skbtxq` within the project. Hopefully, I'll turn something up; if not, then I'll need to broaden my search. But, `aoecmd.c` feels like a likely spot.
|
| 13/2 |
2026/05/25 13:29 |
tool |
grepper |
0m
Args:
Results: map[Output:drivers/block/aoe/aoenet.c=49=static spinlock_t txlock;
drivers/block/aoe/aoenet.c:50:static struct sk_buff_head skbtxq;
drivers/block/aoe/aoenet.c-51-
--
drivers/block/aoe/aoenet.c=54=tx(int id) __must_hold(&txlock)
--
drivers/block/aoe/aoenet.c-58-
drivers/block/aoe/aoenet.c:59: while ((skb = skb_dequeue(&skbtxq))) {
drivers/block/aoe/aoenet.c-60- spin_unlock_irq(&txlock);
--
drivers/block/aoe/aoenet.c=113=aoenet_xmit(struct sk_buff_head *queue)
--
drivers/block/aoe/aoenet.c-120- spin_lock_irqsave(&txlock, flags);
drivers/block/aoe/aoenet.c:121: skb_queue_tail(&skbtxq, skb);
drivers/block/aoe/aoenet.c-122- spin_unlock_irqrestore(&txlock, flags);
--
drivers/block/aoe/aoenet.c=200=aoenet_init(void)
drivers/block/aoe/aoenet.c-201-{
drivers/block/aoe/aoenet.c:202: skb_queue_head_init(&skbtxq);
drivers/block/aoe/aoenet.c-203- init_waitqueue_head(&txwq);
--
drivers/block/aoe/aoenet.c=217=aoenet_exit(void)
--
drivers/block/aoe/aoenet.c-219- aoe_ktstop(&kts);
drivers/block/aoe/aoenet.c:220: skb_queue_purge(&skbtxq);
drivers/block/aoe/aoenet.c-221- dev_remove_pack(&aoe_pt);
]
|
| 14/2 |
2026/05/25 13:29 |
llm |
expert |
0m
Model:
Tokens:
input: 12893
output: 53
thoughts: 31
Thoughts: Here's my take on those thoughts, tailored for an expert audience:
**Analyzing the AOE Network Transmission Path**
Alright, so `aoenet_xmit` is clearly the critical function responsible for queuing packets destined for the AoE network onto the `skbtxq` (socket buffer transmit queue). My initial focus is to trace the execution path and understand the conditions under which `aoenet_xmit` gets invoked. Knowing the callers will be crucial for understanding the overall AoE data flow and identifying potential bottlenecks or areas for optimization. I need to figure out the source of these packets. Are they from the block driver? The network stack directly? And what triggers the queueing? I'll probably start with a static analysis to locate all call sites of `aoenet_xmit` and then delve into the code to understand the context and rationale behind each call, as well as the arguments passed, like the skb.
|
| 15/2 |
2026/05/25 13:29 |
tool |
codesearch-find-references |
0m
Args: map[ContextFile:drivers/block/aoe/aoenet.c IncludeSnippetLines:0 Name:aoenet_xmit SourceTreePrefix:]
Results: map[References:[map[ReferenceKind:calls ReferencingEntityKind:function ReferencingEntityName:aoecmd_ata_rw SourceFile:drivers/block/aoe/aoecmd.c SourceLine:404] map[ReferenceKind:calls ReferencingEntityKind:function ReferencingEntityName:aoecmd_cfg SourceFile:drivers/block/aoe/aoecmd.c SourceLine:1375] map[ReferenceKind:calls ReferencingEntityKind:function ReferencingEntityName:aoecmd_cfg_rsp SourceFile:drivers/block/aoe/aoecmd.c SourceLine:1607] map[ReferenceKind:calls ReferencingEntityKind:function ReferencingEntityName:probe SourceFile:drivers/block/aoe/aoecmd.c SourceLine:625] map[ReferenceKind:calls ReferencingEntityKind:function ReferencingEntityName:resend SourceFile:drivers/block/aoe/aoecmd.c SourceLine:499] map[ReferenceKind:calls ReferencingEntityKind:function ReferencingEntityName:revalidate SourceFile:drivers/block/aoe/aoechr.c SourceLine:130]] TruncatedOutput:false]
|
| 16/2 |
2026/05/25 13:29 |
llm |
expert |
0m
Model:
Tokens:
input: 13510
output: 45
thoughts: 82
Thoughts: **Analyzing a Network Block Device Issue**
Okay, so I'm looking at this `aoe` thing, which I understand is a block driver designed to transmit ATA commands over Ethernet. The bug report is pointing me toward `aoe_tx0`, and it looks like it's trying to use `dev_queue_xmit` on `caif_serial`. Wait a minute, `caif_serial`... that's a serial device driver, specifically for CAIF, right? That doesn't seem right for this application. I need to get a clearer picture of what's going on, so the next logical step is to dive into the code. Let's head over to `drivers/net/caif/caif_serial.c` and see what's actually happening on the serial driver side of things. I'm hoping I can find the root cause by examining the interaction between these drivers, and identify where the network block device is trying to transmit through a serial port.
|
| 17/2 |
2026/05/25 13:29 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/net/caif/caif_serial.c IncludeLines:true Name:handle_tx]
Results: map[SourceCode: 194: static int handle_tx(struct ser_device *ser)
195: {
196: struct tty_struct *tty;
197: struct sk_buff *skb;
198: int tty_wr, len, room;
199:
200: tty = ser->tty;
201: ser->tx_started = true;
202:
203: /* Enter critical section */
204: if (test_and_set_bit(CAIF_SENDING, &ser->state))
205: return 0;
206:
207: /* skb_peek is safe because handle_tx is called after skb_queue_tail */
208: while ((skb = skb_peek(&ser->head)) != NULL) {
209:
210: /* Make sure you don't write too much */
211: len = skb->len;
212: room = tty_write_room(tty);
213: if (!room)
214: break;
215: if (room > ser_write_chunk)
216: room = ser_write_chunk;
217: if (len > room)
218: len = room;
219:
220: /* Write to tty or loopback */
221: if (!ser_loop) {
222: tty_wr = tty->ops->write(tty, skb->data, len);
223: update_tty_status(ser);
224: } else {
225: tty_wr = len;
226: ldisc_receive(tty, skb->data, NULL, len);
227: }
228: ser->dev->stats.tx_packets++;
229: ser->dev->stats.tx_bytes += tty_wr;
230:
231: /* Error on TTY ?! */
232: if (tty_wr < 0)
233: goto error;
234: /* Reduce buffer written, and discard if empty */
235: skb_pull(skb, tty_wr);
236: if (skb->len == 0) {
237: struct sk_buff *tmp = skb_dequeue(&ser->head);
238: WARN_ON(tmp != skb);
239: dev_consume_skb_any(skb);
240: }
241: }
242: /* Send flow off if queue is empty */
243: if (ser->head.qlen <= SEND_QUEUE_LOW &&
244: test_and_clear_bit(CAIF_FLOW_OFF_SENT, &ser->state) &&
245: ser->common.flowctrl != NULL)
246: ser->common.flowctrl(ser->dev, ON);
247: clear_bit(CAIF_SENDING, &ser->state);
248: return 0;
249: error:
250: clear_bit(CAIF_SENDING, &ser->state);
251: return tty_wr;
252: }
SourceFile:drivers/net/caif/caif_serial.c]
|
| 18/2 |
2026/05/25 13:29 |
llm |
expert |
0m
Model:
Tokens:
input: 14782
output: 43
thoughts: 430
Thoughts: **Debugging a Potential Softlockup**
Okay, so I'm looking at this stack trace, and it's pointing me right to `_raw_spin_unlock_irqrestore`. Hmm, that suggests a lock contention issue, specifically within `uart_write_room`. The trace leads me there from `handle_tx`, which is interesting. I see that `handle_tx` calls `tty_write_room`, which then calls `uart_write_room`. And I remember `uart_write_room` deals with locking and unlocking.
Wait, why would it be spinning in `_raw_spin_unlock_irqrestore`? It should be unlocking, so something must be preventing the lock from actually being released. I need to figure out the context of that lock in `uart_write_room`.
Aha! `uart_write_room` does take and unlock the lock. Now, could `uart_write_room` be called repeatedly within a loop in `handle_tx`? Let's see... Yep, there's a `while ((skb = skb_peek(&ser->head)) != NULL)` loop in `handle_tx`. That looks like a potential infinite loop if there's a problem.
Here's the problem: `tty_write_room` checks if the room is greater than zero and then writes to the tty. It calls `tty->ops->write(tty, skb->data, len)`. But what happens if `tty->ops->write` returns zero? If it returns zero, `skb_pull(skb, 0)` does nothing. So, `skb->len` remains greater than zero. The loop continues, checking the room again. If `tty->ops->write` *always* returns zero, it's going to loop indefinitely! That's it! It is not releasing the data and so the serial buffer fills up. This explains the softlockup.
Time to look at `uart_write`. That's where the problem lies.
|
| 19/2 |
2026/05/25 13:29 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/tty/serial/serial_core.c IncludeLines:true Name:uart_write]
Results: map[SourceCode: 610: static ssize_t uart_write(struct tty_struct *tty, const u8 *buf, size_t count)
611: {
612: struct uart_state *state = tty->driver_data;
613: struct uart_port *port;
614: unsigned long flags;
615: int ret = 0;
616:
617: /*
618: * This means you called this function _after_ the port was
619: * closed. No cookie for you.
620: */
621: if (WARN_ON(!state))
622: return -EL3HLT;
623:
624: port = uart_port_ref_lock(state, &flags);
625: if (!state->port.xmit_buf) {
626: uart_port_unlock_deref(port, flags);
627: return 0;
628: }
629:
630: if (port)
631: ret = kfifo_in(&state->port.xmit_fifo, buf, count);
632:
633: __uart_start(state);
634: uart_port_unlock_deref(port, flags);
635: return ret;
636: }
SourceFile:drivers/tty/serial/serial_core.c]
|
| 20/2 |
2026/05/25 13:29 |
llm |
expert |
0m
Model:
Tokens:
input: 16105
output: 45
thoughts: 47
Thoughts: **Analyzing UART Write Functionality**
Okay, so I'm looking at this `uart_write` function, and there's a quick check at the beginning: if `state->port.xmit_buf` is NULL, it immediately returns 0. That makes sense, a NULL buffer would mean we can't write anything. However, the interesting part is the potential discrepancy: could `uart_write_room` return a value greater than 0 even when `uart_write` returns 0? That would be unexpected behavior, potentially a bug. I need to investigate this further. I'll need to dig into the `uart_write_room` function to understand why this inconsistency might exist, or if it is intentional for some reason. Let me check what that function does.
|
| 21/2 |
2026/05/25 13:29 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/tty/serial/serial_core.c IncludeLines:true Name:uart_write_room]
Results: map[SourceCode: 638: static unsigned int uart_write_room(struct tty_struct *tty)
639: {
640: struct uart_state *state = tty->driver_data;
641: struct uart_port *port;
642: unsigned long flags;
643: unsigned int ret;
644:
645: port = uart_port_ref_lock(state, &flags);
646: ret = kfifo_avail(&state->port.xmit_fifo);
647: uart_port_unlock_deref(port, flags);
648: return ret;
649: }
SourceFile:drivers/tty/serial/serial_core.c]
|
| 22/2 |
2026/05/25 13:29 |
llm |
expert |
0m
Model:
Tokens:
input: 16576
output: 52
thoughts: 103
Thoughts: **Analyzing a Potential Buffer Allocation Issue**
Okay, so I'm looking at this code and I see a check: `!state->port.xmit_buf`. My initial thought is, "If `xmit_buf` isn't allocated, what is `kfifo_avail(&state->port.xmit_fifo)` going to tell me?" I need to understand that relationship. My gut feeling is that if the buffer isn't allocated, `kfifo_avail` might return something unexpected. It could be zero, which is likely, but perhaps the FIFO structure itself is initialized with a size, even if no backing buffer is present? Or maybe it returns a value that doesn't mean anything. This is important to pin down.
Wait a second, that `xmit_fifo` is a `kfifo` structure. Right. Okay, let's back up and check how that `xmit_fifo` is initialized. That's the key here, figuring out how the FIFO is set up *before* we get to this null buffer check. I need to understand the initial state of the `kfifo`.
|
| 23/2 |
2026/05/25 13:29 |
tool |
codesearch-find-references |
0m
Error:
Args: map[ContextFile:drivers/tty/serial/serial_core.c IncludeSnippetLines:0 Name:xmit_fifo SourceTreePrefix:]
Results: map[References:<nil> TruncatedOutput:false]
|
| 24/2 |
2026/05/25 13:29 |
llm |
expert |
0m
Model:
Tokens:
input: 16990
output: 18
thoughts: 26
Thoughts: Here's my thought process, summarized as you requested:
**Debugging a Transmit FIFO Issue**
Okay, so I'm looking at this code, and it seems like there's something off with the transmit FIFO. I remember seeing a reference to `state->port.xmit_fifo` earlier. Now, I need to confirm if that's the culprit. Let me quickly do a search within this codebase for the string `xmit_fifo`. Hopefully, this will lead me to the relevant definitions and usages of this variable. That should help me understand how this FIFO is being handled and where the problem might lie.
|
| 25/2 |
2026/05/25 13:29 |
tool |
grepper |
0m
Args: map[Expression:xmit_fifo]
Results: map[Output:
Full output is too long, showing 500 out of 1390 lines.
Use more precise expression if possible.
[Documentation/ABI/testing/sysfs-tty=71=Description:
--
Documentation/ABI/testing/sysfs-tty-76-
Documentation/ABI/testing/sysfs-tty:77:What: /sys/class/tty/ttyS<x>/xmit_fifo_size
Documentation/ABI/testing/sysfs-tty-78-Date: October 2012
--
drivers/mmc/core/sdio_uart.c=64=struct sdio_uart_port {
--
drivers/mmc/core/sdio_uart.c-70- unsigned int regs_offset;
drivers/mmc/core/sdio_uart.c:71: struct kfifo xmit_fifo;
drivers/mmc/core/sdio_uart.c-72- spinlock_t write_lock;
--
drivers/mmc/core/sdio_uart.c=87=static int sdio_uart_add_port(struct sdio_uart_port *port)
--
drivers/mmc/core/sdio_uart.c-92- spin_lock_init(&port->write_lock);
drivers/mmc/core/sdio_uart.c:93: if (kfifo_alloc(&port->xmit_fifo, FIFO_SIZE, GFP_KERNEL))
drivers/mmc/core/sdio_uart.c-94- return -ENOMEM;
--
drivers/mmc/core/sdio_uart.c=407=static void sdio_uart_transmit_chars(struct sdio_uart_port *port)
drivers/mmc/core/sdio_uart.c-408-{
drivers/mmc/core/sdio_uart.c:409: struct kfifo *xmit = &port->xmit_fifo;
drivers/mmc/core/sdio_uart.c-410- int count;
--
drivers/mmc/core/sdio_uart.c=576=static int sdio_uart_activate(struct tty_port *tport, struct tty_struct *tty)
--
drivers/mmc/core/sdio_uart.c-587-
drivers/mmc/core/sdio_uart.c:588: kfifo_reset(&port->xmit_fifo);
drivers/mmc/core/sdio_uart.c-589-
--
drivers/mmc/core/sdio_uart.c=691=static void sdio_uart_port_destroy(struct tty_port *tport)
--
drivers/mmc/core/sdio_uart.c-694- container_of(tport, struct sdio_uart_port, port);
drivers/mmc/core/sdio_uart.c:695: kfifo_free(&port->xmit_fifo);
drivers/mmc/core/sdio_uart.c-696- kfree(port);
--
drivers/mmc/core/sdio_uart.c=759=static ssize_t sdio_uart_write(struct tty_struct *tty, const u8 *buf,
--
drivers/mmc/core/sdio_uart.c-767-
drivers/mmc/core/sdio_uart.c:768: ret = kfifo_in_locked(&port->xmit_fifo, buf, count, &port->write_lock);
drivers/mmc/core/sdio_uart.c-769- if (!(port->ier & UART_IER_THRI)) {
--
drivers/mmc/core/sdio_uart.c=782=static unsigned int sdio_uart_write_room(struct tty_struct *tty)
--
drivers/mmc/core/sdio_uart.c-784- struct sdio_uart_port *port = tty->driver_data;
drivers/mmc/core/sdio_uart.c:785: return FIFO_SIZE - kfifo_len(&port->xmit_fifo);
drivers/mmc/core/sdio_uart.c-786-}
--
drivers/mmc/core/sdio_uart.c=788=static unsigned int sdio_uart_chars_in_buffer(struct tty_struct *tty)
--
drivers/mmc/core/sdio_uart.c-790- struct sdio_uart_port *port = tty->driver_data;
drivers/mmc/core/sdio_uart.c:791: return kfifo_len(&port->xmit_fifo);
drivers/mmc/core/sdio_uart.c-792-}
--
drivers/net/can/xilinx_can.c=651=static void xcan_write_frame(struct net_device *ndev, struct sk_buff *skb,
--
drivers/net/can/xilinx_can.c-735-/**
drivers/net/can/xilinx_can.c:736: * xcan_start_xmit_fifo - Starts the transmission (FIFO mode)
drivers/net/can/xilinx_can.c-737- * @skb: sk_buff pointer that contains data to be Txed
--
drivers/net/can/xilinx_can.c-741- */
drivers/net/can/xilinx_can.c:742:static int xcan_start_xmit_fifo(struct sk_buff *skb, struct net_device *ndev)
drivers/net/can/xilinx_can.c-743-{
--
drivers/net/can/xilinx_can.c=809=static netdev_tx_t xcan_start_xmit(struct sk_buff *skb, struct net_device *ndev)
--
drivers/net/can/xilinx_can.c-819- else
drivers/net/can/xilinx_can.c:820: ret = xcan_start_xmit_fifo(skb, ndev);
drivers/net/can/xilinx_can.c-821-
--
drivers/net/ethernet/dlink/dl2k.h=282=typedef union t_MII_PHY_SCR {
--
drivers/net/ethernet/dlink/dl2k.h-295- u16 rcv_fifo_depth:2; // bit 13:12
drivers/net/ethernet/dlink/dl2k.h:296: u16 xmit_fifo_depth:2; // bit 15:14
drivers/net/ethernet/dlink/dl2k.h-297- } bits;
--
drivers/tty/amiserial.c=892=static int get_serial_info(struct tty_struct *tty, struct serial_struct *ss)
--
drivers/tty/amiserial.c-905- ss->flags = state->tport.flags;
drivers/tty/amiserial.c:906: ss->xmit_fifo_size = XMIT_FIFO_SIZE;
drivers/tty/amiserial.c-907- ss->baud_base = state->baud_base;
--
drivers/tty/amiserial.c=915=static int set_serial_info(struct tty_struct *tty, struct serial_struct *ss)
--
drivers/tty/amiserial.c-926- if (ss->irq || ss->port != state->port ||
drivers/tty/amiserial.c:927: ss->xmit_fifo_size != XMIT_FIFO_SIZE) {
drivers/tty/amiserial.c-928- tty_unlock(tty);
--
drivers/tty/mxser.c=253=struct mxser_port {
--
drivers/tty/mxser.c-273- u8 ignore_status_mask;
drivers/tty/mxser.c:274: u8 xmit_fifo_size;
drivers/tty/mxser.c-275-
--
drivers/tty/mxser.c=416=static void mxser_process_txrx_fifo(struct mxser_port *info)
--
drivers/tty/mxser.c-422- info->rx_low_water = 1;
drivers/tty/mxser.c:423: info->xmit_fifo_size = 1;
drivers/tty/mxser.c-424- return;
--
drivers/tty/mxser.c-430- info->rx_high_water = Gpci_uart_info[i].rx_high_water;
drivers/tty/mxser.c:431: info->xmit_fifo_size = Gpci_uart_info[i].fifo_size;
drivers/tty/mxser.c-432- break;
--
drivers/tty/mxser.c=476=static int mxser_set_baud(struct tty_struct *tty, speed_t newspd)
--
drivers/tty/mxser.c-502- */
drivers/tty/mxser.c:503: timeout = (u64)info->xmit_fifo_size * HZ * 10 * quot;
drivers/tty/mxser.c-504- do_div(timeout, MXSER_BAUD_BASE);
--
drivers/tty/mxser.c=718=static int mxser_activate(struct tty_port *port, struct tty_struct *tty)
--
drivers/tty/mxser.c-791- clear_bit(TTY_IO_ERROR, &tty->flags);
drivers/tty/mxser.c:792: kfifo_reset(&port->xmit_fifo);
drivers/tty/mxser.c-793-
--
drivers/tty/mxser.c=871=static void mxser_flush_buffer(struct tty_struct *tty)
--
drivers/tty/mxser.c-875- scoped_guard(spinlock_irqsave, &info->slock) {
drivers/tty/mxser.c:876: kfifo_reset(&info->port.xmit_fifo);
drivers/tty/mxser.c-877-
--
drivers/tty/mxser.c=890=static ssize_t mxser_write(struct tty_struct *tty, const u8 *buf, size_t count)
--
drivers/tty/mxser.c-896- scoped_guard(spinlock_irqsave, &info->slock) {
drivers/tty/mxser.c:897: written = kfifo_in(&info->port.xmit_fifo, buf, count);
drivers/tty/mxser.c:898: is_empty = kfifo_is_empty(&info->port.xmit_fifo);
drivers/tty/mxser.c-899- }
--
drivers/tty/mxser.c=908=static int mxser_put_char(struct tty_struct *tty, u8 ch)
--
drivers/tty/mxser.c-912- guard(spinlock_irqsave)(&info->slock);
drivers/tty/mxser.c:913: return kfifo_put(&info->port.xmit_fifo, ch);
drivers/tty/mxser.c-914-}
--
drivers/tty/mxser.c=917=static void mxser_flush_chars(struct tty_struct *tty)
--
drivers/tty/mxser.c-920-
drivers/tty/mxser.c:921: if (kfifo_is_empty(&info->port.xmit_fifo) || tty->flow.stopped ||
drivers/tty/mxser.c-922- (tty->hw_stopped && !mxser_16550A_or_MUST(info)))
--
drivers/tty/mxser.c=928=static unsigned int mxser_write_room(struct tty_struct *tty)
--
drivers/tty/mxser.c-931-
drivers/tty/mxser.c:932: return kfifo_avail(&info->port.xmit_fifo);
drivers/tty/mxser.c-933-}
--
drivers/tty/mxser.c=935=static unsigned int mxser_chars_in_buffer(struct tty_struct *tty)
--
drivers/tty/mxser.c-938-
drivers/tty/mxser.c:939: return kfifo_len(&info->port.xmit_fifo);
drivers/tty/mxser.c-940-}
--
drivers/tty/mxser.c=1304=static void mxser_start(struct tty_struct *tty)
--
drivers/tty/mxser.c-1308- guard(spinlock_irqsave)(&info->slock);
drivers/tty/mxser.c:1309: if (!kfifo_is_empty(&info->port.xmit_fifo))
drivers/tty/mxser.c-1310- __mxser_start_tx(info);
--
drivers/tty/mxser.c=1348=static void mxser_wait_until_sent(struct tty_struct *tty, int timeout)
--
drivers/tty/mxser.c-1355-
drivers/tty/mxser.c:1356: if (info->xmit_fifo_size == 0)
drivers/tty/mxser.c-1357- return; /* Just in case.... */
--
drivers/tty/mxser.c-1366- */
drivers/tty/mxser.c:1367: char_time = (info->timeout - HZ / 50) / info->xmit_fifo_size;
drivers/tty/mxser.c-1368- char_time = char_time / 5;
--
drivers/tty/mxser.c=1518=static void mxser_transmit_chars(struct tty_struct *tty, struct mxser_port *port)
--
drivers/tty/mxser.c-1528-
drivers/tty/mxser.c:1529: if (kfifo_is_empty(&port->port.xmit_fifo) || tty->flow.stopped ||
drivers/tty/mxser.c-1530- (tty->hw_stopped && !mxser_16550A_or_MUST(port))) {
--
drivers/tty/mxser.c-1534-
drivers/tty/mxser.c:1535: count = port->xmit_fifo_size;
drivers/tty/mxser.c-1536- do {
--
drivers/tty/mxser.c-1538-
drivers/tty/mxser.c:1539: if (!kfifo_get(&port->port.xmit_fifo, &c))
drivers/tty/mxser.c-1540- break;
--
drivers/tty/mxser.c-1545-
drivers/tty/mxser.c:1546: if (kfifo_len(&port->port.xmit_fifo) < WAKEUP_CHARS)
drivers/tty/mxser.c-1547- tty_wakeup(tty);
drivers/tty/mxser.c-1548-
drivers/tty/mxser.c:1549: if (kfifo_is_empty(&port->port.xmit_fifo))
drivers/tty/mxser.c-1550- __mxser_stop_tx(port);
--
drivers/tty/serial/8250/8250_bcm7271.c=413=static int brcmuart_tx_dma(struct uart_8250_port *p)
--
drivers/tty/serial/8250/8250_bcm7271.c-419- if (uart_tx_stopped(&p->port) || priv->tx_running ||
drivers/tty/serial/8250/8250_bcm7271.c:420: kfifo_is_empty(&tport->xmit_fifo)) {
drivers/tty/serial/8250/8250_bcm7271.c-421- return 0;
--
drivers/tty/serial/8250/8250_bcm7271.c-426-
drivers/tty/serial/8250/8250_bcm7271.c:427: if (kfifo_len(&tport->xmit_fifo) < WAKEUP_CHARS)
drivers/tty/serial/8250/8250_bcm7271.c-428- uart_write_wakeup(&p->port);
--
drivers/tty/serial/8250/8250_bcm7271.c=536=static void brcmuart_tx_isr(struct uart_port *up, u32 isr)
--
drivers/tty/serial/8250/8250_bcm7271.c-548- priv->tx_running = false;
drivers/tty/serial/8250/8250_bcm7271.c:549: if (!kfifo_is_empty(&tport->xmit_fifo) && !uart_tx_stopped(up))
drivers/tty/serial/8250/8250_bcm7271.c-550- brcmuart_tx_dma(port_8250);
--
drivers/tty/serial/8250/8250_core.c=217=static void serial8250_backup_timeout(struct timer_list *t)
--
drivers/tty/serial/8250/8250_core.c-243- if ((iir & UART_IIR_NO_INT) && (up->ier & UART_IER_THRI) &&
drivers/tty/serial/8250/8250_core.c:244: (!kfifo_is_empty(&up->port.state->port.xmit_fifo) ||
drivers/tty/serial/8250/8250_core.c-245- up->port.x_char) &&
--
drivers/tty/serial/8250/8250_dma.c=14=static void __dma_tx_complete(void *param)
--
drivers/tty/serial/8250/8250_dma.c-30-
drivers/tty/serial/8250/8250_dma.c:31: if (kfifo_len(&tport->xmit_fifo) < WAKEUP_CHARS)
drivers/tty/serial/8250/8250_dma.c-32- uart_write_wakeup(&p->port);
--
drivers/tty/serial/8250/8250_dma.c=86=int serial8250_tx_dma(struct uart_8250_port *p)
--
drivers/tty/serial/8250/8250_dma.c-107-
drivers/tty/serial/8250/8250_dma.c:108: if (uart_tx_stopped(&p->port) || kfifo_is_empty(&tport->xmit_fifo)) {
drivers/tty/serial/8250/8250_dma.c-109- /* We have been called from __dma_tx_complete() */
--
drivers/tty/serial/8250/8250_dma.c-116-
drivers/tty/serial/8250/8250_dma.c:117: ret = kfifo_dma_out_prepare_mapped(&tport->xmit_fifo, sgl, ARRAY_SIZE(sgl),
drivers/tty/serial/8250/8250_dma.c-118- UART_XMIT_SIZE, dma->tx_addr);
--
drivers/tty/serial/8250/8250_exar.c=479=static void exar_shutdown(struct uart_port *port)
--
drivers/tty/serial/8250/8250_exar.c-493- usleep_range(1000, 1100);
drivers/tty/serial/8250/8250_exar.c:494: } while (!kfifo_is_empty(&tport->xmit_fifo) &&
drivers/tty/serial/8250/8250_exar.c-495- !tx_complete && i++ < 1000);
--
drivers/tty/serial/8250/8250_mtk.c=190=static int mtk8250_startup(struct uart_port *port)
--
drivers/tty/serial/8250/8250_mtk.c-201- data->rx_status = DMA_RX_START;
drivers/tty/serial/8250/8250_mtk.c:202: kfifo_reset(&port->state->port.xmit_fifo);
drivers/tty/serial/8250/8250_mtk.c-203- }
--
drivers/tty/serial/8250/8250_omap.c=1077=static void omap_8250_dma_tx_complete(void *param)
--
drivers/tty/serial/8250/8250_omap.c-1098-
drivers/tty/serial/8250/8250_omap.c:1099: if (kfifo_len(&tport->xmit_fifo) < WAKEUP_CHARS)
drivers/tty/serial/8250/8250_omap.c-1100- uart_write_wakeup(&p->port);
drivers/tty/serial/8250/8250_omap.c-1101-
drivers/tty/serial/8250/8250_omap.c:1102: if (!kfifo_is_empty(&tport->xmit_fifo) && !uart_tx_stopped(&p->port)) {
drivers/tty/serial/8250/8250_omap.c-1103- int ret;
--
drivers/tty/serial/8250/8250_omap.c=1118=static int omap_8250_tx_dma(struct uart_8250_port *p)
--
drivers/tty/serial/8250/8250_omap.c-1129- return 0;
drivers/tty/serial/8250/8250_omap.c:1130: if (uart_tx_stopped(&p->port) || kfifo_is_empty(&tport->xmit_fifo)) {
drivers/tty/serial/8250/8250_omap.c-1131-
--
drivers/tty/serial/8250/8250_omap.c-1168- }
drivers/tty/serial/8250/8250_omap.c:1169: if (kfifo_len(&tport->xmit_fifo) < 4) {
drivers/tty/serial/8250/8250_omap.c-1170- ret = -EINVAL;
--
drivers/tty/serial/8250/8250_omap.c-1180- sg_init_table(&sg, 1);
drivers/tty/serial/8250/8250_omap.c:1181: ret = kfifo_dma_out_prepare_mapped(&tport->xmit_fifo, &sg, 1, UART_XMIT_SIZE, dma->tx_addr);
drivers/tty/serial/8250/8250_omap.c-1182- if (ret != 1) {
--
drivers/tty/serial/8250/8250_omap.c=1296=static int omap_8250_dma_handle_irq(struct uart_port *port)
--
drivers/tty/serial/8250/8250_omap.c-1321- if (uart_tx_stopped(port) ||
drivers/tty/serial/8250/8250_omap.c:1322: kfifo_is_empty(&port->state->port.xmit_fifo)) {
drivers/tty/serial/8250/8250_omap.c-1323- up->dma->tx_err = 0;
--
drivers/tty/serial/8250/8250_pci1xxxx.c=438=static void pci1xxxx_process_write_data(struct uart_port *port,
--
drivers/tty/serial/8250/8250_pci1xxxx.c-455- break;
drivers/tty/serial/8250/8250_pci1xxxx.c:456: if (kfifo_len(&tport->xmit_fifo) < UART_BURST_SIZE)
drivers/tty/serial/8250/8250_pci1xxxx.c-457- break;
drivers/tty/serial/8250/8250_pci1xxxx.c:458: if (WARN_ON(kfifo_out(&tport->xmit_fifo, (u8 *)&c, sizeof(c)) !=
drivers/tty/serial/8250/8250_pci1xxxx.c-459- sizeof(c)))
--
drivers/tty/serial/8250/8250_pci1xxxx.c-469-
drivers/tty/serial/8250/8250_pci1xxxx.c:470: if (!kfifo_get(&tport->xmit_fifo, &c))
drivers/tty/serial/8250/8250_pci1xxxx.c-471- break;
--
drivers/tty/serial/8250/8250_pci1xxxx.c-480- if (valid_burst_count &&
drivers/tty/serial/8250/8250_pci1xxxx.c:481: kfifo_len(&tport->xmit_fifo) >= UART_BURST_SIZE)
drivers/tty/serial/8250/8250_pci1xxxx.c-482- break;
--
drivers/tty/serial/8250/8250_pci1xxxx.c=486=static void pci1xxxx_tx_burst(struct uart_port *port, u32 uart_status)
--
drivers/tty/serial/8250/8250_pci1xxxx.c-499-
drivers/tty/serial/8250/8250_pci1xxxx.c:500: if ((uart_tx_stopped(port)) || kfifo_is_empty(&tport->xmit_fifo)) {
drivers/tty/serial/8250/8250_pci1xxxx.c-501- port->ops->stop_tx(port);
--
drivers/tty/serial/8250/8250_pci1xxxx.c-505- do {
drivers/tty/serial/8250/8250_pci1xxxx.c:506: valid_byte_count = kfifo_len(&tport->xmit_fifo);
drivers/tty/serial/8250/8250_pci1xxxx.c-507-
--
drivers/tty/serial/8250/8250_pci1xxxx.c-512- port->icount.tx++;
drivers/tty/serial/8250/8250_pci1xxxx.c:513: if (kfifo_is_empty(&tport->xmit_fifo))
drivers/tty/serial/8250/8250_pci1xxxx.c-514- break;
--
drivers/tty/serial/8250/8250_pci1xxxx.c-517-
drivers/tty/serial/8250/8250_pci1xxxx.c:518: if (kfifo_len(&tport->xmit_fifo) < WAKEUP_CHARS)
drivers/tty/serial/8250/8250_pci1xxxx.c-519- uart_write_wakeup(port);
--
drivers/tty/serial/8250/8250_pci1xxxx.c-525- */
drivers/tty/serial/8250/8250_pci1xxxx.c:526: if (kfifo_is_empty(&tport->xmit_fifo) &&
drivers/tty/serial/8250/8250_pci1xxxx.c-527- !(up->capabilities & UART_CAP_RPM))
--
drivers/tty/serial/8250/8250_port.c=1517=static void serial8250_start_tx(struct uart_port *port)
--
drivers/tty/serial/8250/8250_port.c-1524-
drivers/tty/serial/8250/8250_port.c:1525: if (!port->x_char && kfifo_is_empty(&port->state->port.xmit_fifo))
drivers/tty/serial/8250/8250_port.c-1526- return;
--
drivers/tty/serial/8250/8250_port.c=1669=void serial8250_tx_chars(struct uart_8250_port *up)
--
drivers/tty/serial/8250/8250_port.c-1682- }
drivers/tty/serial/8250/8250_port.c:1683: if (kfifo_is_empty(&tport->xmit_fifo)) {
drivers/tty/serial/8250/8250_port.c-1684- __stop_tx(up);
--
drivers/tty/serial/8250/8250_port.c-1717-
drivers/tty/serial/8250/8250_port.c:1718: if (kfifo_len(&tport->xmit_fifo) < WAKEUP_CHARS)
drivers/tty/serial/8250/8250_port.c-1719- uart_write_wakeup(port);
--
drivers/tty/serial/8250/8250_port.c-1725- */
drivers/tty/serial/8250/8250_port.c:1726: if (kfifo_is_empty(&tport->xmit_fifo) &&
drivers/tty/serial/8250/8250_port.c-1727- !(up->capabilities & UART_CAP_RPM))
--
drivers/tty/serial/amba-pl011.c=545=static void pl011_dma_tx_callback(void *data)
--
drivers/tty/serial/amba-pl011.c-571- if (!(dmacr & UART011_TXDMAE) || uart_tx_stopped(&uap->port) ||
drivers/tty/serial/amba-pl011.c:572: kfifo_is_empty(&tport->xmit_fifo)) {
drivers/tty/serial/amba-pl011.c-573- uap->dmatx.queued = false;
--
drivers/tty/serial/amba-pl011.c=596=static int pl011_dma_tx_refill(struct uart_amba_port *uap)
--
drivers/tty/serial/amba-pl011.c-610- */
drivers/tty/serial/amba-pl011.c:611: count = kfifo_len(&tport->xmit_fifo);
drivers/tty/serial/amba-pl011.c-612- if (count < (uap->fifosize >> 1)) {
--
drivers/tty/serial/amba-pl011.c-626-
drivers/tty/serial/amba-pl011.c:627: count = kfifo_out_peek(&tport->xmit_fifo, dmatx->buf, count);
drivers/tty/serial/amba-pl011.c-628- dmatx->len = count;
--
drivers/tty/serial/amba-pl011.c-669-
drivers/tty/serial/amba-pl011.c:670: if (kfifo_len(&tport->xmit_fifo) < WAKEUP_CHARS)
drivers/tty/serial/amba-pl011.c-671- uart_write_wakeup(&uap->port);
--
drivers/tty/serial/amba-pl011.c=1504=static bool pl011_tx_chars(struct uart_amba_port *uap, bool from_irq)
--
drivers/tty/serial/amba-pl011.c-1514- }
drivers/tty/serial/amba-pl011.c:1515: if (kfifo_is_empty(&tport->xmit_fifo) || uart_tx_stopped(&uap->port)) {
drivers/tty/serial/amba-pl011.c-1516- pl011_stop_tx(&uap->port);
--
drivers/tty/serial/amba-pl011.c-1529-
drivers/tty/serial/amba-pl011.c:1530: if (!kfifo_peek(&tport->xmit_fifo, &c))
drivers/tty/serial/amba-pl011.c-1531- break;
--
drivers/tty/serial/amba-pl011.c-1535-
drivers/tty/serial/amba-pl011.c:1536: kfifo_skip(&tport->xmit_fifo);
drivers/tty/serial/amba-pl011.c-1537- }
drivers/tty/serial/amba-pl011.c-1538-
drivers/tty/serial/amba-pl011.c:1539: if (kfifo_len(&tport->xmit_fifo) < WAKEUP_CHARS)
drivers/tty/serial/amba-pl011.c-1540- uart_write_wakeup(&uap->port);
drivers/tty/serial/amba-pl011.c-1541-
drivers/tty/serial/amba-pl011.c:1542: if (kfifo_is_empty(&tport->xmit_fifo)) {
drivers/tty/serial/amba-pl011.c-1543- pl011_stop_tx(&uap->port);
--
drivers/tty/serial/ar933x_uart.c=391=static void ar933x_uart_tx_chars(struct ar933x_uart_port *up)
--
drivers/tty/serial/ar933x_uart.c-401- if ((rs485conf->flags & SER_RS485_ENABLED) &&
drivers/tty/serial/ar933x_uart.c:402: (up->port.x_char || !kfifo_is_empty(&tport->xmit_fifo))) {
drivers/tty/serial/ar933x_uart.c-403- ar933x_uart_stop_rx_interrupt(up);
--
drivers/tty/serial/ar933x_uart.c-429-
drivers/tty/serial/ar933x_uart.c:430: if (kfifo_len(&tport->xmit_fifo) < WAKEUP_CHARS)
drivers/tty/serial/ar933x_uart.c-431- uart_write_wakeup(&up->port);
drivers/tty/serial/ar933x_uart.c-432-
drivers/tty/serial/ar933x_uart.c:433: if (!kfifo_is_empty(&tport->xmit_fifo)) {
drivers/tty/serial/ar933x_uart.c-434- ar933x_uart_start_tx_interrupt(up);
--
drivers/tty/serial/arc_uart.c=156=static void arc_serial_tx_chars(struct uart_port *port)
--
drivers/tty/serial/arc_uart.c-177- */
drivers/tty/serial/arc_uart.c:178: if (kfifo_len(&tport->xmit_fifo) < WAKEUP_CHARS)
drivers/tty/serial/arc_uart.c-179- uart_write_wakeup(port);
--
drivers/tty/serial/atmel_serial.c=858=static void atmel_complete_tx_dma(void *arg)
--
drivers/tty/serial/atmel_serial.c-877-
drivers/tty/serial/atmel_serial.c:878: if (kfifo_len(&tport->xmit_fifo) < WAKEUP_CHARS)
drivers/tty/serial/atmel_serial.c-879- uart_write_wakeup(port);
--
drivers/tty/serial/atmel_serial.c-885- */
drivers/tty/serial/atmel_serial.c:886: if (!kfifo_is_empty(&tport->xmit_fifo))
drivers/tty/serial/atmel_serial.c-887- atmel_tasklet_schedule(atmel_port, &atmel_port->tasklet_tx);
--
drivers/tty/serial/atmel_serial.c=921=static void atmel_tx_dma(struct uart_port *port)
--
drivers/tty/serial/atmel_serial.c-934-
drivers/tty/serial/atmel_serial.c:935: if (!kfifo_is_empty(&tport->xmit_fifo) && !uart_tx_stopped(port)) {
drivers/tty/serial/atmel_serial.c-936- /*
--
drivers/tty/serial/atmel_serial.c-944- */
drivers/tty/serial/atmel_serial.c:945: tx_len = kfifo_out_linear(&tport->xmit_fifo, &tail,
drivers/tty/serial/atmel_serial.c-946- UART_XMIT_SIZE);
--
drivers/tty/serial/atmel_serial.c-1007-
drivers/tty/serial/atmel_serial.c:1008: if (kfifo_len(&tport->xmit_fifo) < WAKEUP_CHARS)
drivers/tty/serial/atmel_serial.c-1009- uart_write_wakeup(port);
--
drivers/tty/serial/atmel_serial.c=1442=static void atmel_tx_pdc(struct uart_port *port)
--
drivers/tty/serial/atmel_serial.c-1458-
drivers/tty/serial/atmel_serial.c:1459: if (!kfifo_is_empty(&tport->xmit_fifo) && !uart_tx_stopped(port)) {
drivers/tty/serial/atmel_serial.c-1460- unsigned int count, tail;
--
drivers/tty/serial/atmel_serial.c-1466-
drivers/tty/serial/atmel_serial.c:1467: count = kfifo_out_linear(&tport->xmit_fifo, &tail,
drivers/tty/serial/atmel_serial.c-1468- UART_XMIT_SIZE);
--
drivers/tty/serial/atmel_serial.c-1484-
drivers/tty/serial/atmel_serial.c:1485: if (kfifo_len(&tport->xmit_fifo) < WAKEUP_CHARS)
drivers/tty/serial/atmel_serial.c-1486- uart_write_wakeup(port);
--
drivers/tty/serial/clps711x.c=145=static irqreturn_t uart_clps711x_int_tx(int irq, void *dev_id)
--
drivers/tty/serial/clps711x.c-158-
drivers/tty/serial/clps711x.c:159: if (kfifo_is_empty(&tport->xmit_fifo) || uart_tx_stopped(port)) {
drivers/tty/serial/clps711x.c-160- if (s->tx_enabled) {
--
drivers/tty/serial/clps711x.c-176-
drivers/tty/serial/clps711x.c:177: if (kfifo_len(&tport->xmit_fifo) < WAKEUP_CHARS)
drivers/tty/serial/clps711x.c-178- uart_write_wakeup(port);
--
drivers/tty/serial/cpm_uart.c=644=static int cpm_uart_tx_pump(struct uart_port *port)
--
drivers/tty/serial/cpm_uart.c-675-
drivers/tty/serial/cpm_uart.c:676: if (kfifo_is_empty(&tport->xmit_fifo) || uart_tx_stopped(port)) {
drivers/tty/serial/cpm_uart.c-677- cpm_uart_stop_tx(port);
--
drivers/tty/serial/cpm_uart.c-684- while (!(in_be16(&bdp->cbd_sc) & BD_SC_READY) &&
drivers/tty/serial/cpm_uart.c:685: !kfifo_is_empty(&tport->xmit_fifo)) {
drivers/tty/serial/cpm_uart.c-686- p = cpm2cpu_addr(in_be32(&bdp->cbd_bufaddr), pinfo);
--
drivers/tty/serial/cpm_uart.c-697-
drivers/tty/serial/cpm_uart.c:698: if (kfifo_len(&tport->xmit_fifo) < WAKEUP_CHARS)
drivers/tty/serial/cpm_uart.c-699- uart_write_wakeup(port);
drivers/tty/serial/cpm_uart.c-700-
drivers/tty/serial/cpm_uart.c:701: if (kfifo_is_empty(&tport->xmit_fifo)) {
drivers/tty/serial/cpm_uart.c-702- cpm_uart_stop_tx(port);
--
drivers/tty/serial/digicolor-usart.c=180=static void digicolor_uart_tx(struct uart_port *port)
--
drivers/tty/serial/digicolor-usart.c-197-
drivers/tty/serial/digicolor-usart.c:198: if (kfifo_is_empty(&tport->xmit_fifo) || uart_tx_stopped(port)) {
drivers/tty/serial/digicolor-usart.c-199- digicolor_uart_stop_tx(port);
--
drivers/tty/serial/digicolor-usart.c-209-
drivers/tty/serial/digicolor-usart.c:210: if (kfifo_len(&tport->xmit_fifo) < WAKEUP_CHARS)
drivers/tty/serial/digicolor-usart.c-211- uart_write_wakeup(port);
--
drivers/tty/serial/dz.c=252=static inline void dz_transmit_chars(struct dz_mux *mux)
--
drivers/tty/serial/dz.c-283-
drivers/tty/serial/dz.c:284: if (kfifo_len(&tport->xmit_fifo) < DZ_WAKEUP_CHARS)
drivers/tty/serial/dz.c-285- uart_write_wakeup(&dport->port);
--
drivers/tty/serial/dz.c-287- /* Are we are done. */
drivers/tty/serial/dz.c:288: if (kfifo_is_empty(&tport->xmit_fifo)) {
drivers/tty/serial/dz.c-289- uart_port_lock(&dport->port);
--
drivers/tty/serial/fsl_linflexuart.c=175=static inline void linflex_transmit_buffer(struct uart_port *sport)
--
drivers/tty/serial/fsl_linflexuart.c-184-
drivers/tty/serial/fsl_linflexuart.c:185: if (kfifo_len(&tport->xmit_fifo) < WAKEUP_CHARS)
drivers/tty/serial/fsl_linflexuart.c-186- uart_write_wakeup(sport);
drivers/tty/serial/fsl_linflexuart.c-187-
drivers/tty/serial/fsl_linflexuart.c:188: if (kfifo_is_empty(&tport->xmit_fifo))
drivers/tty/serial/fsl_linflexuart.c-189- linflex_stop_tx(sport);
--
drivers/tty/serial/fsl_linflexuart.c=201=static irqreturn_t linflex_txint(int irq, void *dev_id)
--
drivers/tty/serial/fsl_linflexuart.c-213-
drivers/tty/serial/fsl_linflexuart.c:214: if (kfifo_is_empty(&tport->xmit_fifo) || uart_tx_stopped(sport)) {
drivers/tty/serial/fsl_linflexuart.c-215- linflex_stop_tx(sport);
--
drivers/tty/serial/fsl_lpuart.c=478=static void lpuart_dma_tx(struct lpuart_port *sport)
--
drivers/tty/serial/fsl_lpuart.c-489- sg_init_table(sgl, ARRAY_SIZE(sport->tx_sgl));
drivers/tty/serial/fsl_lpuart.c:490: sport->dma_tx_bytes = kfifo_len(&tport->xmit_fifo);
drivers/tty/serial/fsl_lpuart.c:491: sport->dma_tx_nents = kfifo_dma_out_prepare(&tport->xmit_fifo, sgl,
drivers/tty/serial/fsl_lpuart.c-492- ARRAY_SIZE(sport->tx_sgl), sport->dma_tx_bytes);
--
drivers/tty/serial/fsl_lpuart.c=518=static bool lpuart_stopped_or_empty(struct uart_port *port)
drivers/tty/serial/fsl_lpuart.c-519-{
drivers/tty/serial/fsl_lpuart.c:520: return kfifo_is_empty(&port->state->port.xmit_fifo) ||
drivers/tty/serial/fsl_lpuart.c-521- uart_tx_stopped(port);
--
drivers/tty/serial/fsl_lpuart.c=524=static void lpuart_dma_tx_complete(void *arg)
--
drivers/tty/serial/fsl_lpuart.c-544-
]
]
|
| 26/2 |
2026/05/25 13:29 |
llm |
expert |
0m
Model:
Tokens:
input: 29416
output: 39
thoughts: 51
Thoughts: Okay, here's my interpretation of those thoughts, tailored for an expert audience:
**Digging into the Serial Driver's Data Structures**
Right, so I'm looking at the serial driver code, and my first thought is, "Aha! That `xmit_fifo` – that's a `kfifo` structure, and it looks like it's tucked away inside the `tty_port` structure." I know the driver pretty well, so this is immediately familiar.
Then I double-check, because I like to be precise. "Wait, let me just confirm. `state->port` – yes, that's definitely a pointer to a `struct tty_port`. Excellent."
Time to quickly confirm my mental model. I'll mentally review (or, if I'm being thorough, I might glance at the header) the definition of `tty_port` itself. Just to make sure I'm not missing anything critical about how that `kfifo` is being used, or other relevant fields that might be lurking in there and affect the transmission flow. Gotta keep all the pieces in view.
|
| 27/2 |
2026/05/25 13:29 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:include/linux/tty.h IncludeLines:true Name:tty_port]
Results: map[SourceCode: 51: /**
52: * struct tty_port -- port level information
53: *
54: * @buf: buffer for this port, locked internally
55: * @tty: back pointer to &struct tty_struct, valid only if the tty is open. Use
56: * tty_port_tty_get() to obtain it (and tty_kref_put() to release).
57: * @itty: internal back pointer to &struct tty_struct. Avoid this. It should be
58: * eliminated in the long term.
59: * @ops: tty port operations (like activate, shutdown), see &struct
60: * tty_port_operations
61: * @client_ops: tty port client operations (like receive_buf, write_wakeup).
62: * By default, tty_port_default_client_ops is used.
63: * @lock: lock protecting @tty
64: * @blocked_open: # of procs waiting for open in tty_port_block_til_ready()
65: * @count: usage count
66: * @open_wait: open waiters queue (waiting e.g. for a carrier)
67: * @delta_msr_wait: modem status change queue (waiting for MSR changes)
68: * @flags: user TTY flags (%ASYNC_)
69: * @iflags: internal flags (%TTY_PORT_)
70: * @console: when set, the port is a console
71: * @mutex: locking, for open, shutdown and other port operations
72: * @buf_mutex: @xmit_buf alloc lock
73: * @xmit_buf: optional xmit buffer used by some drivers
74: * @xmit_fifo: optional xmit buffer used by some drivers
75: * @close_delay: delay in jiffies to wait when closing the port
76: * @closing_wait: delay in jiffies for output to be sent before closing
77: * @drain_delay: set to zero if no pure time based drain is needed else set to
78: * size of fifo
79: * @kref: references counter. Reaching zero calls @ops->destruct() if non-%NULL
80: * or frees the port otherwise.
81: * @client_data: pointer to private data, for @client_ops
82: *
83: * Each device keeps its own port level information. &struct tty_port was
84: * introduced as a common structure for such information. As every TTY device
85: * shall have a backing tty_port structure, every driver can use these members.
86: *
87: * The tty port has a different lifetime to the tty so must be kept apart.
88: * In addition be careful as tty -> port mappings are valid for the life
89: * of the tty object but in many cases port -> tty mappings are valid only
90: * until a hangup so don't use the wrong path.
91: *
92: * Tty port shall be initialized by tty_port_init() and shut down either by
93: * tty_port_destroy() (refcounting not used), or tty_port_put() (refcounting).
94: *
95: * There is a lot of helpers around &struct tty_port too. To name the most
96: * significant ones: tty_port_open(), tty_port_close() (or
97: * tty_port_close_start() and tty_port_close_end() separately if need be), and
98: * tty_port_hangup(). These call @ops->activate() and @ops->shutdown() as
99: * needed.
100: */
101: struct tty_port {
102: struct tty_bufhead buf;
103: struct tty_struct *tty;
104: struct tty_struct *itty;
105: const struct tty_port_operations *ops;
106: const struct tty_port_client_operations *client_ops;
107: spinlock_t lock;
108: int blocked_open;
109: int count;
110: wait_queue_head_t open_wait;
111: wait_queue_head_t delta_msr_wait;
112: unsigned long flags;
113: unsigned long iflags;
114: unsigned char console:1;
115: struct mutex mutex;
116: struct mutex buf_mutex;
117: u8 *xmit_buf;
118: DECLARE_KFIFO_PTR(xmit_fifo, u8);
119: unsigned int close_delay;
120: unsigned int closing_wait;
121: int drain_delay;
122: struct kref kref;
123: void *client_data;
124: };
SourceFile:include/linux/tty_port.h]
|
| 28/2 |
2026/05/25 13:29 |
llm |
expert |
0m
Model:
Tokens:
input: 31143
output: 41
thoughts: 131
Thoughts: **Analyzing the FIFO Availability**
Okay, so `xmit_fifo` is defined as `DECLARE_KFIFO_PTR(xmit_fifo, u8)`. My immediate concern is what happens if this FIFO isn't actually allocated yet. Specifically, what value will `kfifo_avail` return in that scenario? The documentation states that `kfifo_avail` calculates the available space as `kfifo_size() - kfifo_len()`. Alright, that makes sense. But if the FIFO isn't initialized, `kfifo_size()` should return 0, right? Yes, it would. Hold on a second, if `kfifo_size()` *is* zero when not allocated, then `kfifo_avail()` would also return zero. That seems straightforward, but I need to make absolutely sure. Let me go back and double-check the behavior of `kfifo_avail` in this uninitialized state just to be certain. It's always best to verify these assumptions, especially when dealing with potential edge cases.
|
| 29/2 |
2026/05/25 13:29 |
tool |
codesearch-definition-source |
0m
Error:
Args: map[ContextFile:include/linux/kfifo.h IncludeLines:true Name:kfifo_avail]
Results: map[SourceCode: SourceFile:]
|
| 30/2 |
2026/05/25 13:29 |
llm |
expert |
0m
Model:
Tokens:
input: 31555
output: 19
thoughts: 17
Thoughts: Okay, here's my take on those thoughts, tailored for an expert audience, presented in the first person:
**Kernel Investigation - KFIFO Availability**
Alright, this looks like it's a macro. My gut tells me this is something that needs a deeper dive, probably related to kernel internals. The quick and dirty is to *grep* for instances of `kfifo_avail`. That'll be the starting point. I want to see where it's defined, how it's used, and most importantly, what context it lives in. I'm assuming it relates to checking the amount of available space in a `kfifo`, probably for asynchronous data transfer or something similar. Depending on the results, I might start looking at related macros or functions like `kfifo_put`, `kfifo_get`, or perhaps anything related to interrupt context as a next step. This is standard procedure when I'm chasing down something like a potential data corruption bug or performance bottleneck involving a kernel data structure like this. Let's see what we find.
|
| 31/2 |
2026/05/25 13:29 |
tool |
grepper |
0m
Error:
Args: map[Expression:define kfifo_avail]
Results:
|
| 32/2 |
2026/05/25 13:30 |
llm |
expert |
0m
Model:
Tokens:
input: 31824
output: 23
thoughts: 14
Thoughts: Here's my attempt at summarizing the thought process, tailored for an expert audience:
**Diving into the Kernel FIFO Implementation**
Alright, time to dig in. The problem at hand is making me think about kernel-level data structures. My first instinct is to go straight to the source. Specifically, I need to understand the implementation of the `kfifo` structure, so I'm heading directly to the standard place for this: `include/linux/kfifo.h`. I'm hoping to refresh my memory on the underlying details - how the circular buffer is managed, the locking primitives used for concurrency, and the general interface exposed for enqueuing and dequeuing data. I'm especially interested in how it handles boundary conditions, any potential race conditions, and any clever optimizations they've implemented. Let's see what gems we find.
|
| 33/2 |
2026/05/25 13:30 |
tool |
read-file |
0m
Args: map[File:include/linux/kfifo.h]
Results: map[Contents:/* SPDX-License-Identifier: GPL-2.0-or-later */
/*
* A generic kernel FIFO implementation
*
* Copyright (C) 2013 Stefani Seibold <stefani@seibold.net>
*/
#ifndef _LINUX_KFIFO_H
#define _LINUX_KFIFO_H
/*
* How to porting drivers to the new generic FIFO API:
*
* - Modify the declaration of the "struct kfifo *" object into a
* in-place "struct kfifo" object
* - Init the in-place object with kfifo_alloc() or kfifo_init()
* Note: The address of the in-place "struct kfifo" object must be
* passed as the first argument to this functions
* - Replace the use of __kfifo_put into kfifo_in and __kfifo_get
* into kfifo_out
* - Replace the use of kfifo_put into kfifo_in_spinlocked and kfifo_get
* into kfifo_out_spinlocked
* Note: the spinlock pointer formerly passed to kfifo_init/kfifo_alloc
* must be passed now to the kfifo_in_spinlocked and kfifo_out_spinlocked
* as the last parameter
* - The formerly __kfifo_* functions are renamed into kfifo_*
*/
/*
* Note about locking: There is no locking required until only one reader
* and one writer is using the fifo and no kfifo_reset() will be called.
* kfifo_reset_out() can be safely used, until it will be only called
* in the reader thread.
* For multiple writer and one reader there is only a need to lock the writer.
* And vice versa for only one writer and multiple reader there is only a need
* to lock the reader.
*/
#include <linux/array_size.h>
#include <linux/spinlock.h>
#include <linux/stddef.h>
#include <linux/types.h>
#include <asm/barrier.h>
#include <asm/errno.h>
struct scatterlist;
struct __kfifo {
unsigned int in;
unsigned int out;
unsigned int mask;
unsigned int esize;
void *data;
};
#define __STRUCT_KFIFO_COMMON(datatype, recsize, ptrtype) \
union { \
struct __kfifo kfifo; \
datatype *type; \
const datatype *const_type; \
char (*rectype)[recsize]; \
ptrtype *ptr; \
ptrtype const *ptr_const; \
}
#define __STRUCT_KFIFO(type, size, recsize, ptrtype) \
{ \
__STRUCT_KFIFO_COMMON(type, recsize, ptrtype); \
type buf[((size < 2) || (size & (size - 1))) ? -1 : size]; \
}
#define STRUCT_KFIFO(type, size) \
struct __STRUCT_KFIFO(type, size, 0, type)
#define __STRUCT_KFIFO_PTR(type, recsize, ptrtype) \
{ \
__STRUCT_KFIFO_COMMON(type, recsize, ptrtype); \
type buf[0]; \
}
#define STRUCT_KFIFO_PTR(type) \
struct __STRUCT_KFIFO_PTR(type, 0, type)
/*
* define compatibility "struct kfifo" for dynamic allocated fifos
*/
struct kfifo __STRUCT_KFIFO_PTR(unsigned char, 0, void);
#define STRUCT_KFIFO_REC_1(size) \
struct __STRUCT_KFIFO(unsigned char, size, 1, void)
#define STRUCT_KFIFO_REC_2(size) \
struct __STRUCT_KFIFO(unsigned char, size, 2, void)
/*
* define kfifo_rec types
*/
struct kfifo_rec_ptr_1 __STRUCT_KFIFO_PTR(unsigned char, 1, void);
struct kfifo_rec_ptr_2 __STRUCT_KFIFO_PTR(unsigned char, 2, void);
/*
* helper macro to distinguish between real in place fifo where the fifo
* array is a part of the structure and the fifo type where the array is
* outside of the fifo structure.
*/
#define __is_kfifo_ptr(fifo) \
(sizeof(*fifo) == sizeof(STRUCT_KFIFO_PTR(typeof(*(fifo)->type))))
/**
* DECLARE_KFIFO_PTR - macro to declare a fifo pointer object
* @fifo: name of the declared fifo
* @type: type of the fifo elements
*/
#define DECLARE_KFIFO_PTR(fifo, type) STRUCT_KFIFO_PTR(type) fifo
/**
* DECLARE_KFIFO - macro to declare a fifo object
* @fifo: name of the declared fifo
* @type: type of the fifo elements
* @size: the number of elements in the fifo, this must be a power of 2
*/
#define DECLARE_KFIFO(fifo, type, size) STRUCT_KFIFO(type, size) fifo
/**
* INIT_KFIFO - Initialize a fifo declared by DECLARE_KFIFO
* @fifo: name of the declared fifo datatype
*/
#define INIT_KFIFO(fifo) \
(void)({ \
typeof(&(fifo)) __tmp = &(fifo); \
struct __kfifo *__kfifo = &__tmp->kfifo; \
__kfifo->in = 0; \
__kfifo->out = 0; \
__kfifo->mask = __is_kfifo_ptr(__tmp) ? 0 : ARRAY_SIZE(__tmp->buf) - 1;\
__kfifo->esize = sizeof(*__tmp->buf); \
__kfifo->data = __is_kfifo_ptr(__tmp) ? NULL : __tmp->buf; \
})
/**
* DEFINE_KFIFO - macro to define and initialize a fifo
* @fifo: name of the declared fifo datatype
* @type: type of the fifo elements
* @size: the number of elements in the fifo, this must be a power of 2
*
* Note: the macro can be used for global and local fifo data type variables.
*/
#define DEFINE_KFIFO(fifo, type, size) \
DECLARE_KFIFO(fifo, type, size) = \
(typeof(fifo)) { \
{ \
{ \
.in = 0, \
.out = 0, \
.mask = __is_kfifo_ptr(&(fifo)) ? \
0 : \
ARRAY_SIZE((fifo).buf) - 1, \
.esize = sizeof(*(fifo).buf), \
.data = __is_kfifo_ptr(&(fifo)) ? \
NULL : \
(fifo).buf, \
} \
} \
}
static inline unsigned int __must_check
__kfifo_uint_must_check_helper(unsigned int val)
{
return val;
}
static inline int __must_check
__kfifo_int_must_check_helper(int val)
{
return val;
}
/**
* kfifo_initialized - Check if the fifo is initialized
* @fifo: address of the fifo to check
*
* Return %true if fifo is initialized, otherwise %false.
* Assumes the fifo was 0 before.
*/
#define kfifo_initialized(fifo) ((fifo)->kfifo.mask)
/**
* kfifo_esize - returns the size of the element managed by the fifo
* @fifo: address of the fifo to be used
*/
#define kfifo_esize(fifo) ((fifo)->kfifo.esize)
/**
* kfifo_recsize - returns the size of the record length field
* @fifo: address of the fifo to be used
*/
#define kfifo_recsize(fifo) (sizeof(*(fifo)->rectype))
/**
* kfifo_size - returns the size of the fifo in elements
* @fifo: address of the fifo to be used
*/
#define kfifo_size(fifo) ((fifo)->kfifo.mask + 1)
/**
* kfifo_reset - removes the entire fifo content
* @fifo: address of the fifo to be used
*
* Note: usage of kfifo_reset() is dangerous. It should be only called when the
* fifo is exclusived locked or when it is secured that no other thread is
* accessing the fifo.
*/
#define kfifo_reset(fifo) \
(void)({ \
typeof((fifo) + 1) __tmp = (fifo); \
__tmp->kfifo.in = __tmp->kfifo.out = 0; \
})
/**
* kfifo_reset_out - skip fifo content
* @fifo: address of the fifo to be used
*
* Note: The usage of kfifo_reset_out() is safe until it will be only called
* from the reader thread and there is only one concurrent reader. Otherwise
* it is dangerous and must be handled in the same way as kfifo_reset().
*/
#define kfifo_reset_out(fifo) \
(void)({ \
typeof((fifo) + 1) __tmp = (fifo); \
__tmp->kfifo.out = __tmp->kfifo.in; \
})
/**
* kfifo_len - returns the number of used elements in the fifo
* @fifo: address of the fifo to be used
*/
#define kfifo_len(fifo) \
({ \
typeof((fifo) + 1) __tmpl = (fifo); \
__tmpl->kfifo.in - __tmpl->kfifo.out; \
})
/**
* kfifo_is_empty - returns true if the fifo is empty
* @fifo: address of the fifo to be used
*/
#define kfifo_is_empty(fifo) \
({ \
typeof((fifo) + 1) __tmpq = (fifo); \
__tmpq->kfifo.in == __tmpq->kfifo.out; \
})
/**
* kfifo_is_empty_spinlocked - returns true if the fifo is empty using
* a spinlock for locking
* @fifo: address of the fifo to be used
* @lock: spinlock to be used for locking
*/
#define kfifo_is_empty_spinlocked(fifo, lock) \
({ \
unsigned long __flags; \
bool __ret; \
spin_lock_irqsave(lock, __flags); \
__ret = kfifo_is_empty(fifo); \
spin_unlock_irqrestore(lock, __flags); \
__ret; \
})
/**
* kfifo_is_empty_spinlocked_noirqsave - returns true if the fifo is empty
* using a spinlock for locking, doesn't disable interrupts
* @fifo: address of the fifo to be used
* @lock: spinlock to be used for locking
*/
#define kfifo_is_empty_spinlocked_noirqsave(fifo, lock) \
({ \
bool __ret; \
spin_lock(lock); \
__ret = kfifo_is_empty(fifo); \
spin_unlock(lock); \
__ret; \
})
/**
* kfifo_is_full - returns true if the fifo is full
* @fifo: address of the fifo to be used
*/
#define kfifo_is_full(fifo) \
({ \
typeof((fifo) + 1) __tmpq = (fifo); \
kfifo_len(__tmpq) > __tmpq->kfifo.mask; \
})
/**
* kfifo_avail - returns the number of unused elements in the fifo
* @fifo: address of the fifo to be used
*/
#define kfifo_avail(fifo) \
__kfifo_uint_must_check_helper( \
({ \
typeof((fifo) + 1) __tmpq = (fifo); \
const size_t __recsize = sizeof(*__tmpq->rectype); \
unsigned int __avail = kfifo_size(__tmpq) - kfifo_len(__tmpq); \
(__recsize) ? ((__avail <= __recsize) ? 0 : \
__kfifo_max_r(__avail - __recsize, __recsize)) : \
__avail; \
}) \
)
/**
* kfifo_skip_count - skip output data
* @fifo: address of the fifo to be used
* @count: count of data to skip
*/
#define kfifo_skip_count(fifo, count) do { \
typeof((fifo) + 1) __tmp = (fifo); \
const size_t __recsize = sizeof(*__tmp->rectype); \
struct __kfifo *__kfifo = &__tmp->kfifo; \
if (__recsize) \
__kfifo_skip_r(__kfifo, __recsize); \
else \
__kfifo->out += (count); \
} while(0)
/**
* kfifo_skip - skip output data
* @fifo: address of the fifo to be used
*/
#define kfifo_skip(fifo) kfifo_skip_count(fifo, 1)
/**
* kfifo_peek_len - gets the size of the next fifo record
* @fifo: address of the fifo to be used
*
* This function returns the size of the next fifo record in number of bytes.
*/
#define kfifo_peek_len(fifo) \
__kfifo_uint_must_check_helper( \
({ \
typeof((fifo) + 1) __tmp = (fifo); \
const size_t __recsize = sizeof(*__tmp->rectype); \
struct __kfifo *__kfifo = &__tmp->kfifo; \
(!__recsize) ? kfifo_len(__tmp) * sizeof(*__tmp->type) : \
__kfifo_len_r(__kfifo, __recsize); \
}) \
)
/**
* kfifo_alloc - dynamically allocates a new fifo buffer
* @fifo: pointer to the fifo
* @size: the number of elements in the fifo, this must be a power of 2
* @gfp_mask: get_free_pages mask, passed to kmalloc()
*
* This macro dynamically allocates a new fifo buffer.
*
* The number of elements will be rounded-up to a power of 2.
* The fifo will be release with kfifo_free().
* Return 0 if no error, otherwise an error code.
*/
#define kfifo_alloc(fifo, size, gfp_mask) \
__kfifo_int_must_check_helper( \
({ \
typeof((fifo) + 1) __tmp = (fifo); \
struct __kfifo *__kfifo = &__tmp->kfifo; \
__is_kfifo_ptr(__tmp) ? \
__kfifo_alloc(__kfifo, size, sizeof(*__tmp->type), gfp_mask) : \
-EINVAL; \
}) \
)
/**
* kfifo_alloc_node - dynamically allocates a new fifo buffer on a NUMA node
* @fifo: pointer to the fifo
* @size: the number of elements in the fifo, this must be a power of 2
* @gfp_mask: get_free_pages mask, passed to kmalloc()
* @node: NUMA node to allocate memory on
*
* This macro dynamically allocates a new fifo buffer with NUMA node awareness.
*
* The number of elements will be rounded-up to a power of 2.
* The fifo will be release with kfifo_free().
* Return 0 if no error, otherwise an error code.
*/
#define kfifo_alloc_node(fifo, size, gfp_mask, node) \
__kfifo_int_must_check_helper( \
({ \
typeof((fifo) + 1) __tmp = (fifo); \
struct __kfifo *__kfifo = &__tmp->kfifo; \
__is_kfifo_ptr(__tmp) ? \
__kfifo_alloc_node(__kfifo, size, sizeof(*__tmp->type), gfp_mask, node) : \
-EINVAL; \
}) \
)
/**
* kfifo_free - frees the fifo
* @fifo: the fifo to be freed
*/
#define kfifo_free(fifo) \
({ \
typeof((fifo) + 1) __tmp = (fifo); \
struct __kfifo *__kfifo = &__tmp->kfifo; \
if (__is_kfifo_ptr(__tmp)) \
__kfifo_free(__kfifo); \
})
/**
* kfifo_init - initialize a fifo using a preallocated buffer
* @fifo: the fifo to assign the buffer
* @buffer: the preallocated buffer to be used
* @size: the size of the internal buffer, this have to be a power of 2
*
* This macro initializes a fifo using a preallocated buffer.
*
* The number of elements will be rounded-up to a power of 2.
* Return 0 if no error, otherwise an error code.
*/
#define kfifo_init(fifo, buffer, size) \
({ \
typeof((fifo) + 1) __tmp = (fifo); \
struct __kfifo *__kfifo = &__tmp->kfifo; \
__is_kfifo_ptr(__tmp) ? \
__kfifo_init(__kfifo, buffer, size, sizeof(*__tmp->type)) : \
-EINVAL; \
})
/**
* kfifo_put - put data into the fifo
* @fifo: address of the fifo to be used
* @val: the data to be added
*
* This macro copies the given value into the fifo.
* It returns 0 if the fifo was full. Otherwise it returns the number
* processed elements.
*
* Note that with only one concurrent reader and one concurrent
* writer, you don't need extra locking to use these macro.
*/
#define kfifo_put(fifo, val) \
({ \
typeof((fifo) + 1) __tmp = (fifo); \
typeof(*__tmp->const_type) __val = (val); \
unsigned int __ret; \
size_t __recsize = sizeof(*__tmp->rectype); \
struct __kfifo *__kfifo = &__tmp->kfifo; \
if (__recsize) \
__ret = __kfifo_in_r(__kfifo, &__val, sizeof(__val), \
__recsize); \
else { \
__ret = !kfifo_is_full(__tmp); \
if (__ret) { \
(__is_kfifo_ptr(__tmp) ? \
((typeof(__tmp->type))__kfifo->data) : \
(__tmp->buf) \
)[__kfifo->in & __tmp->kfifo.mask] = \
*(typeof(__tmp->type))&__val; \
smp_wmb(); \
__kfifo->in++; \
} \
} \
__ret; \
})
/**
* kfifo_get - get data from the fifo
* @fifo: address of the fifo to be used
* @val: address where to store the data
*
* This macro reads the data from the fifo.
* It returns 0 if the fifo was empty. Otherwise it returns the number
* processed elements.
*
* Note that with only one concurrent reader and one concurrent
* writer, you don't need extra locking to use these macro.
*/
#define kfifo_get(fifo, val) \
__kfifo_uint_must_check_helper( \
({ \
typeof((fifo) + 1) __tmp = (fifo); \
typeof(__tmp->ptr) __val = (val); \
unsigned int __ret; \
const size_t __recsize = sizeof(*__tmp->rectype); \
struct __kfifo *__kfifo = &__tmp->kfifo; \
if (__recsize) \
__ret = __kfifo_out_r(__kfifo, __val, sizeof(*__val), \
__recsize); \
else { \
__ret = !kfifo_is_empty(__tmp); \
if (__ret) { \
*(typeof(__tmp->type))__val = \
(__is_kfifo_ptr(__tmp) ? \
((typeof(__tmp->type))__kfifo->data) : \
(__tmp->buf) \
)[__kfifo->out & __tmp->kfifo.mask]; \
smp_wmb(); \
__kfifo->out++; \
} \
} \
__ret; \
}) \
)
/**
* kfifo_peek - get data from the fifo without removing
* @fifo: address of the fifo to be used
* @val: address where to store the data
*
* This reads the data from the fifo without removing it from the fifo.
* It returns 0 if the fifo was empty. Otherwise it returns the number
* processed elements.
*
* Note that with only one concurrent reader and one concurrent
* writer, you don't need extra locking to use these macro.
*/
#define kfifo_peek(fifo, val) \
__kfifo_uint_must_check_helper( \
({ \
typeof((fifo) + 1) __tmp = (fifo); \
typeof(__tmp->ptr) __val = (val); \
unsigned int __ret; \
const size_t __recsize = sizeof(*__tmp->rectype); \
struct __kfifo *__kfifo = &__tmp->kfifo; \
if (__recsize) \
__ret = __kfifo_out_peek_r(__kfifo, __val, sizeof(*__val), \
__recsize); \
else { \
__ret = !kfifo_is_empty(__tmp); \
if (__ret) { \
*(typeof(__tmp->type))__val = \
(__is_kfifo_ptr(__tmp) ? \
((typeof(__tmp->type))__kfifo->data) : \
(__tmp->buf) \
)[__kfifo->out & __tmp->kfifo.mask]; \
smp_wmb(); \
} \
} \
__ret; \
}) \
)
/**
* kfifo_in - put data into the fifo
* @fifo: address of the fifo to be used
* @buf: the data to be added
* @n: number of elements to be added
*
* This macro copies the given buffer into the fifo and returns the
* number of copied elements.
*
* Note that with only one concurrent reader and one concurrent
* writer, you don't need extra locking to use these macro.
*/
#define kfifo_in(fifo, buf, n) \
({ \
typeof((fifo) + 1) __tmp = (fifo); \
typeof(__tmp->ptr_const) __buf = (buf); \
unsigned long __n = (n); \
const size_t __recsize = sizeof(*__tmp->rectype); \
struct __kfifo *__kfifo = &__tmp->kfifo; \
(__recsize) ?\
__kfifo_in_r(__kfifo, __buf, __n, __recsize) : \
__kfifo_in(__kfifo, __buf, __n); \
})
/**
* kfifo_in_spinlocked - put data into the fifo using a spinlock for locking
* @fifo: address of the fifo to be used
* @buf: the data to be added
* @n: number of elements to be added
* @lock: pointer to the spinlock to use for locking
*
* This macro copies the given values buffer into the fifo and returns the
* number of copied elements.
*/
#define kfifo_in_spinlocked(fifo, buf, n, lock) \
({ \
unsigned long __flags; \
unsigned int __ret; \
spin_lock_irqsave(lock, __flags); \
__ret = kfifo_in(fifo, buf, n); \
spin_unlock_irqrestore(lock, __flags); \
__ret; \
})
/**
* kfifo_in_spinlocked_noirqsave - put data into fifo using a spinlock for
* locking, don't disable interrupts
* @fifo: address of the fifo to be used
* @buf: the data to be added
* @n: number of elements to be added
* @lock: pointer to the spinlock to use for locking
*
* This is a variant of kfifo_in_spinlocked() but uses spin_lock/unlock()
* for locking and doesn't disable interrupts.
*/
#define kfifo_in_spinlocked_noirqsave(fifo, buf, n, lock) \
({ \
unsigned int __ret; \
spin_lock(lock); \
__ret = kfifo_in(fifo, buf, n); \
spin_unlock(lock); \
__ret; \
})
/* alias for kfifo_in_spinlocked, will be removed in a future release */
#define kfifo_in_locked(fifo, buf, n, lock) \
kfifo_in_spinlocked(fifo, buf, n, lock)
/**
* kfifo_out - get data from the fifo
* @fifo: address of the fifo to be used
* @buf: pointer to the storage buffer
* @n: max. number of elements to get
*
* This macro gets some data from the fifo and returns the numbers of elements
* copied.
*
* Note that with only one concurrent reader and one concurrent
* writer, you don't need extra locking to use these macro.
*/
#define kfifo_out(fifo, buf, n) \
__kfifo_uint_must_check_helper( \
({ \
typeof((fifo) + 1) __tmp = (fifo); \
typeof(__tmp->ptr) __buf = (buf); \
unsigned long __n = (n); \
const size_t __recsize = sizeof(*__tmp->rectype); \
struct __kfifo *__kfifo = &__tmp->kfifo; \
(__recsize) ?\
__kfifo_out_r(__kfifo, __buf, __n, __recsize) : \
__kfifo_out(__kfifo, __buf, __n); \
}) \
)
/**
* kfifo_out_spinlocked - get data from the fifo using a spinlock for locking
* @fifo: address of the fifo to be used
* @buf: pointer to the storage buffer
* @n: max. number of elements to get
* @lock: pointer to the spinlock to use for locking
*
* This macro gets the data from the fifo and returns the numbers of elements
* copied.
*/
#define kfifo_out_spinlocked(fifo, buf, n, lock) \
__kfifo_uint_must_check_helper( \
({ \
unsigned long __flags; \
unsigned int __ret; \
spin_lock_irqsave(lock, __flags); \
__ret = kfifo_out(fifo, buf, n); \
spin_unlock_irqrestore(lock, __flags); \
__ret; \
}) \
)
/**
* kfifo_out_spinlocked_noirqsave - get data from the fifo using a spinlock
* for locking, don't disable interrupts
* @fifo: address of the fifo to be used
* @buf: pointer to the storage buffer
* @n: max. number of elements to get
* @lock: pointer to the spinlock to use for locking
*
* This is a variant of kfifo_out_spinlocked() which uses spin_lock/unlock()
* for locking and doesn't disable interrupts.
*/
#define kfifo_out_spinlocked_noirqsave(fifo, buf, n, lock) \
__kfifo_uint_must_check_helper( \
({ \
unsigned int __ret; \
spin_lock(lock); \
__ret = kfifo_out(fifo, buf, n); \
spin_unlock(lock); \
__ret; \
}) \
)
/* alias for kfifo_out_spinlocked, will be removed in a future release */
#define kfifo_out_locked(fifo, buf, n, lock) \
kfifo_out_spinlocked(fifo, buf, n, lock)
/**
* kfifo_from_user - puts some data from user space into the fifo
* @fifo: address of the fifo to be used
* @from: pointer to the data to be added
* @len: the length of the data to be added
* @copied: pointer to output variable to store the number of copied bytes
*
* This macro copies at most @len bytes from the @from into the
* fifo, depending of the available space and returns -EFAULT/0.
*
* Note that with only one concurrent reader and one concurrent
* writer, you don't need extra locking to use these macro.
*/
#define kfifo_from_user(fifo, from, len, copied) \
__kfifo_uint_must_check_helper( \
({ \
typeof((fifo) + 1) __tmp = (fifo); \
const void __user *__from = (from); \
unsigned int __len = (len); \
unsigned int *__copied = (copied); \
const size_t __recsize = sizeof(*__tmp->rectype); \
struct __kfifo *__kfifo = &__tmp->kfifo; \
(__recsize) ? \
__kfifo_from_user_r(__kfifo, __from, __len, __copied, __recsize) : \
__kfifo_from_user(__kfifo, __from, __len, __copied); \
}) \
)
/**
* kfifo_to_user - copies data from the fifo into user space
* @fifo: address of the fifo to be used
* @to: where the data must be copied
* @len: the size of the destination buffer
* @copied: pointer to output variable to store the number of copied bytes
*
* This macro copies at most @len bytes from the fifo into the
* @to buffer and returns -EFAULT/0.
*
* Note that with only one concurrent reader and one concurrent
* writer, you don't need extra locking to use these macro.
*/
#define kfifo_to_user(fifo, to, len, copied) \
__kfifo_int_must_check_helper( \
({ \
typeof((fifo) + 1) __tmp = (fifo); \
void __user *__to = (to); \
unsigned int __len = (len); \
unsigned int *__copied = (copied); \
const size_t __recsize = sizeof(*__tmp->rectype); \
struct __kfifo *__kfifo = &__tmp->kfifo; \
(__recsize) ? \
__kfifo_to_user_r(__kfifo, __to, __len, __copied, __recsize) : \
__kfifo_to_user(__kfifo, __to, __len, __copied); \
}) \
)
/**
* kfifo_dma_in_prepare_mapped - setup a scatterlist for DMA input
* @fifo: address of the fifo to be used
* @sgl: pointer to the scatterlist array
* @nents: number of entries in the scatterlist array
* @len: number of elements to transfer
* @dma: mapped dma address to fill into @sgl
*
* This macro fills a scatterlist for DMA input.
* It returns the number entries in the scatterlist array.
*
* Note that with only one concurrent reader and one concurrent
* writer, you don't need extra locking to use these macros.
*/
#define kfifo_dma_in_prepare_mapped(fifo, sgl, nents, len, dma) \
({ \
typeof((fifo) + 1) __tmp = (fifo); \
struct scatterlist *__sgl = (sgl); \
int __nents = (nents); \
unsigned int __len = (len); \
const size_t __recsize = sizeof(*__tmp->rectype); \
struct __kfifo *__kfifo = &__tmp->kfifo; \
(__recsize) ? \
__kfifo_dma_in_prepare_r(__kfifo, __sgl, __nents, __len, __recsize, \
dma) : \
__kfifo_dma_in_prepare(__kfifo, __sgl, __nents, __len, dma); \
})
#define kfifo_dma_in_prepare(fifo, sgl, nents, len) \
kfifo_dma_in_prepare_mapped(fifo, sgl, nents, len, DMA_MAPPING_ERROR)
/**
* kfifo_dma_in_finish - finish a DMA IN operation
* @fifo: address of the fifo to be used
* @len: number of bytes to received
*
* This macro finishes a DMA IN operation. The in counter will be updated by
* the len parameter. No error checking will be done.
*
* Note that with only one concurrent reader and one concurrent
* writer, you don't need extra locking to use these macros.
*/
#define kfifo_dma_in_finish(fifo, len) \
(void)({ \
typeof((fifo) + 1) __tmp = (fifo); \
unsigned int __len = (len); \
const size_t __recsize = sizeof(*__tmp->rectype); \
struct __kfifo *__kfifo = &__tmp->kfifo; \
if (__recsize) \
__kfifo_dma_in_finish_r(__kfifo, __len, __recsize); \
else \
__kfifo->in += __len / sizeof(*__tmp->type); \
})
/**
* kfifo_dma_out_prepare_mapped - setup a scatterlist for DMA output
* @fifo: address of the fifo to be used
* @sgl: pointer to the scatterlist array
* @nents: number of entries in the scatterlist array
* @len: number of elements to transfer
* @dma: mapped dma address to fill into @sgl
*
* This macro fills a scatterlist for DMA output which at most @len bytes
* to transfer.
* It returns the number entries in the scatterlist array.
* A zero means there is no space available and the scatterlist is not filled.
*
* Note that with only one concurrent reader and one concurrent
* writer, you don't need extra locking to use these macros.
*/
#define kfifo_dma_out_prepare_mapped(fifo, sgl, nents, len, dma) \
({ \
typeof((fifo) + 1) __tmp = (fifo); \
struct scatterlist *__sgl = (sgl); \
int __nents = (nents); \
unsigned int __len = (len); \
const size_t __recsize = sizeof(*__tmp->rectype); \
struct __kfifo *__kfifo = &__tmp->kfifo; \
(__recsize) ? \
__kfifo_dma_out_prepare_r(__kfifo, __sgl, __nents, __len, __recsize, \
dma) : \
__kfifo_dma_out_prepare(__kfifo, __sgl, __nents, __len, dma); \
})
#define kfifo_dma_out_prepare(fifo, sgl, nents, len) \
kfifo_dma_out_prepare_mapped(fifo, sgl, nents, len, DMA_MAPPING_ERROR)
/**
* kfifo_dma_out_finish - finish a DMA OUT operation
* @fifo: address of the fifo to be used
* @len: number of bytes transferred
*
* This macro finishes a DMA OUT operation. The out counter will be updated by
* the len parameter. No error checking will be done.
*
* Note that with only one concurrent reader and one concurrent
* writer, you don't need extra locking to use these macros.
*/
#define kfifo_dma_out_finish(fifo, len) do { \
typeof((fifo) + 1) ___tmp = (fifo); \
kfifo_skip_count(___tmp, (len) / sizeof(*___tmp->type)); \
} while (0)
/**
* kfifo_out_peek - gets some data from the fifo
* @fifo: address of the fifo to be used
* @buf: pointer to the storage buffer
* @n: max. number of elements to get
*
* This macro gets the data from the fifo and returns the numbers of elements
* copied. The data is not removed from the fifo.
*
* Note that with only one concurrent reader and one concurrent
* writer, you don't need extra locking to use these macro.
*/
#define kfifo_out_peek(fifo, buf, n) \
__kfifo_uint_must_check_helper( \
({ \
typeof((fifo) + 1) __tmp = (fifo); \
typeof(__tmp->ptr) __buf = (buf); \
unsigned long __n = (n); \
const size_t __recsize = sizeof(*__tmp->rectype); \
struct __kfifo *__kfifo = &__tmp->kfifo; \
(__recsize) ? \
__kfifo_out_peek_r(__kfifo, __buf, __n, __recsize) : \
__kfifo_out_peek(__kfifo, __buf, __n); \
}) \
)
/**
* kfifo_out_linear - gets a tail of/offset to available data
* @fifo: address of the fifo to be used
* @tail: pointer to an unsigned int to store the value of tail
* @n: max. number of elements to point at
*
* This macro obtains the offset (tail) to the available data in the fifo
* buffer and returns the
* numbers of elements available. It returns the available count till the end
* of data or till the end of the buffer. So that it can be used for linear
* data processing (like memcpy() of (@fifo->data + @tail) with count
* returned).
*
* Note that with only one concurrent reader and one concurrent
* writer, you don't need extra locking to use these macro.
*/
#define kfifo_out_linear(fifo, tail, n) \
__kfifo_uint_must_check_helper( \
({ \
typeof((fifo) + 1) __tmp = (fifo); \
unsigned int *__tail = (tail); \
unsigned long __n = (n); \
const size_t __recsize = sizeof(*__tmp->rectype); \
struct __kfifo *__kfifo = &__tmp->kfifo; \
(__recsize) ? \
__kfifo_out_linear_r(__kfifo, __tail, __n, __recsize) : \
__kfifo_out_linear(__kfifo, __tail, __n); \
}) \
)
/**
* kfifo_out_linear_ptr - gets a pointer to the available data
* @fifo: address of the fifo to be used
* @ptr: pointer to data to store the pointer to tail
* @n: max. number of elements to point at
*
* Similarly to kfifo_out_linear(), this macro obtains the pointer to the
* available data in the fifo buffer and returns the numbers of elements
* available. It returns the available count till the end of available data or
* till the end of the buffer. So that it can be used for linear data
* processing (like memcpy() of @ptr with count returned).
*
* Note that with only one concurrent reader and one concurrent
* writer, you don't need extra locking to use these macro.
*/
#define kfifo_out_linear_ptr(fifo, ptr, n) \
__kfifo_uint_must_check_helper( \
({ \
typeof((fifo) + 1) ___tmp = (fifo); \
unsigned int ___tail; \
unsigned int ___n = kfifo_out_linear(___tmp, &___tail, (n)); \
*(ptr) = ___tmp->kfifo.data + ___tail * kfifo_esize(___tmp); \
___n; \
}) \
)
extern int __kfifo_alloc_node(struct __kfifo *fifo, unsigned int size,
size_t esize, gfp_t gfp_mask, int node);
static inline int __kfifo_alloc(struct __kfifo *fifo, unsigned int size,
size_t esize, gfp_t gfp_mask)
{
return __kfifo_alloc_node(fifo, size, esize, gfp_mask, NUMA_NO_NODE);
}
extern void __kfifo_free(struct __kfifo *fifo);
extern int __kfifo_init(struct __kfifo *fifo, void *buffer,
unsigned int size, size_t esize);
extern unsigned int __kfifo_in(struct __kfifo *fifo,
const void *buf, unsigned int len);
extern unsigned int __kfifo_out(struct __kfifo *fifo,
void *buf, unsigned int len);
extern int __kfifo_from_user(struct __kfifo *fifo,
const void __user *from, unsigned long len, unsigned int *copied);
extern int __kfifo_to_user(struct __kfifo *fifo,
void __user *to, unsigned long len, unsigned int *copied);
extern unsigned int __kfifo_dma_in_prepare(struct __kfifo *fifo,
struct scatterlist *sgl, int nents, unsigned int len, dma_addr_t dma);
extern unsigned int __kfifo_dma_out_prepare(struct __kfifo *fifo,
struct scatterlist *sgl, int nents, unsigned int len, dma_addr_t dma);
extern unsigned int __kfifo_out_peek(struct __kfifo *fifo,
void *buf, unsigned int len);
extern unsigned int __kfifo_out_linear(struct __kfifo *fifo,
unsigned int *tail, unsigned int n);
extern unsigned int __kfifo_in_r(struct __kfifo *fifo,
const void *buf, unsigned int len, size_t recsize);
extern unsigned int __kfifo_out_r(struct __kfifo *fifo,
void *buf, unsigned int len, size_t recsize);
extern int __kfifo_from_user_r(struct __kfifo *fifo,
const void __user *from, unsigned long len, unsigned int *copied,
size_t recsize);
extern int __kfifo_to_user_r(struct __kfifo *fifo, void __user *to,
unsigned long len, unsigned int *copied, size_t recsize);
extern unsigned int __kfifo_dma_in_prepare_r(struct __kfifo *fifo,
struct scatterlist *sgl, int nents, unsigned int len, size_t recsize,
dma_addr_t dma);
extern void __kfifo_dma_in_finish_r(struct __kfifo *fifo,
unsigned int len, size_t recsize);
extern unsigned int __kfifo_dma_out_prepare_r(struct __kfifo *fifo,
struct scatterlist *sgl, int nents, unsigned int len, size_t recsize,
dma_addr_t dma);
extern unsigned int __kfifo_len_r(struct __kfifo *fifo, size_t recsize);
extern void __kfifo_skip_r(struct __kfifo *fifo, size_t recsize);
extern unsigned int __kfifo_out_peek_r(struct __kfifo *fifo,
void *buf, unsigned int len, size_t recsize);
extern unsigned int __kfifo_out_linear_r(struct __kfifo *fifo,
unsigned int *tail, unsigned int n, size_t recsize);
extern unsigned int __kfifo_max_r(unsigned int len, size_t recsize);
#endif
]
|
| 34/2 |
2026/05/25 13:30 |
llm |
expert |
0m
Model:
Tokens:
input: 42611
output: 45
thoughts: 806
Thoughts: **Analyzing the UART Transmit FIFO and Buffer**
Okay, so I'm looking at how the UART driver handles transmit data. My thought process is starting with `kfifo_avail`, the function that tells me how much space is available in the transmit FIFO (`xmit_fifo`). The macro definition for `kfifo_avail` is a bit dense, but I can break it down. It calculates the available space by subtracting the current length (`kfifo_len`) from the total size (`kfifo_size`).
Initially, I got tripped up by the uninitialized state. If `xmit_fifo` isn't allocated, the `mask` in `kfifo_size` is zero, so the size is 1. `kfifo_len` would also be zero since `in` and `out` are initialized to zero. Therefore, `kfifo_avail` would return 1, indicating a single byte is available, which seems counterintuitive for an uninitialized FIFO. I need to be careful about that case.
Then I realized this connects to `uart_write_room`, which calls `kfifo_avail`. If the FIFO isn't allocated, `uart_write_room` would also return 1. Now, `handle_tx` uses this information to determine the amount of data it can write. If it sees that a single byte is available (`room = 1`), it calls `tty->ops->write`, which is `uart_write` in this case.
Here's where the problem arises: `uart_write` checks `state->port.xmit_buf`, *not* `xmit_fifo`. If `xmit_buf` is NULL, it returns 0. That’s the key difference. Wait a minute, I realized that these are different fields; `xmit_buf` and `xmit_fifo` are distinct. Let me just confirm that in the `tty_port` structure... Yup, `xmit_buf` is a pointer, while `xmit_fifo` is a KFIFO.
Okay, so `uart_write` returns 0 if `xmit_buf` is NULL, which means no bytes were actually written. But `uart_write_room` still claims that 1 byte is available! This is the core issue. Typically, `xmit_buf` and `xmit_fifo` are allocated together, but this subtle difference means that when `xmit_buf` is NULL (i.e., not allocated or deallocated), `uart_write_room` will still return 1, leading to an infinite loop in `handle_tx` because it thinks there's room, but nothing is actually written. This leads to the driver thinking that it successfully wrote a byte when it hasn't, and will keep entering this loop. I need to verify that this is indeed the case.
|
| 35/2 |
2026/05/25 13:30 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/tty/serial/serial_core.c IncludeLines:true Name:uart_write_room]
Results: map[SourceCode: 638: static unsigned int uart_write_room(struct tty_struct *tty)
639: {
640: struct uart_state *state = tty->driver_data;
641: struct uart_port *port;
642: unsigned long flags;
643: unsigned int ret;
644:
645: port = uart_port_ref_lock(state, &flags);
646: ret = kfifo_avail(&state->port.xmit_fifo);
647: uart_port_unlock_deref(port, flags);
648: return ret;
649: }
SourceFile:drivers/tty/serial/serial_core.c]
|
| 36/2 |
2026/05/25 13:30 |
llm |
expert |
0m
Model:
Tokens:
input: 44283
output: 52
thoughts: 85
Thoughts: Here's my summary, as I understand the situation:
**UART Transmit Buffer Conundrum**
Okay, hold on a second. I'm focusing on the `uart_write_room` function, and something's not quite clicking. It seems I missed a key detail: it doesn't actually validate the contents of `state->port.xmit_buf` before calculating space availability. That feels… wrong.
Now, if `xmit_buf` is `NULL`, which it can be under specific circumstances, `kfifo_avail(&state->port.xmit_fifo)` doesn't behave as expected. It would return 1 or potentially some other value such as `mask + 1`, particularly if `xmit_buf` was previously allocated and subsequently freed. That's a huge potential issue. This could lead to incorrect room calculations, buffer overflows, or other unpredictable behavior if not handled correctly.
And that then leads to the next questions, when exactly is `xmit_buf` allocated and freed? What are the conditions that cause it to become `NULL` in the first place? Knowing that will be absolutely crucial for understanding the overall data flow and identifying any vulnerabilities or race conditions in this UART driver. I need to dig into the surrounding code to determine how that buffer is managed because it appears that this logic is incomplete.
|
| 37/2 |
2026/05/25 13:30 |
tool |
codesearch-find-references |
0m
Error:
Args: map[ContextFile:drivers/tty/serial/serial_core.c IncludeSnippetLines:0 Name:xmit_buf SourceTreePrefix:]
Results: map[References:<nil> TruncatedOutput:false]
|
| 38/2 |
2026/05/25 13:30 |
llm |
expert |
0m
Model:
Tokens:
input: 44725
output: 18
thoughts: 25
Thoughts: Here's my thought process, summarized as you requested:
**Navigating the Serial Driver Landscape**
Okay, so I need to find where the `xmit_buf` variable is defined and used. My initial instinct is to drill down into the serial driver code, knowing that's where the core transmission logic resides. Specifically, I'm going to start by searching within the `drivers/tty/serial/` directory, which is the obvious place to look for serial port implementations. I'll begin my search with the `serial_core.c` file, since that's often where the common, or "core", functions are located. I'm expecting this file to contain the central data structures and functions that manage the serial port interaction, and that the `xmit_buf` variable is likely defined and used within its context. Time to get my search on!
|
| 39/2 |
2026/05/25 13:30 |
tool |
grepper |
0m
Args:
Results: map[Output:
Full output is too long, showing 500 out of 765 lines.
Use more precise expression if possible.
[drivers/crypto/omap-sham.c=214=struct omap_sham_dev {
--
drivers/crypto/omap-sham.c-223- u8 polling_mode;
drivers/crypto/omap-sham.c:224: u8 xmit_buf[BUFLEN] OMAP_ALIGNED;
drivers/crypto/omap-sham.c-225-
--
drivers/crypto/omap-sham.c=627=static int omap_sham_copy_sg_lists(struct omap_sham_reqctx *ctx,
--
drivers/crypto/omap-sham.c-649- if (ctx->bufcnt) {
drivers/crypto/omap-sham.c:650: sg_set_buf(tmp, ctx->dd->xmit_buf, ctx->bufcnt);
drivers/crypto/omap-sham.c-651- tmp = sg_next(tmp);
--
drivers/crypto/omap-sham.c=693=static int omap_sham_copy_sgs(struct omap_sham_reqctx *ctx,
--
drivers/crypto/omap-sham.c-708- if (ctx->bufcnt)
drivers/crypto/omap-sham.c:709: memcpy(buf, ctx->dd->xmit_buf, ctx->bufcnt);
drivers/crypto/omap-sham.c-710-
--
drivers/crypto/omap-sham.c=725=static int omap_sham_align_sgs(struct scatterlist *sg,
--
drivers/crypto/omap-sham.c-740- sg_init_table(rctx->sgl, 1);
drivers/crypto/omap-sham.c:741: sg_set_buf(rctx->sgl, rctx->dd->xmit_buf, bufcnt);
drivers/crypto/omap-sham.c-742- rctx->sg = rctx->sgl;
--
drivers/crypto/omap-sham.c-832- sg_init_table(rctx->sgl, 2);
drivers/crypto/omap-sham.c:833: sg_set_buf(rctx->sgl, rctx->dd->xmit_buf, rctx->bufcnt);
drivers/crypto/omap-sham.c-834- sg_chain(rctx->sgl, 2, sg);
--
drivers/crypto/omap-sham.c=843=static int omap_sham_prepare_request(struct crypto_engine *engine, void *areq)
--
drivers/crypto/omap-sham.c-883- if (rctx->bufcnt)
drivers/crypto/omap-sham.c:884: memcpy(rctx->dd->xmit_buf, rctx->buffer, rctx->bufcnt);
drivers/crypto/omap-sham.c-885-
--
drivers/crypto/s5p-sss.c=247=struct s5p_aes_ctx {
--
drivers/crypto/s5p-sss.c-287- * @hash_tasklet: New HASH request scheduling job.
drivers/crypto/s5p-sss.c:288: * @xmit_buf: Buffer for current HASH request transfer into SSS block.
drivers/crypto/s5p-sss.c-289- * @hash_req: Current request sending to SSS HASH block.
--
drivers/crypto/s5p-sss.c=295=struct s5p_aes_dev {
--
drivers/crypto/s5p-sss.c-323-
drivers/crypto/s5p-sss.c:324: u8 xmit_buf[BUFLEN];
drivers/crypto/s5p-sss.c-325- struct ahash_request *hash_req;
--
drivers/crypto/s5p-sss.c=963=static int s5p_hash_xmit_dma(struct s5p_aes_dev *dd, size_t length,
--
drivers/crypto/s5p-sss.c-997- *
drivers/crypto/s5p-sss.c:998: * Allocate new buffer, copy data for HASH into it. If there was xmit_buf
drivers/crypto/s5p-sss.c-999- * filled, copy it first, then copy data from sg into it. Prepare one sgl[0]
--
drivers/crypto/s5p-sss.c=1004=static int s5p_hash_copy_sgs(struct s5p_hash_reqctx *ctx,
--
drivers/crypto/s5p-sss.c-1020- if (ctx->bufcnt)
drivers/crypto/s5p-sss.c:1021: memcpy(buf, ctx->dd->xmit_buf, ctx->bufcnt);
drivers/crypto/s5p-sss.c-1022-
--
drivers/crypto/s5p-sss.c-1041- * Allocate new scatterlist table, copy data for HASH into it. If there was
drivers/crypto/s5p-sss.c:1042: * xmit_buf filled, prepare it first, then copy page, length and offset from
drivers/crypto/s5p-sss.c-1043- * source sg into it, adjusting begin and/or end for skip offset and
--
drivers/crypto/s5p-sss.c=1049=static int s5p_hash_copy_sg_lists(struct s5p_hash_reqctx *ctx,
--
drivers/crypto/s5p-sss.c-1071- if (ctx->bufcnt) {
drivers/crypto/s5p-sss.c:1072: sg_set_buf(tmp, ctx->dd->xmit_buf, ctx->bufcnt);
drivers/crypto/s5p-sss.c-1073- tmp = sg_next(tmp);
--
drivers/crypto/s5p-sss.c=1119=static int s5p_hash_prepare_sgs(struct s5p_hash_reqctx *ctx,
--
drivers/crypto/s5p-sss.c-1170- sg_init_table(ctx->sgl, 2);
drivers/crypto/s5p-sss.c:1171: sg_set_buf(ctx->sgl, ctx->dd->xmit_buf, ctx->bufcnt);
drivers/crypto/s5p-sss.c-1172- sg_chain(ctx->sgl, 2, sg);
--
drivers/crypto/s5p-sss.c=1193=static int s5p_hash_prepare_request(struct ahash_request *req, bool update)
--
drivers/crypto/s5p-sss.c-1224- if (ctx->bufcnt)
drivers/crypto/s5p-sss.c:1225: memcpy(ctx->dd->xmit_buf, ctx->buffer, ctx->bufcnt);
drivers/crypto/s5p-sss.c-1226-
--
drivers/crypto/s5p-sss.c-1237- /* copy hash_later bytes from end of req->src */
drivers/crypto/s5p-sss.c:1238: /* previous bytes are in xmit_buf, so no overwrite */
drivers/crypto/s5p-sss.c-1239- memcpy_from_sglist(ctx->buffer, req->src,
--
drivers/crypto/s5p-sss.c-1251- /* first update didn't fill up buffer */
drivers/crypto/s5p-sss.c:1252: memcpy_from_sglist(ctx->dd->xmit_buf, req->src,
drivers/crypto/s5p-sss.c-1253- 0, xmit_len);
--
drivers/crypto/s5p-sss.c-1256- sg_init_table(ctx->sgl, 1);
drivers/crypto/s5p-sss.c:1257: sg_set_buf(ctx->sgl, ctx->dd->xmit_buf, xmit_len);
drivers/crypto/s5p-sss.c-1258-
--
drivers/crypto/stm32/stm32-hash.c=193=struct stm32_hash_dev {
--
drivers/crypto/stm32/stm32-hash.c-199- phys_addr_t phys_base;
drivers/crypto/stm32/stm32-hash.c:200: u8 xmit_buf[HASH_BUFLEN] __aligned(sizeof(u32));
drivers/crypto/stm32/stm32-hash.c-201- u32 dma_mode;
--
drivers/crypto/stm32/stm32-hash.c=1102=static int stm32_hash_copy_sgs(struct stm32_hash_request_ctx *rctx,
--
drivers/crypto/stm32/stm32-hash.c-1117-
drivers/crypto/stm32/stm32-hash.c:1118: memcpy(buf, rctx->hdev->xmit_buf, state->bufcnt);
drivers/crypto/stm32/stm32-hash.c-1119-
--
drivers/crypto/stm32/stm32-hash.c=1134=static int stm32_hash_align_sgs(struct scatterlist *sg,
--
drivers/crypto/stm32/stm32-hash.c-1151- sg_init_table(rctx->sgl, 1);
drivers/crypto/stm32/stm32-hash.c:1152: sg_set_buf(rctx->sgl, rctx->hdev->xmit_buf, bufcnt);
drivers/crypto/stm32/stm32-hash.c-1153- rctx->sg = rctx->sgl;
--
drivers/crypto/stm32/stm32-hash.c-1241- sg_init_table(rctx->sgl, 2);
drivers/crypto/stm32/stm32-hash.c:1242: sg_set_buf(rctx->sgl, rctx->hdev->xmit_buf, state->bufcnt);
drivers/crypto/stm32/stm32-hash.c-1243- sg_chain(rctx->sgl, 2, sg);
--
drivers/crypto/stm32/stm32-hash.c=1252=static int stm32_hash_prepare_request(struct ahash_request *req)
--
drivers/crypto/stm32/stm32-hash.c-1301- /* copy buffer in a temporary one that is used for sg alignment */
drivers/crypto/stm32/stm32-hash.c:1302: memcpy(hdev->xmit_buf, state->buffer, state->bufcnt);
drivers/crypto/stm32/stm32-hash.c-1303-
--
drivers/ipack/devices/ipoctal.c=201=static void ipoctal_irq_tx(struct ipoctal_channel *channel)
--
drivers/ipack/devices/ipoctal.c-209- spin_lock(&channel->lock);
drivers/ipack/devices/ipoctal.c:210: value = channel->tty_port.xmit_buf[*pointer_write];
drivers/ipack/devices/ipoctal.c-211- iowrite8(value, &channel->regs->w.thr);
--
drivers/ipack/devices/ipoctal.c=272=static int ipoctal_inst_slot(struct ipoctal *ipoctal, unsigned int bus_nr,
--
drivers/ipack/devices/ipoctal.c-397- tty_port_init(&channel->tty_port);
drivers/ipack/devices/ipoctal.c:398: res = tty_port_alloc_xmit_buf(&channel->tty_port);
drivers/ipack/devices/ipoctal.c-399- if (res)
--
drivers/ipack/devices/ipoctal.c-411- dev_err(&ipoctal->dev->dev, "Failed to register tty device.\n");
drivers/ipack/devices/ipoctal.c:412: tty_port_free_xmit_buf(&channel->tty_port);
drivers/ipack/devices/ipoctal.c-413- tty_port_destroy(&channel->tty_port);
--
drivers/ipack/devices/ipoctal.c=437=static inline size_t ipoctal_copy_write_buffer(struct ipoctal_channel *channel,
--
drivers/ipack/devices/ipoctal.c-447- spin_lock_irqsave(&channel->lock, flags);
drivers/ipack/devices/ipoctal.c:448: channel->tty_port.xmit_buf[*pointer_read] = buf[i];
drivers/ipack/devices/ipoctal.c-449- *pointer_read = (*pointer_read + 1) % PAGE_SIZE;
--
drivers/ipack/devices/ipoctal.c=708=static void __ipoctal_remove(struct ipoctal *ipoctal)
--
drivers/ipack/devices/ipoctal.c-720- tty_unregister_device(ipoctal->tty_drv, i);
drivers/ipack/devices/ipoctal.c:721: tty_port_free_xmit_buf(&channel->tty_port);
drivers/ipack/devices/ipoctal.c-722- tty_port_destroy(&channel->tty_port);
--
drivers/net/ethernet/i825xx/sun3_82586.c=145=struct priv
--
drivers/net/ethernet/i825xx/sun3_82586.c-154- volatile struct scb_struct *scb; /* volatile is important */
drivers/net/ethernet/i825xx/sun3_82586.c:155: volatile struct tbd_struct *xmit_buffs[NUM_XMIT_BUFFS];
drivers/net/ethernet/i825xx/sun3_82586.c-156- volatile struct transmit_cmd_struct *xmit_cmds[NUM_XMIT_BUFFS];
--
drivers/net/ethernet/i825xx/sun3_82586.c=401=static int init586(struct net_device *dev)
--
drivers/net/ethernet/i825xx/sun3_82586.c-581- ptr = (char *) ptr + XMIT_BUFF_SIZE;
drivers/net/ethernet/i825xx/sun3_82586.c:582: p->xmit_buffs[i] = (struct tbd_struct *)ptr; /* TBD */
drivers/net/ethernet/i825xx/sun3_82586.c-583- ptr = (char *) ptr + sizeof(struct tbd_struct);
--
drivers/net/ethernet/i825xx/sun3_82586.c-589- memset((char *)(p->xmit_cmds[i]) ,0, sizeof(struct transmit_cmd_struct));
drivers/net/ethernet/i825xx/sun3_82586.c:590: memset((char *)(p->xmit_buffs[i]),0, sizeof(struct tbd_struct));
drivers/net/ethernet/i825xx/sun3_82586.c-591- p->xmit_cmds[i]->cmd_link = make16(p->nop_cmds[(i+1)%NUM_XMIT_BUFFS]);
--
drivers/net/ethernet/i825xx/sun3_82586.c-593- p->xmit_cmds[i]->cmd_cmd = swab16(CMD_XMIT | CMD_INT);
drivers/net/ethernet/i825xx/sun3_82586.c:594: p->xmit_cmds[i]->tbd_offset = make16((p->xmit_buffs[i]));
drivers/net/ethernet/i825xx/sun3_82586.c:595: p->xmit_buffs[i]->next = 0xffff;
drivers/net/ethernet/i825xx/sun3_82586.c:596: p->xmit_buffs[i]->buffer = make24((p->xmit_cbuffs[i]));
drivers/net/ethernet/i825xx/sun3_82586.c-597- }
--
drivers/net/ethernet/i825xx/sun3_82586.c=1004=sun3_82586_send_packet(struct sk_buff *skb, struct net_device *dev)
--
drivers/net/ethernet/i825xx/sun3_82586.c-1047-
drivers/net/ethernet/i825xx/sun3_82586.c:1048: p->xmit_buffs[0]->size = swab16(TBD_LAST | len);
drivers/net/ethernet/i825xx/sun3_82586.c-1049- for(i=0;i<16;i++)
--
drivers/net/ethernet/i825xx/sun3_82586.c-1073- next_nop = (p->nop_point + 1) & 0x1;
drivers/net/ethernet/i825xx/sun3_82586.c:1074: p->xmit_buffs[0]->size = swab16(TBD_LAST | len);
drivers/net/ethernet/i825xx/sun3_82586.c-1075-
--
drivers/net/ethernet/i825xx/sun3_82586.c-1084-#else
drivers/net/ethernet/i825xx/sun3_82586.c:1085: p->xmit_buffs[p->xmit_count]->size = swab16(TBD_LAST | len);
drivers/net/ethernet/i825xx/sun3_82586.c-1086- if( (next_nop = p->xmit_count + 1) == NUM_XMIT_BUFFS )
--
drivers/net/wireless/mediatek/mt76/mt76.h=685=struct mt76_sdio {
--
drivers/net/wireless/mediatek/mt76/mt76.h-690-
drivers/net/wireless/mediatek/mt76/mt76.h:691: u8 *xmit_buf;
drivers/net/wireless/mediatek/mt76/mt76.h:692: u32 xmit_buf_sz;
drivers/net/wireless/mediatek/mt76/mt76.h-693-
--
drivers/net/wireless/mediatek/mt76/sdio.c=635=int mt76s_init(struct mt76_dev *dev, struct sdio_func *func,
--
drivers/net/wireless/mediatek/mt76/sdio.c-667- func->card->host->max_blk_count);
drivers/net/wireless/mediatek/mt76/sdio.c:668: dev->sdio.xmit_buf_sz = min_t(u32, host_max_cap, MT76S_XMIT_BUF_SZ);
drivers/net/wireless/mediatek/mt76/sdio.c:669: dev->sdio.xmit_buf = devm_kmalloc(dev->dev, dev->sdio.xmit_buf_sz,
drivers/net/wireless/mediatek/mt76/sdio.c-670- GFP_KERNEL);
drivers/net/wireless/mediatek/mt76/sdio.c:671: if (!dev->sdio.xmit_buf)
drivers/net/wireless/mediatek/mt76/sdio.c-672- err = -ENOMEM;
--
drivers/net/wireless/mediatek/mt76/sdio_txrx.c=245=static int mt76s_tx_run_queue(struct mt76_dev *dev, struct mt76_queue *q)
--
drivers/net/wireless/mediatek/mt76/sdio_txrx.c-275- pad = roundup(e->skb->len, 4) - e->skb->len;
drivers/net/wireless/mediatek/mt76/sdio_txrx.c:276: if (len + e->skb->len + pad + 4 > dev->sdio.xmit_buf_sz)
drivers/net/wireless/mediatek/mt76/sdio_txrx.c-277- break;
--
drivers/net/wireless/mediatek/mt76/sdio_txrx.c-282-
drivers/net/wireless/mediatek/mt76/sdio_txrx.c:283: memcpy(sdio->xmit_buf + len, e->skb->data, skb_headlen(e->skb));
drivers/net/wireless/mediatek/mt76/sdio_txrx.c-284- len += skb_headlen(e->skb);
--
drivers/net/wireless/mediatek/mt76/sdio_txrx.c-287- skb_walk_frags(e->skb, iter) {
drivers/net/wireless/mediatek/mt76/sdio_txrx.c:288: memcpy(sdio->xmit_buf + len, iter->data, iter->len);
drivers/net/wireless/mediatek/mt76/sdio_txrx.c-289- len += iter->len;
--
drivers/net/wireless/mediatek/mt76/sdio_txrx.c-293- if (unlikely(pad)) {
drivers/net/wireless/mediatek/mt76/sdio_txrx.c:294: memset(sdio->xmit_buf + len, 0, pad);
drivers/net/wireless/mediatek/mt76/sdio_txrx.c-295- len += pad;
--
drivers/net/wireless/mediatek/mt76/sdio_txrx.c-302- if (nframes) {
drivers/net/wireless/mediatek/mt76/sdio_txrx.c:303: memset(sdio->xmit_buf + len, 0, 4);
drivers/net/wireless/mediatek/mt76/sdio_txrx.c:304: err = __mt76s_xmit_queue(dev, sdio->xmit_buf, len + 4);
drivers/net/wireless/mediatek/mt76/sdio_txrx.c-305- if (err)
--
drivers/staging/rtl8723bs/core/rtw_mlme_ext.c=1888=static struct xmit_frame *_alloc_mgtxmitframe(struct xmit_priv *pxmitpriv, bool once)
--
drivers/staging/rtl8723bs/core/rtw_mlme_ext.c-1890- struct xmit_frame *pmgntframe;
drivers/staging/rtl8723bs/core/rtw_mlme_ext.c:1891: struct xmit_buf *pxmitbuf;
drivers/staging/rtl8723bs/core/rtw_mlme_ext.c-1892-
--
drivers/staging/rtl8723bs/core/rtw_mlme_ext.c=1994=s32 dump_mgntframe_and_wait(struct adapter *padapter, struct xmit_frame *pmgntframe, int timeout_ms)
--
drivers/staging/rtl8723bs/core/rtw_mlme_ext.c-1998- struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
drivers/staging/rtl8723bs/core/rtw_mlme_ext.c:1999: struct xmit_buf *pxmitbuf = pmgntframe->pxmitbuf;
drivers/staging/rtl8723bs/core/rtw_mlme_ext.c-2000- struct submit_ctx sctx;
--
drivers/staging/rtl8723bs/core/rtw_xmit.c=34=s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter)
--
drivers/staging/rtl8723bs/core/rtw_xmit.c-36- int i;
drivers/staging/rtl8723bs/core/rtw_xmit.c:37: struct xmit_buf *pxmitbuf;
drivers/staging/rtl8723bs/core/rtw_xmit.c-38- struct xmit_frame *pxframe;
--
drivers/staging/rtl8723bs/core/rtw_xmit.c-103-
drivers/staging/rtl8723bs/core/rtw_xmit.c:104: /* init xmit_buf */
drivers/staging/rtl8723bs/core/rtw_xmit.c-105- INIT_LIST_HEAD(&pxmitpriv->free_xmitbuf_queue.queue);
--
drivers/staging/rtl8723bs/core/rtw_xmit.c-109-
drivers/staging/rtl8723bs/core/rtw_xmit.c:110: pxmitpriv->pallocated_xmitbuf = vzalloc(NR_XMITBUFF * sizeof(struct xmit_buf) + 4);
drivers/staging/rtl8723bs/core/rtw_xmit.c-111-
--
drivers/staging/rtl8723bs/core/rtw_xmit.c-118-
drivers/staging/rtl8723bs/core/rtw_xmit.c:119: pxmitbuf = (struct xmit_buf *)pxmitpriv->pxmitbuf;
drivers/staging/rtl8723bs/core/rtw_xmit.c-120-
--
drivers/staging/rtl8723bs/core/rtw_xmit.c-192-
drivers/staging/rtl8723bs/core/rtw_xmit.c:193: pxmitpriv->pallocated_xmit_extbuf = vzalloc(NR_XMIT_EXTBUFF * sizeof(struct xmit_buf) + 4);
drivers/staging/rtl8723bs/core/rtw_xmit.c-194-
--
drivers/staging/rtl8723bs/core/rtw_xmit.c-201-
drivers/staging/rtl8723bs/core/rtw_xmit.c:202: pxmitbuf = (struct xmit_buf *)pxmitpriv->pxmit_extbuf;
drivers/staging/rtl8723bs/core/rtw_xmit.c-203-
--
drivers/staging/rtl8723bs/core/rtw_xmit.c=275=void _rtw_free_xmit_priv(struct xmit_priv *pxmitpriv)
--
drivers/staging/rtl8723bs/core/rtw_xmit.c-279- struct xmit_frame *pxmitframe = (struct xmit_frame *)pxmitpriv->pxmit_frame_buf;
drivers/staging/rtl8723bs/core/rtw_xmit.c:280: struct xmit_buf *pxmitbuf = (struct xmit_buf *)pxmitpriv->pxmitbuf;
drivers/staging/rtl8723bs/core/rtw_xmit.c-281-
--
drivers/staging/rtl8723bs/core/rtw_xmit.c-313- /* free xmit extension buff */
drivers/staging/rtl8723bs/core/rtw_xmit.c:314: pxmitbuf = (struct xmit_buf *)pxmitpriv->pxmit_extbuf;
drivers/staging/rtl8723bs/core/rtw_xmit.c-315- for (i = 0; i < NR_XMIT_EXTBUFF; i++) {
--
drivers/staging/rtl8723bs/core/rtw_xmit.c=1406=void rtw_count_tx_stats(struct adapter *padapter, struct xmit_frame *pxmitframe, int sz)
--
drivers/staging/rtl8723bs/core/rtw_xmit.c-1433-
drivers/staging/rtl8723bs/core/rtw_xmit.c:1434:static struct xmit_buf *__rtw_alloc_cmd_xmitbuf(struct xmit_priv *pxmitpriv,
drivers/staging/rtl8723bs/core/rtw_xmit.c-1435- enum cmdbuf_type buf_type)
drivers/staging/rtl8723bs/core/rtw_xmit.c-1436-{
drivers/staging/rtl8723bs/core/rtw_xmit.c:1437: struct xmit_buf *pxmitbuf = NULL;
drivers/staging/rtl8723bs/core/rtw_xmit.c-1438-
--
drivers/staging/rtl8723bs/core/rtw_xmit.c=1455=struct xmit_frame *__rtw_alloc_cmdxmitframe(struct xmit_priv *pxmitpriv,
--
drivers/staging/rtl8723bs/core/rtw_xmit.c-1458- struct xmit_frame *pcmdframe;
drivers/staging/rtl8723bs/core/rtw_xmit.c:1459: struct xmit_buf *pxmitbuf;
drivers/staging/rtl8723bs/core/rtw_xmit.c-1460-
--
drivers/staging/rtl8723bs/core/rtw_xmit.c-1481-
drivers/staging/rtl8723bs/core/rtw_xmit.c:1482:struct xmit_buf *rtw_alloc_xmitbuf_ext(struct xmit_priv *pxmitpriv)
drivers/staging/rtl8723bs/core/rtw_xmit.c-1483-{
drivers/staging/rtl8723bs/core/rtw_xmit.c-1484- unsigned long irqL;
drivers/staging/rtl8723bs/core/rtw_xmit.c:1485: struct xmit_buf *pxmitbuf = NULL;
drivers/staging/rtl8723bs/core/rtw_xmit.c-1486- struct list_head *plist, *phead;
--
drivers/staging/rtl8723bs/core/rtw_xmit.c-1497-
drivers/staging/rtl8723bs/core/rtw_xmit.c:1498: pxmitbuf = container_of(plist, struct xmit_buf, list);
drivers/staging/rtl8723bs/core/rtw_xmit.c-1499-
--
drivers/staging/rtl8723bs/core/rtw_xmit.c-1521-
drivers/staging/rtl8723bs/core/rtw_xmit.c:1522:s32 rtw_free_xmitbuf_ext(struct xmit_priv *pxmitpriv, struct xmit_buf *pxmitbuf)
drivers/staging/rtl8723bs/core/rtw_xmit.c-1523-{
--
drivers/staging/rtl8723bs/core/rtw_xmit.c-1541-
drivers/staging/rtl8723bs/core/rtw_xmit.c:1542:struct xmit_buf *rtw_alloc_xmitbuf(struct xmit_priv *pxmitpriv)
drivers/staging/rtl8723bs/core/rtw_xmit.c-1543-{
drivers/staging/rtl8723bs/core/rtw_xmit.c-1544- unsigned long irqL;
drivers/staging/rtl8723bs/core/rtw_xmit.c:1545: struct xmit_buf *pxmitbuf = NULL;
drivers/staging/rtl8723bs/core/rtw_xmit.c-1546- struct list_head *plist, *phead;
--
drivers/staging/rtl8723bs/core/rtw_xmit.c-1557-
drivers/staging/rtl8723bs/core/rtw_xmit.c:1558: pxmitbuf = container_of(plist, struct xmit_buf, list);
drivers/staging/rtl8723bs/core/rtw_xmit.c-1559-
--
drivers/staging/rtl8723bs/core/rtw_xmit.c-1582-
drivers/staging/rtl8723bs/core/rtw_xmit.c:1583:s32 rtw_free_xmitbuf(struct xmit_priv *pxmitpriv, struct xmit_buf *pxmitbuf)
drivers/staging/rtl8723bs/core/rtw_xmit.c-1584-{
--
drivers/staging/rtl8723bs/core/rtw_xmit.c=2345=void xmit_delivery_enabled_frames(struct adapter *padapter, struct sta_info *psta)
--
drivers/staging/rtl8723bs/core/rtw_xmit.c-2408-
drivers/staging/rtl8723bs/core/rtw_xmit.c:2409:void enqueue_pending_xmitbuf(struct xmit_priv *pxmitpriv, struct xmit_buf *pxmitbuf)
drivers/staging/rtl8723bs/core/rtw_xmit.c-2410-{
--
drivers/staging/rtl8723bs/core/rtw_xmit.c-2423-
drivers/staging/rtl8723bs/core/rtw_xmit.c:2424:void enqueue_pending_xmitbuf_to_head(struct xmit_priv *pxmitpriv, struct xmit_buf *pxmitbuf)
drivers/staging/rtl8723bs/core/rtw_xmit.c-2425-{
--
drivers/staging/rtl8723bs/core/rtw_xmit.c-2435-
drivers/staging/rtl8723bs/core/rtw_xmit.c:2436:struct xmit_buf *dequeue_pending_xmitbuf(struct xmit_priv *pxmitpriv)
drivers/staging/rtl8723bs/core/rtw_xmit.c-2437-{
drivers/staging/rtl8723bs/core/rtw_xmit.c:2438: struct xmit_buf *pxmitbuf;
drivers/staging/rtl8723bs/core/rtw_xmit.c-2439- struct __queue *pqueue;
--
drivers/staging/rtl8723bs/core/rtw_xmit.c-2450- plist = get_next(phead);
drivers/staging/rtl8723bs/core/rtw_xmit.c:2451: pxmitbuf = container_of(plist, struct xmit_buf, list);
drivers/staging/rtl8723bs/core/rtw_xmit.c-2452- list_del_init(&pxmitbuf->list);
--
drivers/staging/rtl8723bs/core/rtw_xmit.c-2459-
drivers/staging/rtl8723bs/core/rtw_xmit.c:2460:struct xmit_buf *dequeue_pending_xmitbuf_under_survey(struct xmit_priv *pxmitpriv)
drivers/staging/rtl8723bs/core/rtw_xmit.c-2461-{
drivers/staging/rtl8723bs/core/rtw_xmit.c:2462: struct xmit_buf *pxmitbuf;
drivers/staging/rtl8723bs/core/rtw_xmit.c-2463- struct __queue *pqueue;
--
drivers/staging/rtl8723bs/core/rtw_xmit.c-2480-
drivers/staging/rtl8723bs/core/rtw_xmit.c:2481: pxmitbuf = container_of(plist, struct xmit_buf, list);
drivers/staging/rtl8723bs/core/rtw_xmit.c-2482-
--
drivers/staging/rtl8723bs/hal/hal_intf.c=268=s32 rtw_hal_xmit_thread_handler(struct adapter *padapter)
drivers/staging/rtl8723bs/hal/hal_intf.c-269-{
drivers/staging/rtl8723bs/hal/hal_intf.c:270: return rtl8723bs_xmit_buf_handler(padapter);
drivers/staging/rtl8723bs/hal/hal_intf.c-271-}
--
drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c=36=static s32 rtl8723_dequeue_writeport(struct adapter *padapter)
--
drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c-40- struct dvobj_priv *pdvobjpriv = adapter_to_dvobj(padapter);
drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c:41: struct xmit_buf *pxmitbuf;
drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c-42- struct adapter *pri_padapter = padapter;
--
drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c-120- */
drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c:121:s32 rtl8723bs_xmit_buf_handler(struct adapter *padapter)
drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c-122-{
--
drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c=166=static s32 xmit_xmitframes(struct adapter *padapter, struct xmit_priv *pxmitpriv)
--
drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c-175- struct __queue *pframe_queue;
drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c:176: struct xmit_buf *pxmitbuf;
drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c-177- u32 txlen, max_xmit_len;
--
drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c-231-
drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c:232: /* check xmit_buf size enough or not */
drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c-233- txlen = txdesc_size + rtw_wlan_pkt_size(pxmitframe);
--
drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c-259- netdev_err(padapter->pnetdev,
drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c:260: "%s: xmit_buf is not enough!\n",
drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c-261- __func__);
--
drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c-322-
drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c:323: /* dump xmit_buf to hw tx fifo */
drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c-324- if (pxmitbuf) {
--
drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c=423=s32 rtl8723bs_mgnt_xmit(
--
drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c-428- struct pkt_attrib *pattrib = &pmgntframe->attrib;
drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c:429: struct xmit_buf *pxmitbuf = pmgntframe->pxmitbuf;
drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c-430- struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
--
drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c=545=void rtl8723bs_free_xmit_priv(struct adapter *padapter)
--
drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c-547- struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c:548: struct xmit_buf *pxmitbuf;
drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c-549- struct __queue *pqueue = &pxmitpriv->pending_xmitbuf_queue;
--
drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c-570-
drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c:571: pxmitbuf = container_of(plist, struct xmit_buf, list);
drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c-572- rtw_free_xmitframe(pxmitpriv, (struct xmit_frame *)pxmitbuf->priv_data);
--
drivers/staging/rtl8723bs/hal/sdio_ops.c=429=static u32 sdio_write_port(
--
drivers/staging/rtl8723bs/hal/sdio_ops.c-438- s32 err;
drivers/staging/rtl8723bs/hal/sdio_ops.c:439: struct xmit_buf *xmitbuf = (struct xmit_buf *)mem;
drivers/staging/rtl8723bs/hal/sdio_ops.c-440-
--
drivers/staging/rtl8723bs/include/rtl8723b_xmit.h=414=s32 rtl8723bs_hal_xmitframe_enqueue(struct adapter *padapter, struct xmit_frame *pxmitframe);
drivers/staging/rtl8723bs/include/rtl8723b_xmit.h:415:s32 rtl8723bs_xmit_buf_handler(struct adapter *padapter);
drivers/staging/rtl8723bs/include/rtl8723b_xmit.h-416-int rtl8723bs_xmit_thread(void *context);
--
drivers/staging/rtl8723bs/include/rtw_xmit.h=229=void rtw_sctx_done(struct submit_ctx **sctx);
drivers/staging/rtl8723bs/include/rtw_xmit.h-230-
drivers/staging/rtl8723bs/include/rtw_xmit.h:231:struct xmit_buf {
drivers/staging/rtl8723bs/include/rtw_xmit.h-232- struct list_head list;
--
drivers/staging/rtl8723bs/include/rtw_xmit.h=265=struct xmit_frame {
--
drivers/staging/rtl8723bs/include/rtw_xmit.h-277-
drivers/staging/rtl8723bs/include/rtw_xmit.h:278: struct xmit_buf *pxmitbuf;
drivers/staging/rtl8723bs/include/rtw_xmit.h-279-
--
drivers/staging/rtl8723bs/include/rtw_xmit.h=338=struct xmit_priv {
--
drivers/staging/rtl8723bs/include/rtw_xmit.h-407-
drivers/staging/rtl8723bs/include/rtw_xmit.h:408: struct xmit_buf pcmd_xmitbuf[CMDBUF_MAX];
drivers/staging/rtl8723bs/include/rtw_xmit.h-409-
--
drivers/staging/rtl8723bs/include/rtw_xmit.h=419=extern struct xmit_frame *__rtw_alloc_cmdxmitframe(struct xmit_priv *pxmitpriv,
--
drivers/staging/rtl8723bs/include/rtw_xmit.h-423-
drivers/staging/rtl8723bs/include/rtw_xmit.h:424:extern struct xmit_buf *rtw_alloc_xmitbuf_ext(struct xmit_priv *pxmitpriv);
drivers/staging/rtl8723bs/include/rtw_xmit.h:425:extern s32 rtw_free_xmitbuf_ext(struct xmit_priv *pxmitpriv, struct xmit_buf *pxmitbuf);
drivers/staging/rtl8723bs/include/rtw_xmit.h-426-
drivers/staging/rtl8723bs/include/rtw_xmit.h:427:extern struct xmit_buf *rtw_alloc_xmitbuf(struct xmit_priv *pxmitpriv);
drivers/staging/rtl8723bs/include/rtw_xmit.h:428:extern s32 rtw_free_xmitbuf(struct xmit_priv *pxmitpriv, struct xmit_buf *pxmitbuf);
drivers/staging/rtl8723bs/include/rtw_xmit.h-429-
--
drivers/staging/rtl8723bs/include/rtw_xmit.h=474=u8 qos_acm(u8 acm_mask, u8 priority);
drivers/staging/rtl8723bs/include/rtw_xmit.h-475-
drivers/staging/rtl8723bs/include/rtw_xmit.h:476:void enqueue_pending_xmitbuf(struct xmit_priv *pxmitpriv, struct xmit_buf *pxmitbuf);
drivers/staging/rtl8723bs/include/rtw_xmit.h:477:void enqueue_pending_xmitbuf_to_head(struct xmit_priv *pxmitpriv, struct xmit_buf *pxmitbuf);
drivers/staging/rtl8723bs/include/rtw_xmit.h:478:struct xmit_buf *dequeue_pending_xmitbuf(struct xmit_priv *pxmitpriv);
drivers/staging/rtl8723bs/include/rtw_xmit.h:479:struct xmit_buf *dequeue_pending_xmitbuf_under_survey(struct xmit_priv *pxmitpriv);
drivers/staging/rtl8723bs/include/rtw_xmit.h-480-signed int check_pending_xmitbuf(struct xmit_priv *pxmitpriv);
--
drivers/staging/rtl8723bs/include/rtw_xmit.h=486=void rtw_ack_tx_done(struct xmit_priv *pxmitpriv, int status);
drivers/staging/rtl8723bs/include/rtw_xmit.h-487-
drivers/staging/rtl8723bs/include/rtw_xmit.h:488:/* include after declaring struct xmit_buf, in order to avoid warning */
drivers/staging/rtl8723bs/include/rtw_xmit.h-489-#include <xmit_osdep.h>
--
drivers/staging/rtl8723bs/include/xmit_osdep.h=25=struct xmit_frame;
drivers/staging/rtl8723bs/include/xmit_osdep.h:26:struct xmit_buf;
drivers/staging/rtl8723bs/include/xmit_osdep.h-27-
--
drivers/staging/rtl8723bs/include/xmit_osdep.h=31=void rtw_os_xmit_schedule(struct adapter *padapter);
drivers/staging/rtl8723bs/include/xmit_osdep.h-32-
drivers/staging/rtl8723bs/include/xmit_osdep.h:33:int rtw_os_xmit_resource_alloc(struct adapter *padapter, struct xmit_buf *pxmitbuf, u32 alloc_sz, u8 flag);
drivers/staging/rtl8723bs/include/xmit_osdep.h:34:void rtw_os_xmit_resource_free(struct adapter *padapter, struct xmit_buf *pxmitbuf, u32 free_sz, u8 flag);
drivers/staging/rtl8723bs/include/xmit_osdep.h-35-
--
drivers/staging/rtl8723bs/os_dep/xmit_linux.c=42=signed int rtw_endofpktfile(struct pkt_file *pfile)
--
drivers/staging/rtl8723bs/os_dep/xmit_linux.c-48-
drivers/staging/rtl8723bs/os_dep/xmit_linux.c:49:int rtw_os_xmit_resource_alloc(struct adapter *padapter, struct xmit_buf *pxmitbuf, u32 alloc_sz, u8 flag)
drivers/staging/rtl8723bs/os_dep/xmit_linux.c-50-{
--
drivers/staging/rtl8723bs/os_dep/xmit_linux.c-61-
drivers/staging/rtl8723bs/os_dep/xmit_linux.c:62:void rtw_os_xmit_resource_free(struct adapter *padapter, struct xmit_buf *pxmitbuf, u32 free_sz, u8 flag)
drivers/staging/rtl8723bs/os_dep/xmit_linux.c-63-{
--
drivers/tty/mips_ejtag_fdc.c=84=struct mips_ejtag_fdc_tty;
--
drivers/tty/mips_ejtag_fdc.c-93- * @rx_buf: Read buffer.
drivers/tty/mips_ejtag_fdc.c:94: * @xmit_lock: Lock for xmit_*, and port.xmit_buf.
drivers/tty/mips_ejtag_fdc.c-95- * This protects between user context and kernel thread.
--
drivers/tty/mips_ejtag_fdc.c=415=static unsigned int mips_ejtag_fdc_put_chan(struct mips_ejtag_fdc_tty *priv,
--
drivers/tty/mips_ejtag_fdc.c-427- if (dport->xmit_cnt) {
drivers/tty/mips_ejtag_fdc.c:428: ptrs[0] = dport->port.xmit_buf + dport->xmit_tail;
drivers/tty/mips_ejtag_fdc.c-429- sizes[0] = min_t(unsigned int,
--
drivers/tty/mips_ejtag_fdc.c-431- dport->xmit_cnt);
drivers/tty/mips_ejtag_fdc.c:432: ptrs[1] = dport->port.xmit_buf;
drivers/tty/mips_ejtag_fdc.c-433- sizes[1] = dport->xmit_cnt - sizes[0];
--
drivers/tty/mips_ejtag_fdc.c=696=static int mips_ejtag_fdc_tty_port_activate(struct tty_port *port,
--
drivers/tty/mips_ejtag_fdc.c-703- /* Allocate the buffer we use for writing data */
drivers/tty/mips_ejtag_fdc.c:704: if (tty_port_alloc_xmit_buf(port) < 0)
drivers/tty/mips_ejtag_fdc.c-705- goto err;
--
drivers/tty/mips_ejtag_fdc.c-717-err_free_xmit:
drivers/tty/mips_ejtag_fdc.c:718: tty_port_free_xmit_buf(port);
drivers/tty/mips_ejtag_fdc.c-719-err:
--
drivers/tty/mips_ejtag_fdc.c=723=static void mips_ejtag_fdc_tty_port_shutdown(struct tty_port *port)
--
drivers/tty/mips_ejtag_fdc.c-751- /* Free the write buffer */
drivers/tty/mips_ejtag_fdc.c:752: tty_port_free_xmit_buf(port);
drivers/tty/mips_ejtag_fdc.c-753-}
--
drivers/tty/mips_ejtag_fdc.c=800=static ssize_t mips_ejtag_fdc_tty_write(struct tty_struct *tty, const u8 *buf,
--
drivers/tty/mips_ejtag_fdc.c-825- block = min(count, (int)(priv->xmit_size - dport->xmit_head));
]
]
|
| 40/2 |
2026/05/25 13:30 |
llm |
expert |
1m
Model:
Tokens:
input: 59045
output: 48
thoughts: 58
Thoughts: Okay, here's my interpretation of that thought process, tailored for an expert audience:
**Analyzing `tty_port_alloc_xmit_buf`**
Right, so `tty_port_alloc_xmit_buf` is the one allocating the `xmit_buf` and initializing the `xmit_fifo`. Pretty standard stuff, but let's just make sure it's doing everything correctly, especially in terms of handling potential edge cases or resource contention. I need to be certain there aren't any subtle memory leaks or race conditions lurking in there. It's time to check the actual implementation. I'll take a look at `drivers/tty/tty_port.c` to see how it's actually implemented. I want to see how it's interfacing with the underlying hardware.
|
| 41/2 |
2026/05/25 13:31 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/tty/tty_port.c IncludeLines:true Name:tty_port_alloc_xmit_buf]
Results: map[SourceCode: 221: int tty_port_alloc_xmit_buf(struct tty_port *port)
222: {
223: /* We may sleep in get_zeroed_page() */
224: guard(mutex)(&port->buf_mutex);
225:
226: if (port->xmit_buf)
227: return 0;
228:
229: port->xmit_buf = (u8 *)get_zeroed_page(GFP_KERNEL);
230: if (port->xmit_buf == NULL)
231: return -ENOMEM;
232:
233: kfifo_init(&port->xmit_fifo, port->xmit_buf, PAGE_SIZE);
234:
235: return 0;
236: }
SourceFile:drivers/tty/tty_port.c]
|
| 42/2 |
2026/05/25 13:31 |
llm |
expert |
0m
Model:
Tokens:
input: 59592
output: 46
thoughts: 239
Thoughts: **Debugging a TX Loop in the Serial Driver**
Okay, so I've got this nasty infinite loop in the `handle_tx` function. My initial hunch, and it seems confirmed by the code, is that this is all to do with how the transmit buffer (`xmit_buf`) is allocated and initialized, and the state of the transmit FIFO (`xmit_fifo`). From what I can tell, `tty_port_alloc_xmit_buf` is the key. If it *is* called, both `xmit_buf` is properly allocated, and the `xmit_fifo` is initialized. If that allocation doesn't happen, `xmit_buf` ends up as NULL, and the FIFO's state is undefined.
Now, if `xmit_fifo` *is* uninitialized, the `kfifo_avail` call will report that there's one byte available. This seems correct because the mask is zero. So, `uart_write_room` returns 1 (it's available). But then, `uart_write` will return 0, because, as expected, `xmit_buf` is NULL. This is the culprit: `handle_tx` thinks the buffer is available but it *isn't* available!
The obvious question then becomes *why* is `xmit_buf` NULL? The standard flow dictates that `tty_port_alloc_xmit_buf` should be called during a tty open. But I suspect this `caif_serial` interface is not behaving in a standard fashion, and I need to confirm how `caif_serial` is integrated with the TTY layer. It's a line discipline *or* a driver, and I think it may be a net device driver that uses a TTY. Let's dig deeper and see how `caif_serial` obtains the TTY instance. That's the key to understanding why we're not allocating the buffer.
|
| 43/2 |
2026/05/25 13:31 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/net/caif/caif_serial.c IncludeLines:true Name:ldisc_open]
Results: map[SourceCode: 308: static int ldisc_open(struct tty_struct *tty)
309: {
310: struct ser_device *ser;
311: struct net_device *dev;
312: char name[64];
313: int result;
314:
315: /* No write no play */
316: if (tty->ops->write == NULL)
317: return -EOPNOTSUPP;
318: if (!capable(CAP_SYS_ADMIN) && !capable(CAP_SYS_TTY_CONFIG))
319: return -EPERM;
320:
321: /* release devices to avoid name collision */
322: ser_release(NULL);
323:
324: result = snprintf(name, sizeof(name), "cf%s", tty->name);
325: if (result >= IFNAMSIZ)
326: return -EINVAL;
327: dev = alloc_netdev(sizeof(*ser), name, NET_NAME_UNKNOWN,
328: caifdev_setup);
329: if (!dev)
330: return -ENOMEM;
331:
332: ser = netdev_priv(dev);
333: ser->tty = tty_kref_get(tty);
334: ser->dev = dev;
335: debugfs_init(ser, tty);
336: tty->receive_room = 4096;
337: tty->disc_data = ser;
338: set_bit(TTY_DO_WRITE_WAKEUP, &tty->flags);
339: rtnl_lock();
340: result = register_netdevice(dev);
341: if (result) {
342: tty_kref_put(tty);
343: rtnl_unlock();
344: free_netdev(dev);
345: return -ENODEV;
346: }
347:
348: spin_lock(&ser_lock);
349: list_add(&ser->node, &ser_list);
350: spin_unlock(&ser_lock);
351: rtnl_unlock();
352: netif_stop_queue(dev);
353: update_tty_status(ser);
354: return 0;
355: }
SourceFile:drivers/net/caif/caif_serial.c]
|
| 44/2 |
2026/05/25 13:31 |
llm |
expert |
0m
Model:
Tokens:
input: 61023
output: 37
thoughts: 126
Thoughts: **Line Discipline Security Concerns**
Okay, so `ldisc_open` gets called when a line discipline is hooked up to a TTY. Right, that makes sense. But hang on, it requires either `CAP_SYS_ADMIN` or `CAP_SYS_TTY_CONFIG`... just like `caif_serial` does. That's immediately flagging something for me. I need to be sure the system's security is watertight in this scenario.
The crucial question is: where is this capability check actually *done*? Is it happening in the initial user namespace? Because if it is, that's not ideal. The `capable(CAP_SYS_ADMIN)` call… Ah, right. *That* checks the *initial* user namespace. That's the key distinction. We need to be certain we are using the correct checks for each situation.
Now, wait a moment, the distinction is `capable()` checks the initial user namespace, while `ns_capable()` checks the specific namespace. I need to verify how `capable()` is defined and precisely where it is used within this context. I need the full picture to assess the implications here.
|
| 45/2 |
2026/05/25 13:31 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:include/linux/capability.h IncludeLines:true Name:capable]
Results: map[SourceCode: 404: /**
405: * capable - Determine if the current task has a superior capability in effect
406: * @cap: The capability to be tested for
407: *
408: * Return true if the current task has the given superior capability currently
409: * available for use, false if not.
410: *
411: * This sets PF_SUPERPRIV on the task if the capability is available on the
412: * assumption that it's about to be used.
413: */
414: bool capable(int cap)
415: {
416: return ns_capable(&init_user_ns, cap);
417: }
SourceFile:kernel/capability.c]
|
| 46/2 |
2026/05/25 13:31 |
llm |
expert |
0m
Model:
Tokens:
input: 61654
output: 41
thoughts: 234
Thoughts: **Analyzing the AoE Vulnerability**
Okay, so the initial check confirms that `capable(CAP_SYS_ADMIN)` does indeed verify `init_user_ns`. That immediately rules out an unprivileged user within a user namespace directly attaching this line discipline. But, hold on... the bug report mentions an `rcu_preempt` stall, specifically linked to `aoe_tx0`. How did *that* get triggered?
`aoe_tx0` is a kernel thread generated by the `aoe` module. Ah, right, the `aoe` module registers a packet type and then sends packets over *any* network interface. Now I see a potential path: if `caif_serial` is already attached by a privileged user, like root, then the `aoe` module *can* use it to send packets.
The crucial question is, can an *unprivileged* user initiate this whole process? If `caif_serial` is pre-configured, and any user can send packets over that interface, then the vulnerability becomes exploitable. The trigger, in that scenario, is independent of direct `caif_serial` attachment. It's essentially leverage over an existing configuration.
And wait, the `aoe` module sends packets over *all* network interfaces. That really broadens the attack surface. Time to dive deeper into `aoenet_xmit` and `aoe_tx0` to understand the exact mechanics of the packet transmission process.
|
| 47/2 |
2026/05/25 13:31 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/block/aoe/aoenet.c IncludeLines:true Name:tx]
Results: map[SourceCode: 52: /* enters with txlock held */
53: static int
54: tx(int id) __must_hold(&txlock)
55: {
56: struct sk_buff *skb;
57: struct net_device *ifp;
58:
59: while ((skb = skb_dequeue(&skbtxq))) {
60: spin_unlock_irq(&txlock);
61: ifp = skb->dev;
62: if (dev_queue_xmit(skb) == NET_XMIT_DROP && net_ratelimit())
63: pr_warn("aoe: packet could not be sent on %s. %s\n",
64: ifp ? ifp->name : "netif",
65: "consider increasing tx_queue_len");
66: dev_put(ifp);
67: spin_lock_irq(&txlock);
68: }
69: return 0;
70: }
SourceFile:drivers/block/aoe/aoenet.c]
|
| 48/2 |
2026/05/25 13:31 |
llm |
expert |
0m
Model:
Tokens:
input: 62554
output: 54
thoughts: 25
Thoughts: Here's my understanding of the situation, phrased as a thought process:
**Network Packet Flow Inquiry**
Okay, so I'm looking at how `aoe` transmits data packets. It's using `skb->dev`, specifically the network device pointer, to send them out. The key question I need to answer is: how is that `skb->dev` field populated in the first place? I need to understand the path the data takes to know which device it's associated with. Is it set during the packet's construction, or perhaps at a higher network layer? Maybe the device is looked up from metadata, or from the configuration of `aoe` itself? I have to trace back through the code, ideally starting from the `aoe` send path to see how the skb's are created. I'll need to follow the data structures and function calls to determine where `skb->dev` gets initialized. It's all about finding the setting location for that all important device pointer.
|
| 49/2 |
2026/05/25 13:31 |
tool |
codesearch-find-references |
0m
Args: map[ContextFile:drivers/block/aoe/aoenet.c IncludeSnippetLines:10 Name:aoenet_xmit SourceTreePrefix:]
Results: map[References:[map[ReferenceKind:calls ReferencingEntityKind:function ReferencingEntityName:aoecmd_ata_rw SourceFile:drivers/block/aoe/aoecmd.c SourceLine:404 SourceSnippet: 394: /* mark all tracking fields and load out */
395: buf->nframesout += 1;
396:
397: ata_rw_frameinit(f);
398:
399: skb = skb_clone(f->skb, GFP_ATOMIC);
400: if (skb) {
401: f->sent = ktime_get();
402: __skb_queue_head_init(&queue);
403: __skb_queue_tail(&queue, skb);
404: aoenet_xmit(&queue);
405: } else {
406: dev_put(f->t->ifp->nd);
407: }
408: return 1;
409: }
] map[ReferenceKind:calls ReferencingEntityKind:function ReferencingEntityName:aoecmd_cfg SourceFile:drivers/block/aoe/aoecmd.c SourceLine:1375 SourceSnippet:1368: void
1369: aoecmd_cfg(ushort aoemajor, unsigned char aoeminor)
1370: {
1371: struct sk_buff_head queue;
1372:
1373: __skb_queue_head_init(&queue);
1374: aoecmd_cfg_pkts(aoemajor, aoeminor, &queue);
1375: aoenet_xmit(&queue);
1376: }
] map[ReferenceKind:calls ReferencingEntityKind:function ReferencingEntityName:aoecmd_cfg_rsp SourceFile:drivers/block/aoe/aoecmd.c SourceLine:1607 SourceSnippet:1597: if (d->nopen == 0) {
1598: d->fw_ver = be16_to_cpu(ch->fwver);
1599: sl = aoecmd_ata_id(d);
1600: }
1601: bail:
1602: spin_unlock_irqrestore(&d->lock, flags);
1603: aoedev_put(d);
1604: if (sl) {
1605: __skb_queue_head_init(&queue);
1606: __skb_queue_tail(&queue, sl);
1607: aoenet_xmit(&queue);
1608: }
1609: }
] map[ReferenceKind:calls ReferencingEntityKind:function ReferencingEntityName:probe SourceFile:drivers/block/aoe/aoecmd.c SourceLine:625 SourceSnippet: 615: }
616: skb->len += f->iter.bi_size;
617: skb->data_len = f->iter.bi_size;
618: skb->truesize += f->iter.bi_size;
619:
620: skb = skb_clone(f->skb, GFP_ATOMIC);
621: if (skb) {
622: f->sent = ktime_get();
623: __skb_queue_head_init(&queue);
624: __skb_queue_tail(&queue, skb);
625: aoenet_xmit(&queue);
626: } else {
627: dev_put(f->t->ifp->nd);
628: }
629: }
] map[ReferenceKind:calls ReferencingEntityKind:function ReferencingEntityName:resend SourceFile:drivers/block/aoe/aoecmd.c SourceLine:499 SourceSnippet: 489: dev_hold(t->ifp->nd);
490: skb->dev = t->ifp->nd;
491: skb = skb_clone(skb, GFP_ATOMIC);
492: if (skb == NULL) {
493: dev_put(t->ifp->nd);
494: return;
495: }
496: f->sent = ktime_get();
497: __skb_queue_head_init(&queue);
498: __skb_queue_tail(&queue, skb);
499: aoenet_xmit(&queue);
500: }
] map[ReferenceKind:calls ReferencingEntityKind:function ReferencingEntityName:revalidate SourceFile:drivers/block/aoe/aoechr.c SourceLine:130 SourceSnippet: 120: */
121: if (!skb && !msleep_interruptible(250)) {
122: spin_lock_irqsave(&d->lock, flags);
123: goto loop;
124: }
125: aoedev_put(d);
126: if (skb) {
127: struct sk_buff_head queue;
128: __skb_queue_head_init(&queue);
129: __skb_queue_tail(&queue, skb);
130: aoenet_xmit(&queue);
131: }
132: return 0;
133: }
]] TruncatedOutput:false]
|
| 50/2 |
2026/05/25 13:31 |
llm |
expert |
0m
Model:
Tokens:
input: 64398
output: 49
thoughts: 17
Thoughts: Okay, here's my take on those thoughts, tailored for an expert audience, and delivered as a first-person summary:
**Packet Generation Across Network Interfaces: A Quick Scan**
Alright, so the core function, `aoecmd_cfg_pkts`, that's what's running through my mind. It's designed to generate packets. But the crucial bit, the thing that’s jumping out immediately, is that it's generating them *for all network interfaces*. This implies a broad scope of operation. We're not just dealing with a targeted interface; we're talking about a mechanism that inherently considers, and likely iterates through, every configured network interface available to the system. This brings with it some implications. Depending on the design, this could be a broadcast operation, a multi-cast, or a per interface generation in a loop. I immediately wonder about the resource implications as well. If we have a lot of interfaces, or high traffic, what sort of impact could the execution of this routine have? Are we dealing with something that could become a bottleneck? We must also consider the need for a mechanism to filter packets per interface, if that is the design goal.
|
| 51/2 |
2026/05/25 13:31 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/block/aoe/aoecmd.c IncludeLines:true Name:aoecmd_cfg_pkts]
Results: map[SourceCode: 411: /* some callers cannot sleep, and they can call this function,
412: * transmitting the packets later, when interrupts are on
413: */
414: static void
415: aoecmd_cfg_pkts(ushort aoemajor, unsigned char aoeminor, struct sk_buff_head *queue)
416: {
417: struct aoe_hdr *h;
418: struct aoe_cfghdr *ch;
419: struct sk_buff *skb;
420: struct net_device *ifp;
421:
422: rcu_read_lock();
423: for_each_netdev_rcu(&init_net, ifp) {
424: dev_hold(ifp);
425: if (!is_aoe_netif(ifp)) {
426: dev_put(ifp);
427: continue;
428: }
429:
430: skb = new_skb(sizeof *h + sizeof *ch);
431: if (skb == NULL) {
432: printk(KERN_INFO "aoe: skb alloc failure\n");
433: dev_put(ifp);
434: continue;
435: }
436: skb_put(skb, sizeof *h + sizeof *ch);
437: skb->dev = ifp;
438: __skb_queue_tail(queue, skb);
439: h = (struct aoe_hdr *) skb_mac_header(skb);
440: memset(h, 0, sizeof *h + sizeof *ch);
441:
442: memset(h->dst, 0xff, sizeof h->dst);
443: memcpy(h->src, ifp->dev_addr, sizeof h->src);
444: h->type = __constant_cpu_to_be16(ETH_P_AOE);
445: h->verfl = AOE_HVER;
446: h->major = cpu_to_be16(aoemajor);
447: h->minor = aoeminor;
448: h->cmd = AOECMD_CFG;
449: }
450: rcu_read_unlock();
451: }
SourceFile:drivers/block/aoe/aoecmd.c]
|
| 52/2 |
2026/05/25 13:32 |
llm |
expert |
0m
Model:
Tokens:
input: 65413
output: 47
thoughts: 55
Thoughts: Okay, here's my interpretation of this code snippet, expressed as if it's my own thought process:
**Diving into the Network Interface Configuration**
Alright, so `aoecmd_cfg_pkts` is the function we're looking at. Seems like it's designed to configure something related to network interfaces. The critical thing here is that it iterates across *all* the network interfaces within the `init_net` structure. Now, that suggests a broad, system-wide sweep for configuration. But it doesn't just blindly touch every interface, thank goodness. There's a conditional: it *only* sends a packet (presumably a configuration packet) if `is_aoe_netif(ifp)` evaluates to true.
This `is_aoe_netif` function is obviously the crux of the logic here. My interest is immediately piqued. That's the gatekeeper. That's the function that determines whether or not a given interface is relevant to this `aoecmd_cfg_pkts` function. So, I need to understand that. I need to know what criteria it uses. Is it based on the interface's driver, the MAC address, the configured IP address, or some other, perhaps more obscure, characteristic? The whole thing hinges on understanding what makes an interface an "AOE netif," because *that* is what drives the decision to send the configuration packet. So, let's drill into `is_aoe_netif`. That's where the answer lies.
|
| 53/2 |
2026/05/25 13:32 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/block/aoe/aoenet.c IncludeLines:true Name:is_aoe_netif]
Results: map[SourceCode: 72: int
73: is_aoe_netif(struct net_device *ifp)
74: {
75: register char *p, *q;
76: register int len;
77:
78: if (aoe_iflist[0] == '\0')
79: return 1;
80:
81: p = aoe_iflist + strspn(aoe_iflist, WHITESPACE);
82: for (; *p; p = q + strspn(q, WHITESPACE)) {
83: q = p + strcspn(p, WHITESPACE);
84: if (q != p)
85: len = q - p;
86: else
87: len = strlen(p); /* last token in aoe_iflist */
88:
89: if (strlen(ifp->name) == len && !strncmp(ifp->name, p, len))
90: return 1;
91: if (q == p)
92: break;
93: }
94:
95: return 0;
96: }
SourceFile:drivers/block/aoe/aoenet.c]
|
| 54/2 |
2026/05/25 13:32 |
llm |
expert |
0m
Model:
Tokens:
input: 66200
output: 42
thoughts: 285
Thoughts: **My Analysis of the `aoe` Driver and Potential Security Implications**
Okay, so here's what I'm thinking. I'm focusing on how this `aoe` driver operates and if there are any obvious security holes. If that `aoe_iflist` is empty, then that means `aoe` just blasts packets out across *every* network interface in the `init_net` namespace. That's... concerning. Especially if something like `caif_serial` is hanging around.
Now, `caif_serial` is a network interface, and if it's attached, it'll start seeing these `aoe` packets. The immediate question I have is, can an unprivileged user even attach `caif_serial`? I seem to remember that `ldisc_open`, which is likely how you *do* attach a line discipline like this, requires `CAP_SYS_ADMIN` or `CAP_SYS_TTY_CONFIG` in `init_user_ns`. So, no, by default, an unprivileged user shouldn't be able to just hook into this thing.
But what if it's already attached by root? If it's attached by root, then `aoe` will *definitely* send packets over it. That's a valid path. But, wait, I'm getting ahead of myself. `aoe` is a block driver, right? So how is `aoe` actually *triggered* in the first place? What initiates those packets?
It looks like `aoe` commands are triggered by `aoecmd_cfg`. `aoecmd_cfg` is called from `aoecmd_cfg_rsp`, or a `probe` or a `revalidate` which are not helpful. And, right, `aoe` is a kernel module, so it might periodically send discovery packets. I have to think about this in the terms of the whole driver. It can be triggered by a character device, `/dev/etherd/discover`. I'd better dig into `aoechr.c` to understand exactly how the character device interface works and what that can do.
|
| 55/2 |
2026/05/25 13:32 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/block/aoe/aoechr.c IncludeLines:true Name:discover]
Results: map[SourceCode: 71: static int
72: discover(void)
73: {
74: aoecmd_cfg(0xffff, 0xff);
75: return 0;
76: }
SourceFile:drivers/block/aoe/aoechr.c]
|
| 56/2 |
2026/05/25 13:32 |
llm |
expert |
0m
Model:
Tokens:
input: 67081
output: 46
thoughts: 14
Thoughts: Okay, here's my interpretation of those thoughts, crafted with the understanding that I'm speaking to a fellow expert:
**Tracing the Execution Path: `aoechr_write` and `discover`**
Right, so I'm focusing on `aoechr_write`. It's pretty clear that `discover` is being called from within that function. I need to understand the relationship between these two, specifically how that function call is being executed. What arguments are being passed? What's the context? Is `discover` called conditionally, or is it a guaranteed part of the execution flow? Understanding the arguments is really key. I immediately want to consider: what is being discovered? Is it related to a data structure being updated within `aoechr_write`? Is it an external resource? This connection is worth exploring!
|
| 57/2 |
2026/05/25 13:32 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/block/aoe/aoechr.c IncludeLines:true Name:aoechr_write]
Results: map[SourceCode: 169: static ssize_t
170: aoechr_write(struct file *filp, const char __user *buf, size_t cnt, loff_t *offp)
171: {
172: int ret = -EINVAL;
173:
174: switch ((unsigned long) filp->private_data) {
175: default:
176: printk(KERN_INFO "aoe: can't write to that file.\n");
177: break;
178: case MINOR_DISCOVER:
179: ret = discover();
180: break;
181: case MINOR_INTERFACES:
182: ret = interfaces(buf, cnt);
183: break;
184: case MINOR_REVALIDATE:
185: ret = revalidate(buf, cnt);
186: break;
187: case MINOR_FLUSH:
188: ret = aoedev_flush(buf, cnt);
189: break;
190: }
191: if (ret == 0)
192: ret = cnt;
193: return ret;
194: }
SourceFile:drivers/block/aoe/aoechr.c]
|
| 58/2 |
2026/05/25 13:32 |
llm |
expert |
0m
Model:
Tokens:
input: 67700
output: 44
thoughts: 200
Thoughts: **Unraveling the `caif_serial` Vulnerability**
Okay, so I'm digging into this `/dev/etherd/discover` interaction and it looks like writing to it ultimately triggers `aoecmd_cfg`. My first instinct is to ask, "who *can* write to that device?" I know from experience that typically it's root-owned with tight permissions. But, I need to look beyond the obvious.
Wait a second, is `/dev/etherd/discover` the *only* entry point to `caif_serial`? It's a network interface, after all. If there is a way to trigger `caif_serial` data transmission, then *anyone* who can send network packets over it could trigger the bug.
Now the question is, can an unprivileged user send packets over `caif_serial`? If the interface is active, there are several methods an unprivileged user can employ. Broadcasting UDP, or binding to the socket. Even using ping, if it's setuid or uses raw sockets, could work.
Hang on...`caif_serial` is a CAIF interface. Can an unprivileged user create a CAIF socket and send data? I need to check out CAIF sockets and see if that's a viable attack vector.
|
| 59/2 |
2026/05/25 13:32 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:net/caif/caif_socket.c IncludeLines:true Name:caif_create]
Results: map[SourceCode:1017: static int caif_create(struct net *net, struct socket *sock, int protocol,
1018: int kern)
1019: {
1020: struct sock *sk = NULL;
1021: struct caifsock *cf_sk = NULL;
1022: static struct proto prot = {.name = "PF_CAIF",
1023: .owner = THIS_MODULE,
1024: .obj_size = sizeof(struct caifsock),
1025: .useroffset = offsetof(struct caifsock, conn_req.param),
1026: .usersize = sizeof_field(struct caifsock, conn_req.param)
1027: };
1028:
1029: if (!capable(CAP_SYS_ADMIN) && !capable(CAP_NET_ADMIN))
1030: return -EPERM;
1031: /*
1032: * The sock->type specifies the socket type to use.
1033: * The CAIF socket is a packet stream in the sense
1034: * that it is packet based. CAIF trusts the reliability
1035: * of the link, no resending is implemented.
1036: */
1037: if (sock->type == SOCK_SEQPACKET)
1038: sock->ops = &caif_seqpacket_ops;
1039: else if (sock->type == SOCK_STREAM)
1040: sock->ops = &caif_stream_ops;
1041: else
1042: return -ESOCKTNOSUPPORT;
1043:
1044: if (protocol < 0 || protocol >= CAIFPROTO_MAX)
1045: return -EPROTONOSUPPORT;
1046: /*
1047: * Set the socket state to unconnected. The socket state
1048: * is really not used at all in the net/core or socket.c but the
1049: * initialization makes sure that sock->state is not uninitialized.
1050: */
1051: sk = sk_alloc(net, PF_CAIF, GFP_KERNEL, &prot, kern);
1052: if (!sk)
1053: return -ENOMEM;
1054:
1055: cf_sk = container_of(sk, struct caifsock, sk);
1056:
1057: /* Store the protocol */
1058: sk->sk_protocol = (unsigned char) protocol;
1059:
1060: /* Initialize default priority for well-known cases */
1061: switch (protocol) {
1062: case CAIFPROTO_AT:
1063: sk->sk_priority = TC_PRIO_CONTROL;
1064: break;
1065: case CAIFPROTO_RFM:
1066: sk->sk_priority = TC_PRIO_INTERACTIVE_BULK;
1067: break;
1068: default:
1069: sk->sk_priority = TC_PRIO_BESTEFFORT;
1070: }
1071:
1072: /*
1073: * Lock in order to try to stop someone from opening the socket
1074: * too early.
1075: */
1076: lock_sock(&(cf_sk->sk));
1077:
1078: /* Initialize the nozero default sock structure data. */
1079: sock_init_data(sock, sk);
1080: sk->sk_destruct = caif_sock_destructor;
1081:
1082: mutex_init(&cf_sk->readlock); /* single task reading lock */
1083: cf_sk->layer.ctrlcmd = caif_ctrl_cb;
1084: cf_sk->sk.sk_socket->state = SS_UNCONNECTED;
1085: cf_sk->sk.sk_state = CAIF_DISCONNECTED;
1086:
1087: set_tx_flow_off(cf_sk);
1088: set_rx_flow_on(cf_sk);
1089:
1090: /* Set default options on configuration */
1091: cf_sk->conn_req.link_selector = CAIF_LINK_LOW_LATENCY;
1092: cf_sk->conn_req.protocol = protocol;
1093: release_sock(&cf_sk->sk);
1094: return 0;
1095: }
SourceFile:net/caif/caif_socket.c]
|
| 60/2 |
2026/05/25 13:32 |
llm |
expert |
0m
Model:
Tokens:
input: 69485
output: 45
thoughts: 447
Thoughts: **My Investigation into CAIF Vulnerability**
Okay, so the initial hurdle is clear: `caif_create` needs either `CAP_SYS_ADMIN` or `CAP_NET_ADMIN` in the initial user namespace. That means an unprivileged user is immediately blocked from creating a CAIF socket. But, where else can I send packets? Can an unprivileged user send packets over `caif_serial` using a raw socket? No, raw sockets need `CAP_NET_RAW`. How about packet sockets? Nope, also requires `CAP_NET_RAW`.
Alright, what about UDP or TCP? Can I sneak something through there? Ah, but `caif_serial` is a CAIF interface, so it *shouldn't* have an IP address directly assigned. However, if root does assign it an IP, then a user *could* send UDP packets. These packets would then be routed over `caif_serial`. But can `caif_serial`, as a CAIF device, even *support* IP? Well, CAIF *does* support IP, but that would necessitate a root-level configuration.
Now, the core of the problem seems to be `aoe` sending packets over `caif_serial`. `aoe` is a block driver, so it sends packets over *all* available network interfaces. If `caif_serial` is present, it'll send packets over it. Can an unprivileged user somehow *trigger* `aoe` into action? I remember `aoechr_write` depends on `/dev/etherd/discover`, but that seems like another root-protected area.
What about `aoecmd_ata_rw`? That's called when reading or writing to an `aoe` block device, like `/dev/etherd/e0.0`. If an unprivileged user can read or write *that*, they've potentially cracked the door open. But `aoe` block devices are usually owned by root, so that's probably another dead end.
Okay, let's think bigger. Can an *incoming* network packet somehow coax `aoe` into responding? `aoenet_rcv` handles incoming packets. If it receives a specifically crafted query, could it trigger `aoe` to send something back and thus leak information or activate some bug?
|
| 61/2 |
2026/05/25 13:32 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/block/aoe/aoenet.c IncludeLines:true Name:aoenet_rcv]
Results: map[SourceCode: 127: /*
128: * (1) len doesn't include the header by default. I want this.
129: */
130: static int
131: aoenet_rcv(struct sk_buff *skb, struct net_device *ifp, struct packet_type *pt, struct net_device *orig_dev)
132: {
133: struct aoe_hdr *h;
134: struct aoe_atahdr *ah;
135: u32 n;
136: int sn;
137:
138: if (dev_net(ifp) != &init_net)
139: goto exit;
140:
141: skb = skb_share_check(skb, GFP_ATOMIC);
142: if (skb == NULL)
143: return 0;
144: if (!is_aoe_netif(ifp))
145: goto exit;
146: skb_push(skb, ETH_HLEN); /* (1) */
147: sn = sizeof(*h) + sizeof(*ah);
148: if (skb->len >= sn) {
149: sn -= skb_headlen(skb);
150: if (sn > 0 && !__pskb_pull_tail(skb, sn))
151: goto exit;
152: }
153: h = (struct aoe_hdr *) skb->data;
154: n = get_unaligned_be32(&h->tag);
155: if ((h->verfl & AOEFL_RSP) == 0 || (n & 1<<31))
156: goto exit;
157:
158: if (h->verfl & AOEFL_ERR) {
159: n = h->err;
160: if (n > NECODES)
161: n = 0;
162: if (net_ratelimit())
163: printk(KERN_ERR
164: "%s%d.%d@%s; ecode=%d '%s'\n",
165: "aoe: error packet from ",
166: get_unaligned_be16(&h->major),
167: h->minor, skb->dev->name,
168: h->err, aoe_errlist[n]);
169: goto exit;
170: }
171:
172: switch (h->cmd) {
173: case AOECMD_ATA:
174: /* ata_rsp may keep skb for later processing or give it back */
175: skb = aoecmd_ata_rsp(skb);
176: break;
177: case AOECMD_CFG:
178: aoecmd_cfg_rsp(skb);
179: break;
180: default:
181: if (h->cmd >= AOECMD_VEND_MIN)
182: break; /* don't complain about vendor commands */
183: pr_info("aoe: unknown AoE command type 0x%02x\n", h->cmd);
184: break;
185: }
186:
187: if (!skb)
188: return 0;
189: exit:
190: dev_kfree_skb(skb);
191: return 0;
192: }
SourceFile:drivers/block/aoe/aoenet.c]
|
| 62/2 |
2026/05/25 13:32 |
llm |
expert |
0m
Model:
Tokens:
input: 71519
output: 48
thoughts: 181
Thoughts: **Analyzing the AoE Packet Handling**
Okay, so I'm diving into this `aoenet_rcv` function, and it's pretty straightforward – it's the gatekeeper for incoming AoE packets. My immediate concern is how it handles responses. Right, so if it gets a `AOECMD_CFG` response, it offloads that to `aoecmd_cfg_rsp`. Now, *that* function is where things get interesting because... hang on... `aoecmd_cfg_rsp` has the potential to *transmit* a packet back out!
And yes, at the tail end of `aoecmd_cfg_rsp`, there it is: `aoenet_xmit(&queue)`. So, an attacker could potentially inject a malicious AoE packet onto the network, triggering `aoe` to respond. The response itself could also be malicious. Now, if `caif_serial` is attached, the packet transmission could occur over `caif_serial` or any other network interfaces that are attached.
But wait a minute, how does `aoecmd_cfg_rsp` know *where* to send the response? Does it echo back over the same interface that the original packet came from? That's the critical question! I need to double-check `aoecmd_cfg_rsp` to confirm this behavior. This is where the vulnerability may be.
|
| 63/2 |
2026/05/25 13:32 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/block/aoe/aoecmd.c IncludeLines:true Name:aoecmd_cfg_rsp]
Results: map[SourceCode:1529: void
1530: aoecmd_cfg_rsp(struct sk_buff *skb)
1531: {
1532: struct aoedev *d;
1533: struct aoe_hdr *h;
1534: struct aoe_cfghdr *ch;
1535: struct aoetgt *t;
1536: ulong flags, aoemajor;
1537: struct sk_buff *sl;
1538: struct sk_buff_head queue;
1539: u16 n;
1540:
1541: sl = NULL;
1542: h = (struct aoe_hdr *) skb_mac_header(skb);
1543: ch = (struct aoe_cfghdr *) (h+1);
1544:
1545: /*
1546: * Enough people have their dip switches set backwards to
1547: * warrant a loud message for this special case.
1548: */
1549: aoemajor = get_unaligned_be16(&h->major);
1550: if (aoemajor == 0xfff) {
1551: printk(KERN_ERR "aoe: Warning: shelf address is all ones. "
1552: "Check shelf dip switches.\n");
1553: return;
1554: }
1555: if (aoemajor == 0xffff) {
1556: pr_info("aoe: e%ld.%d: broadcast shelf number invalid\n",
1557: aoemajor, (int) h->minor);
1558: return;
1559: }
1560: if (h->minor == 0xff) {
1561: pr_info("aoe: e%ld.%d: broadcast slot number invalid\n",
1562: aoemajor, (int) h->minor);
1563: return;
1564: }
1565:
1566: n = be16_to_cpu(ch->bufcnt);
1567: if (n > aoe_maxout) /* keep it reasonable */
1568: n = aoe_maxout;
1569:
1570: d = aoedev_by_aoeaddr(aoemajor, h->minor, 1);
1571: if (d == NULL) {
1572: pr_info("aoe: device allocation failure\n");
1573: return;
1574: }
1575:
1576: spin_lock_irqsave(&d->lock, flags);
1577:
1578: t = gettgt(d, h->src);
1579: if (t) {
1580: t->nframes = n;
1581: if (n < t->maxout)
1582: aoecmd_wreset(t);
1583: } else {
1584: t = addtgt(d, h->src, n);
1585: if (!t)
1586: goto bail;
1587: }
1588: n = skb->dev->mtu;
1589: n -= sizeof(struct aoe_hdr) + sizeof(struct aoe_atahdr);
1590: n /= 512;
1591: if (n > ch->scnt)
1592: n = ch->scnt;
1593: n = n ? n * 512 : DEFAULTBCNT;
1594: setifbcnt(t, skb->dev, n);
1595:
1596: /* don't change users' perspective */
1597: if (d->nopen == 0) {
1598: d->fw_ver = be16_to_cpu(ch->fwver);
1599: sl = aoecmd_ata_id(d);
1600: }
1601: bail:
1602: spin_unlock_irqrestore(&d->lock, flags);
1603: aoedev_put(d);
1604: if (sl) {
1605: __skb_queue_head_init(&queue);
1606: __skb_queue_tail(&queue, sl);
1607: aoenet_xmit(&queue);
1608: }
1609: }
SourceFile:drivers/block/aoe/aoecmd.c]
|
| 64/2 |
2026/05/25 13:32 |
llm |
expert |
0m
Model:
Tokens:
input: 73302
output: 48
thoughts: 105
Thoughts: **My Analysis of the ATA IDENTIFY Command Flow**
Okay, so `aoecmd_cfg_rsp` initiates this whole process, and it looks like it's calling `aoecmd_ata_id(d)`. Right, that's where the ATA IDENTIFY command gets constructed. Makes sense. Then, the command, encapsulated in some sort of structure, gets passed to `aoenet_xmit`.
`aoenet_xmit` seems to handle the queuing aspect. It's taking this crafted command and placing it onto `skbtxq`, which I presume is a transmit queue, specific to sockets. Fine. Standard approach.
Now the `tx` thread comes into play, pulling the queued command off the `skbtxq`. And then, the actual transmission happens: `dev_queue_xmit(skb)`. This looks like the standard device driver interface for sending the packet. All pretty clean so far.
Wait a second… I need to check something. Back up. `aoecmd_ata_id` is where the `skb` is getting created. I need to be absolutely sure what `skb->dev` is being set to in `aoecmd_ata_id`. This is critical for the kernel to know which device to send the data to. Are we setting it to the right net_device, or is there a potential for the packet to be routed incorrectly? I need to verify that part of the code thoroughly, that's a potential point for failure.
|
| 65/2 |
2026/05/25 13:32 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/block/aoe/aoecmd.c IncludeLines:true Name:aoecmd_ata_id]
Results: map[SourceCode:1378: struct sk_buff *
1379: aoecmd_ata_id(struct aoedev *d)
1380: {
1381: struct aoe_hdr *h;
1382: struct aoe_atahdr *ah;
1383: struct frame *f;
1384: struct sk_buff *skb;
1385: struct aoetgt *t;
1386:
1387: f = newframe(d);
1388: if (f == NULL)
1389: return NULL;
1390:
1391: t = *d->tgt;
1392:
1393: /* initialize the headers & frame */
1394: skb = f->skb;
1395: h = (struct aoe_hdr *) skb_mac_header(skb);
1396: ah = (struct aoe_atahdr *) (h+1);
1397: skb_put(skb, sizeof *h + sizeof *ah);
1398: memset(h, 0, skb->len);
1399: f->tag = aoehdr_atainit(d, t, h);
1400: fhash(f);
1401: t->nout++;
1402: f->waited = 0;
1403: f->waited_total = 0;
1404:
1405: /* set up ata header */
1406: ah->scnt = 1;
1407: ah->cmdstat = ATA_CMD_ID_ATA;
1408: ah->lba3 = 0xa0;
1409:
1410: dev_hold(t->ifp->nd);
1411: skb->dev = t->ifp->nd;
1412:
1413: d->rttavg = RTTAVG_INIT;
1414: d->rttdev = RTTDEV_INIT;
1415: d->timer.function = rexmit_timer;
1416:
1417: skb = skb_clone(skb, GFP_ATOMIC);
1418: if (skb)
1419: f->sent = ktime_get();
1420: else
1421: dev_put(t->ifp->nd);
1422:
1423: return skb;
1424: }
SourceFile:drivers/block/aoe/aoecmd.c]
|
| 66/2 |
2026/05/25 13:32 |
llm |
expert |
0m
Model:
Tokens:
input: 74484
output: 43
thoughts: 141
Thoughts: **Analyzing the Device Assignment in AOE Configuration Response**
Okay, so I'm looking at this line: `skb->dev = t->ifp->nd;`. This seems to be a crucial assignment within the `aoecmd_cfg_rsp` function, specifically related to how the network device is associated with a target. Let me break this down. `t` here is the target structure, derived from `*d->tgt`, which is the target that's just been added or updated as a result of the configuration response. And the key is that `t->ifp` represents the *interface* the `AOECMD_CFG` response came from. So, `skb->dev` is being assigned the network device associated with the interface the response was received on. This makes sense – the configuration is being applied *through* a specific network interface.
Now, a bit of a flashback... `aoecmd_cfg_rsp` receives `skb` – that's the key. Inside `aoecmd_cfg_rsp`, we call `gettgt(d, h->src)` to find the target, and if it's not present, we use `addtgt(d, h->src, n)` to create it. It's the `addtgt` function that's setting this.
Hang on… something just hit me. This assignment of `skb->dev` is done *inside* `addtgt`, isn't it? That raises a flag. Why is the network device being set on `skb` itself at this point? I need to double-check that `addtgt` function immediately. I need to understand why we're associating the network device *directly* with the socket buffer (`skb`). I need to understand why this assignment is happening in the target addition step, rather than in response processing or later. This is definitely where I need to focus my attention. It's a key part of the flow that's driving device association.
|
| 67/2 |
2026/05/25 13:32 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/block/aoe/aoecmd.c IncludeLines:true Name:addtgt]
Results: map[SourceCode:1446: static struct aoetgt *
1447: addtgt(struct aoedev *d, char *addr, ulong nframes)
1448: {
1449: struct aoetgt *t, **tt, **te;
1450:
1451: tt = d->targets;
1452: te = tt + d->ntargets;
1453: for (; tt < te && *tt; tt++)
1454: ;
1455:
1456: if (tt == te) {
1457: tt = grow_targets(d);
1458: if (!tt)
1459: goto nomem;
1460: }
1461: t = kzalloc_obj(*t, GFP_ATOMIC);
1462: if (!t)
1463: goto nomem;
1464: t->nframes = nframes;
1465: t->d = d;
1466: memcpy(t->addr, addr, sizeof t->addr);
1467: t->ifp = t->ifs;
1468: aoecmd_wreset(t);
1469: t->maxout = t->nframes / 2;
1470: INIT_LIST_HEAD(&t->ffree);
1471: return *tt = t;
1472:
1473: nomem:
1474: pr_info("aoe: cannot allocate memory to add target\n");
1475: return NULL;
1476: }
SourceFile:drivers/block/aoe/aoecmd.c]
|
| 68/2 |
2026/05/25 13:32 |
llm |
expert |
2m
Model:
Tokens:
input: 75554
output: 45
thoughts: 186
Thoughts: **Debugging the Target Interface Initialization**
Okay, so I'm digging into this code and something feels off. I was just reviewing `addtgt`, and it clearly *doesn't* set `t->ifp->nd`. I was under the impression it was supposed to, but it looks like it just sets `t->ifp = t->ifs;`. Which makes me wonder, if not there, where *is* `t->ifs[0].nd` being initialized?
I know `t->ifs` is an array of `struct aoeif`, so I need to find the point where its members are properly populated. Ah-ha! It looks like `aoecmd_cfg_rsp` is where the crucial initialization is taking place. Let me quickly review the code snippet provided...
```c
n = skb->dev->mtu;
n -= sizeof(struct aoe_hdr) + sizeof(struct aoe_atahdr);
n /= 512;
if (n > ch->scnt)
n = ch->scnt;
n = n ? n * 512 : DEFAULTBCNT;
setifbcnt(t, skb->dev, n);
```
Okay, so it's calculating a block count (`n`) based on the MTU of the device, subtracting the header sizes, dividing by 512, and then setting a block count. It then calls `setifbcnt`. That makes sense.
Now I need to check `setifbcnt` to see exactly what it does with `n`, and what `t->ifs[0].nd` is actually being set to. This is where the magic has to be happening. Let's see...
|
| 69/2 |
2026/05/25 13:35 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/block/aoe/aoecmd.c IncludeLines:true Name:setifbcnt]
Results: map[SourceCode:1496: static void
1497: setifbcnt(struct aoetgt *t, struct net_device *nd, int bcnt)
1498: {
1499: struct aoedev *d;
1500: struct aoeif *p, *e;
1501: int minbcnt;
1502:
1503: d = t->d;
1504: minbcnt = bcnt;
1505: p = t->ifs;
1506: e = p + NAOEIFS;
1507: for (; p < e; p++) {
1508: if (p->nd == NULL)
1509: break; /* end of the valid interfaces */
1510: if (p->nd == nd) {
1511: p->bcnt = bcnt; /* we're updating */
1512: nd = NULL;
1513: } else if (minbcnt > p->bcnt)
1514: minbcnt = p->bcnt; /* find the min interface */
1515: }
1516: if (nd) {
1517: if (p == e) {
1518: pr_err("aoe: device setifbcnt failure; too many interfaces.\n");
1519: return;
1520: }
1521: dev_hold(nd);
1522: p->nd = nd;
1523: p->bcnt = bcnt;
1524: }
1525: t->minbcnt = minbcnt;
1526: setdbcnt(d);
1527: }
SourceFile:drivers/block/aoe/aoecmd.c]
|
| 70/2 |
2026/05/25 13:35 |
llm |
expert |
0m
Model:
Tokens:
input: 76655
output: 45
thoughts: 839
Thoughts: **Analyzing the AoE CFG Response Vulnerability**
Okay, so here's the breakdown. `setifbcnt` correctly adds the packet's receiving interface (`skb->dev`) to the `t->ifs` structure. This means `t->ifp->nd` points to the interface the AoE packet came in on, which is then used by `aoecmd_ata_id` to send a packet back out. The key is, if an attacker crafts an AoE CFG response packet and somehow gets it onto a `caif_serial` interface, `aoe` will respond with an ATA IDENTIFY packet, back out that same interface. That's the core of the issue.
My first thought was, can an attacker even *send* an AoE CFG response over `caif_serial`? If they control the other end of the serial link, yes, that's possible. But `caif_serial` is typically a local serial device or a pseudo-tty (pty), right? I need to remember that it's connected to a TTY. If it's a pty, an unprivileged user can create a pty, open the master, and the slave is a tty. But then I recalled, `ldisc_open` needs `CAP_SYS_ADMIN` or `CAP_SYS_TTY_CONFIG` to attach the `caif_serial` line discipline to the tty. So, an unprivileged user CANNOT create a `caif_serial` interface. However, if root *has* already created a `caif_serial` (for a real CAIF device), then a peripheral on the serial link can send the crafted packet and trigger the vulnerability. That's the Peripheral Trigger scenario.
Can this be remote? Potentially, if the serial link is connected to a remote device. But CAIF is usually for local devices, like modems. What about a VM guest? If the guest has a serial port passed through, and the host attaches `caif_serial` to it... wait, is the bug in the host or the guest? If the bug's in the guest, the host can trigger it over the virtual serial port. If the bug is in the host, the guest triggers it if the host attaches `caif_serial` to a pty linked to the guest. That's unlikely.
Let's zoom out. What if this is a general `caif_serial` issue? The core is that `caif_serial` enters an infinite loop if `tty_write_room` returns > 0, but `tty->ops->write` returns 0. That happens if `xmit_buf` is NULL. Why is `xmit_buf` NULL? It's allocated by `tty_port_alloc_xmit_buf`. I remembered that for a pty, `tty_port_alloc_xmit_buf` is called during pty creation. Hold on, `uart_write` is for UART serial ports! The stack trace confirms this: it's not a pty. It's:
```
uart_write_room+0x2d2/0x930 drivers/tty/serial/serial_core.c:647
tty_write_room+0x66/0x90 drivers/tty/tty_ioctl.c:69
handle_tx+0x14a/0x620 drivers/net/caif/caif_serial.c:212
```
This *is* a UART (serial port). So when is `xmit_buf` allocated for a UART? I need to check `uart_port_startup`. That's where I need to focus.
|
| 71/2 |
2026/05/25 13:35 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/tty/serial/serial_core.c IncludeLines:true Name:uart_port_startup]
Results: map[SourceCode: 299: /*
300: * Startup the port. This will be called once per open. All calls
301: * will be serialised by the per-port mutex.
302: */
303: static int uart_port_startup(struct tty_struct *tty, struct uart_state *state,
304: bool init_hw)
305: {
306: struct uart_port *uport = uart_port_check(state);
307: int retval;
308:
309: if (uport->type == PORT_UNKNOWN)
310: return 1;
311:
312: /*
313: * Make sure the device is in D0 state.
314: */
315: uart_change_pm(state, UART_PM_STATE_ON);
316:
317: retval = uart_alloc_xmit_buf(&state->port);
318: if (retval)
319: return retval;
320:
321: retval = uport->ops->startup(uport);
322: if (retval == 0) {
323: if (uart_console(uport) && uport->cons->cflag) {
324: tty->termios.c_cflag = uport->cons->cflag;
325: tty->termios.c_ispeed = uport->cons->ispeed;
326: tty->termios.c_ospeed = uport->cons->ospeed;
327: uport->cons->cflag = 0;
328: uport->cons->ispeed = 0;
329: uport->cons->ospeed = 0;
330: }
331: /*
332: * Initialise the hardware port settings.
333: */
334: uart_change_line_settings(tty, state, NULL);
335:
336: /*
337: * Setup the RTS and DTR signals once the
338: * port is open and ready to respond.
339: */
340: if (init_hw && C_BAUD(tty))
341: uart_port_dtr_rts(uport, true);
342: }
343:
344: /*
345: * This is to allow setserial on this port. People may want to set
346: * port/irq/type and then reconfigure the port properly if it failed
347: * now.
348: */
349: if (retval && capable(CAP_SYS_ADMIN))
350: return 1;
351:
352: return retval;
353: }
SourceFile:drivers/tty/serial/serial_core.c]
|
| 72/2 |
2026/05/25 13:35 |
llm |
expert |
0m
Model:
Tokens:
input: 79170
output: 48
thoughts: 53
Thoughts: Here's my take on the thought process:
**Diving into UART Initialization**
Okay, so I'm looking at the `uart_port_startup` function, and it seems like it's calling `uart_alloc_xmit_buf`. That rings a bell, but I want to be absolutely sure. My gut says `uart_alloc_xmit_buf` is just a wrapper, a convenience function, for the core allocation routine. Let me quickly confirm. I'm pretty certain it's ultimately calling `tty_port_alloc_xmit_buf`. Need to check the details, though, just to be precise. Always good to double check those low-level allocations.
|
| 73/2 |
2026/05/25 13:35 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/tty/serial/serial_core.c IncludeLines:true Name:uart_alloc_xmit_buf]
Results: map[SourceCode: 244: static int uart_alloc_xmit_buf(struct tty_port *port)
245: {
246: struct uart_state *state = container_of(port, struct uart_state, port);
247: struct uart_port *uport;
248: unsigned long flags;
249: unsigned long page;
250:
251: /*
252: * Initialise and allocate the transmit and temporary
253: * buffer.
254: */
255: page = get_zeroed_page(GFP_KERNEL);
256: if (!page)
257: return -ENOMEM;
258:
259: uport = uart_port_ref_lock(state, &flags);
260: if (!state->port.xmit_buf) {
261: state->port.xmit_buf = (unsigned char *)page;
262: kfifo_init(&state->port.xmit_fifo, state->port.xmit_buf,
263: PAGE_SIZE);
264: uart_port_unlock_deref(uport, flags);
265: } else {
266: uart_port_unlock_deref(uport, flags);
267: /*
268: * Do not free() the page under the port lock, see
269: * uart_free_xmit_buf().
270: */
271: free_page(page);
272: }
273:
274: return 0;
275: }
SourceFile:drivers/tty/serial/serial_core.c]
|
| 74/2 |
2026/05/25 13:35 |
llm |
expert |
0m
Model:
Tokens:
input: 79908
output: 48
thoughts: 33
Thoughts: Okay, here's my take on those thoughts, framed from the perspective you requested:
**Xmit Buffer Allocation and Lifecycle**
Right, so `uart_alloc_xmit_buf` is the function that handles the allocation of the `xmit_buf`, along with initializing the `xmit_fifo` – which makes perfect sense. My immediate follow-up question, of course, is about the counterpart: when and how is that allocated buffer *released*? Understanding the complete lifecycle of this transmit buffer is crucial. I need to know the conditions under which it's deallocated to avoid memory leaks or resource contention down the line. It's a fundamental aspect of any robust UART implementation, and I want to be certain I understand every aspect of it. I want to make sure I know how to avoid those subtle bugs. I should look into the function that releases the buffer, perhaps it is `uart_free_xmit_buf`.
|
| 75/2 |
2026/05/25 13:35 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/tty/serial/serial_core.c IncludeLines:true Name:uart_free_xmit_buf]
Results: map[SourceCode: 277: static void uart_free_xmit_buf(struct tty_port *port)
278: {
279: struct uart_state *state = container_of(port, struct uart_state, port);
280: struct uart_port *uport;
281: unsigned long flags;
282: char *xmit_buf;
283:
284: /*
285: * Do not free() the transmit buffer page under the port lock since
286: * this can create various circular locking scenarios. For instance,
287: * console driver may need to allocate/free a debug object, which
288: * can end up in printk() recursion.
289: */
290: uport = uart_port_ref_lock(state, &flags);
291: xmit_buf = port->xmit_buf;
292: port->xmit_buf = NULL;
293: INIT_KFIFO(port->xmit_fifo);
294: uart_port_unlock_deref(uport, flags);
295:
296: free_page((unsigned long)xmit_buf);
297: }
SourceFile:drivers/tty/serial/serial_core.c]
|
| 76/2 |
2026/05/25 13:35 |
llm |
expert |
0m
Model:
Tokens:
input: 80554
output: 56
thoughts: 270
Thoughts: **Analyzing the UART Transmit Buffer Release**
Okay, so `uart_free_xmit_buf` is called. First, it sets the `xmit_buf` to NULL. Makes sense, we're freeing the buffer. But then it calls `INIT_KFIFO(port->xmit_fifo)`. Wait a second… that's initializing the FIFO. I need to refresh my memory on what `INIT_KFIFO` actually does. Let me just look at the code block again…
Okay, right. `INIT_KFIFO` does some clever dereferencing with temporary variables. Critically, it sets the `mask` to 0 and the `data` pointer to NULL. Hmmm, if the mask is 0, then the number of available spaces, `kfifo_avail`, should return 1. Which makes sense in this scenario of resetting a kfifo.
Now, when is `uart_free_xmit_buf` actually called? I need to remember the calling context to see if there are any potential issues there. Let me note that down for further investigation.
|
| 77/2 |
2026/05/25 13:35 |
tool |
codesearch-find-references |
0m
Args: map[ContextFile:drivers/tty/serial/serial_core.c IncludeSnippetLines:0 Name:uart_free_xmit_buf SourceTreePrefix:]
Results: map[References:[map[ReferenceKind:calls ReferencingEntityKind:function ReferencingEntityName:uart_shutdown SourceFile:drivers/tty/serial/serial_core.c SourceLine:429] map[ReferenceKind:calls ReferencingEntityKind:function ReferencingEntityName:uart_tty_port_shutdown SourceFile:drivers/tty/serial/serial_core.c SourceLine:1743]] TruncatedOutput:false]
|
| 78/2 |
2026/05/25 13:35 |
llm |
expert |
0m
Model:
Tokens:
input: 81240
output: 46
thoughts: 68
Thoughts: Okay, here's my understanding, tailored for an expert audience:
**Analyzing UART Shutdown Procedures**
Alright, let me break this down. We're looking at the shutdown procedures for the UART, and how they interact with the TTY layer, and in particular `caif_serial`. The context I'm seeing is that there are two primary entry points we're dealing with: `uart_shutdown` and `uart_tty_port_shutdown`. The trigger for calling `uart_shutdown` is fairly straightforward - it seems to be invoked when the TTY is closed. The interesting piece is the relationship with the `caif_serial` driver, which from the sounds of it, is attached to the TTY. And here's where it gets critical: When the TTY gets closed, which in turn calls `uart_shutdown`, the TTY's line discipline's `ldisc_close` function will also be invoked. This means there's a cascade effect from TTY closure down to `caif_serial`. I need to ensure that the interactions here are thread-safe and that all the appropriate cleanup happens in the correct order to avoid resource leaks, data corruption, or race conditions. Knowing the flow from TTY closure to the `caif_serial` is going to be key to debugging any issues down the line.
|
| 79/2 |
2026/05/25 13:35 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/net/caif/caif_serial.c IncludeLines:true Name:ldisc_close]
Results: map[SourceCode: 357: static void ldisc_close(struct tty_struct *tty)
358: {
359: struct ser_device *ser = tty->disc_data;
360:
361: spin_lock(&ser_lock);
362: list_move(&ser->node, &ser_release_list);
363: spin_unlock(&ser_lock);
364: schedule_work(&ser_release_work);
365: }
SourceFile:drivers/net/caif/caif_serial.c]
|
| 80/2 |
2026/05/25 13:35 |
llm |
expert |
1m
Model:
Tokens:
input: 81806
output: 45
thoughts: 40
Thoughts: Okay, here's my interpretation of that sequence, thinking through it as if it's my own code and logic:
**Dissecting the Device Closure and Release Sequence**
Right, so `ldisc_close` is the initial trigger. I understand it's responsible for moving a device entry to the `ser_release_list`. That's the first step - getting it ready for final release. Immediately after that, I schedule `ser_release_work`. This is my typical approach; queueing a work item to handle the asynchronous portion of the device release. I do that to keep the closure process as non-blocking as possible. The real heavy lifting isn't done immediately.
The heart of the release, though, lies within `ser_release_work`. When that work item eventually gets processed, it's going to call `ser_release`. That's where all the nitty-gritty of freeing resources, cleaning up data structures, and actually marking the serial device as available, is done. Basically, `ser_release` is where the device's fate is sealed.
|
| 81/2 |
2026/05/25 13:36 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/net/caif/caif_serial.c IncludeLines:true Name:ser_release]
Results: map[SourceCode: 283: static void ser_release(struct work_struct *work)
284: {
285: struct list_head list;
286: struct ser_device *ser, *tmp;
287: struct tty_struct *tty;
288:
289: spin_lock(&ser_lock);
290: list_replace_init(&ser_release_list, &list);
291: spin_unlock(&ser_lock);
292:
293: if (!list_empty(&list)) {
294: rtnl_lock();
295: list_for_each_entry_safe(ser, tmp, &list, node) {
296: tty = ser->tty;
297: dev_close(ser->dev);
298: unregister_netdevice(ser->dev);
299: debugfs_deinit(ser);
300: tty_kref_put(tty);
301: }
302: rtnl_unlock();
303: }
304: }
SourceFile:drivers/net/caif/caif_serial.c]
|
| 82/2 |
2026/05/25 13:36 |
llm |
expert |
0m
Model:
Tokens:
input: 82464
output: 44
thoughts: 887
Thoughts: **Analyzing a Race Condition in the CAIF Serial Driver**
Okay, so I'm looking at this code and I see a potential race condition. `ser_release` is called, and that triggers `dev_close` on the serial device and also unregisters the network device. The crucial thing is that `dev_close` *stops* the network device, which is asynchronous to the `ser_release` process due to the `ser_release_work` work queue.
The problem arises because when the TTY is closed, `uart_shutdown` gets called, and that's the point where `xmit_buf` gets freed. But because of the asynchronous nature of `ser_release_work`, the `caif_serial` network device could still be active for a brief period after the TTY is closed. During this window, `xmit_buf` is NULL.
If, during that window, a packet comes over `caif_serial`, `dev_queue_xmit` will call `handle_tx`. `handle_tx` then goes to `tty_write_room`, which, through a series of calls, gets to `uart_write_room`. `uart_write_room` ends up returning 1, because the `xmit_fifo` was reset by `INIT_KFIFO`. `handle_tx` then tries to call `tty->ops->write`, which calls `uart_write`. `uart_write` will return 0 because `xmit_buf` is NULL. This is a critical point: `handle_tx` is then stuck in an infinite loop! That's the softlockup.
So, the race is between the TTY closing and the `caif_serial` network device being unregistered. A user can trigger this by opening a TTY, attaching the `caif_serial` line discipline, and then closing the TTY while simultaneously sending network traffic over that interface.
But wait, attaching the `caif_serial` line discipline requires `CAP_SYS_ADMIN` or `CAP_SYS_TTY_CONFIG`, correct? Right, I remember that check:
```c
if (!capable(CAP_SYS_ADMIN) && !capable(CAP_SYS_TTY_CONFIG))
return -EPERM;
```
This means an unprivileged user can't trigger this directly because they can't attach the line discipline in the first place, or in a user namespace as the `capable` check is against the initial namespace.
Okay, so if an unprivileged user can't *attach* it, what about a scenario where `caif_serial` is *already* attached by root? If root has attached the `caif_serial` line discipline to a TTY and then *root* closes the TTY, the race condition remains. Can an unprivileged user *close* the TTY in that case? No, an unprivileged user can't force the TTY to close. Closing a file descriptor just releases *their* reference. The TTY doesn't close until the *last* reference is dropped.
What if we're dealing with a pseudo-terminal (pty)? If root attaches `caif_serial` to a pty, and an unprivileged user is on the other end, closing the master pty will hang up the slave. But `caif_serial` is attached to the *slave* pty, and closing the master should cause a hangup on the slave. Does hangup free the `xmit_buf`? I need to check `tty_port_hangup` to be sure.
|
| 83/2 |
2026/05/25 13:36 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/tty/tty_port.c IncludeLines:true Name:tty_port_hangup]
Results: map[SourceCode: 354: /**
355: * tty_port_hangup - hangup helper
356: * @port: tty port
357: *
358: * Perform port level tty hangup flag and count changes. Drop the tty
359: * reference.
360: *
361: * Caller holds tty lock.
362: */
363: void tty_port_hangup(struct tty_port *port)
364: {
365: struct tty_struct *tty;
366:
367: scoped_guard(spinlock_irqsave, &port->lock) {
368: port->count = 0;
369: tty = port->tty;
370: if (tty)
371: set_bit(TTY_IO_ERROR, &tty->flags);
372: port->tty = NULL;
373: }
374:
375: tty_port_set_active(port, false);
376: tty_port_shutdown(port, tty);
377: tty_kref_put(tty);
378: wake_up_interruptible(&port->open_wait);
379: wake_up_interruptible(&port->delta_msr_wait);
380: }
SourceFile:drivers/tty/tty_port.c]
|
| 84/2 |
2026/05/25 13:36 |
llm |
expert |
0m
Model:
Tokens:
input: 84583
output: 41
thoughts: 146
Thoughts: **Analyzing the Serial Port Hangup Sequence**
Okay, so I'm tracing through this hangup procedure. `tty_port_hangup` kicks things off, and that, unsurprisingly, calls `tty_port_shutdown` with the port and the tty structure. `tty_port_shutdown` then goes to the *port's* operations table and invokes the `shutdown` function, specifically using `port->ops->shutdown(port)`.
For a typical UART setup, `port->ops->shutdown` points to `uart_tty_port_shutdown`. That function, in turn, calls `uart_free_xmit_buf(port)`. So, the UART side seems straightforward – the transmit buffer gets freed as expected during a hangup.
But here's where I need to be careful. My initial thought was that a pty and a UART were equivalent here and it's clear they are NOT. If the pty master closes, then the slave is hung up, and I was on auto-pilot, assuming a UART path. A *pty* uses `pty_port_ops`, not `uart_port_ops`. I need to verify what happens with the pty shutdown sequence. Let's look at `pty_port_ops` more closely.
|
| 85/2 |
2026/05/25 13:37 |
tool |
codesearch-definition-source |
0m
Error:
Args: map[ContextFile:drivers/tty/pty.c IncludeLines:true Name:pty_port_ops]
Results: map[SourceCode: SourceFile:]
|
| 86/2 |
2026/05/25 13:37 |
llm |
expert |
0m
Model:
Tokens:
input: 85062
output: 17
thoughts: 26
Thoughts: Okay, here's my take on those thoughts, tailored for an expert audience:
**Diving into the PTY Kernel Code**
Alright, time to dig into the `pty` kernel driver. I'm thinking the best place to start looking for information about the driver's port operations, and potentially how it handles shutdowns, is within `drivers/tty/pty.c`. Specifically, I'll be searching for definitions or references to `pty_port_ops`, or the use of the term `shutdown`. My intuition says that examining the driver's port operations table will give a clear view of how it interfaces with the serial port infrastructure, including management of the pseudoterminal's state and associated resources. Knowing how it's designed to shut down will be critical in understanding any potential issues there. Let's see what's in there... I expect the `pty_port_ops` structure will hold the key to understanding the control flow.
|
| 87/2 |
2026/05/25 13:37 |
tool |
grepper |
0m
Args: map[Expression:shutdown.*pty]
Results: map[Output:drivers/s390/block/dasd.c=4013=void dasd_generic_shutdown(struct ccw_device *cdev)
--
drivers/s390/block/dasd.c-4025-
drivers/s390/block/dasd.c:4026: wait_event(shutdown_waitq, _wait_for_empty_queues(device));
drivers/s390/block/dasd.c-4027-}
--
include/linux/irq.h=177=struct irq_data {
--
include/linux/irq.h-208- * IRQD_IRQ_STARTED - Startup state of the interrupt
include/linux/irq.h:209: * IRQD_MANAGED_SHUTDOWN - Interrupt was shutdown due to empty affinity
include/linux/irq.h-210- * mask. Applies only to affinity managed irqs.
]
|
| 88/2 |
2026/05/25 13:37 |
llm |
expert |
0m
Model:
Tokens:
input: 85551
output: 21
thoughts: 21
Thoughts: Here's a first-person summary, tailored for an expert audience, as if I were thinking these thoughts:
**Navigating the PTY Landscape**
Alright, let's dive into the guts of the pseudo-terminal driver. Specifically, I need to get a handle on how these things are *operated* – that would be the `tty_port_operations` structure. The logical place to start is, as always, `drivers/tty/pty.c`. That file is the canonical implementation for PTYs, so the definitions related to the `tty_port_operations` will *have* to be there, or at least be pointed to from there. I'm assuming that it will be a straightforward implementation of all the port methods. Let's see if that assumption holds...
|
| 89/2 |
2026/05/25 13:37 |
tool |
grepper |
0m
Error:
Args: map[Expression:tty_port_operations.*pty]
Results:
|
| 90/2 |
2026/05/25 13:37 |
llm |
expert |
0m
Model:
Tokens:
input: 85773
output: 19
thoughts: 21
Thoughts: Here's a first-person summary, tailored for an expert audience, as if I were thinking these thoughts:
**Navigating the PTY Landscape**
Alright, let's dive into the guts of the pseudo-terminal driver. Specifically, I need to get a handle on how these things are *operated* – that would be the `tty_port_operations` structure. The logical place to start is, as always, `drivers/tty/pty.c`. That file is the canonical implementation for PTYs, so the definitions related to the `tty_port_operations` will *have* to be there, or at least be pointed to from there. I'm assuming that it will be a straightforward implementation of all the port methods. Let's see if that assumption holds...
|
| 91/2 |
2026/05/25 13:37 |
tool |
grepper |
0m
Args: map[Expression:tty_port_operations]
Results: map[Output:Documentation/driver-api/tty/tty_port.rst=67=TTY Port Operations Reference
--
Documentation/driver-api/tty/tty_port.rst-70-.. kernel-doc:: include/linux/tty_port.h
Documentation/driver-api/tty/tty_port.rst:71: :identifiers: tty_port_operations
--
arch/um/drivers/line.c=307=static void line_destruct(struct tty_port *port)
--
arch/um/drivers/line.c-317-
arch/um/drivers/line.c:318:static const struct tty_port_operations line_port_ops = {
arch/um/drivers/line.c-319- .activate = line_activate,
--
drivers/char/ttyprintk.c=152=static const struct tty_operations ttyprintk_ops = {
--
drivers/char/ttyprintk.c-159-
drivers/char/ttyprintk.c:160:static const struct tty_port_operations tpk_port_ops = {
drivers/char/ttyprintk.c-161- .shutdown = tpk_port_shutdown,
--
drivers/ipack/devices/ipoctal.c=251=static irqreturn_t ipoctal_irq_handler(void *arg)
--
drivers/ipack/devices/ipoctal.c-266-
drivers/ipack/devices/ipoctal.c:267:static const struct tty_port_operations ipoctal_tty_port_ops = {
drivers/ipack/devices/ipoctal.c-268- .dtr_rts = NULL,
--
drivers/isdn/capi/capi.c=197=static void capiminor_destroy(struct tty_port *port)
--
drivers/isdn/capi/capi.c-207-
drivers/isdn/capi/capi.c:208:static const struct tty_port_operations capiminor_port_ops = {
drivers/isdn/capi/capi.c-209- .destruct = capiminor_destroy,
--
drivers/mmc/core/sdio_uart.c=944=static int sdio_uart_proc_show(struct seq_file *m, void *v)
--
drivers/mmc/core/sdio_uart.c-988-
drivers/mmc/core/sdio_uart.c:989:static const struct tty_port_operations sdio_uart_port_ops = {
drivers/mmc/core/sdio_uart.c-990- .dtr_rts = uart_dtr_rts,
--
drivers/staging/greybus/uart.c=776=static const struct tty_operations gb_ops = {
--
drivers/staging/greybus/uart.c-796-
drivers/staging/greybus/uart.c:797:static const struct tty_port_operations gb_port_ops = {
drivers/staging/greybus/uart.c-798- .dtr_rts = gb_tty_dtr_rts,
--
drivers/tty/amiserial.c=1460=static void amiga_dtr_rts(struct tty_port *port, bool active)
--
drivers/tty/amiserial.c-1475-
drivers/tty/amiserial.c:1476:static const struct tty_port_operations amiga_port_ops = {
drivers/tty/amiserial.c-1477- .carrier_raised = amiga_carrier_raised,
--
drivers/tty/ehv_bytechan.c=656=static void ehv_bc_tty_port_shutdown(struct tty_port *port)
--
drivers/tty/ehv_bytechan.c-663-
drivers/tty/ehv_bytechan.c:664:static const struct tty_port_operations ehv_bc_tty_port_ops = {
drivers/tty/ehv_bytechan.c-665- .activate = ehv_bc_tty_port_activate,
--
drivers/tty/goldfish.c=213=static int goldfish_tty_console_setup(struct console *co, char *options)
--
drivers/tty/goldfish.c-221-
drivers/tty/goldfish.c:222:static const struct tty_port_operations goldfish_port_ops = {
drivers/tty/goldfish.c-223- .activate = goldfish_tty_activate,
--
drivers/tty/hvc/hvc_console.c=888=static const struct tty_operations hvc_ops = {
--
drivers/tty/hvc/hvc_console.c-906-
drivers/tty/hvc/hvc_console.c:907:static const struct tty_port_operations hvc_port_ops = {
drivers/tty/hvc/hvc_console.c-908- .destruct = hvc_port_destruct,
--
drivers/tty/hvc/hvcs.c=664=static void hvcs_destruct_port(struct tty_port *p)
--
drivers/tty/hvc/hvcs.c-703-
drivers/tty/hvc/hvcs.c:704:static const struct tty_port_operations hvcs_port_ops = {
drivers/tty/hvc/hvcs.c-705- .destruct = hvcs_destruct_port,
--
drivers/tty/mips_ejtag_fdc.c=723=static void mips_ejtag_fdc_tty_port_shutdown(struct tty_port *port)
--
drivers/tty/mips_ejtag_fdc.c-754-
drivers/tty/mips_ejtag_fdc.c:755:static const struct tty_port_operations mips_ejtag_fdc_tty_port_ops = {
drivers/tty/mips_ejtag_fdc.c-756- .activate = mips_ejtag_fdc_tty_port_activate,
--
drivers/tty/moxa.c=533=static const struct tty_operations moxa_ops = {
--
drivers/tty/moxa.c-550-
drivers/tty/moxa.c:551:static const struct tty_port_operations moxa_port_ops = {
drivers/tty/moxa.c-552- .carrier_raised = moxa_carrier_raised,
--
drivers/tty/mxser.c=1638=static const struct tty_operations mxser_ops = {
--
drivers/tty/mxser.c-1662-
drivers/tty/mxser.c:1663:static const struct tty_port_operations mxser_port_ops = {
drivers/tty/mxser.c-1664- .carrier_raised = mxser_carrier_raised,
--
drivers/tty/n_gsm.c=360=static struct tty_driver *gsm_tty_driver;
--
drivers/tty/n_gsm.c-410-
drivers/tty/n_gsm.c:411:static const struct tty_port_operations gsm_port_ops;
drivers/tty/n_gsm.c-412-
--
drivers/tty/n_gsm.c=4258=static void gsm_dtr_rts(struct tty_port *port, bool active)
--
drivers/tty/n_gsm.c-4271-
drivers/tty/n_gsm.c:4272:static const struct tty_port_operations gsm_port_ops = {
drivers/tty/n_gsm.c-4273- .carrier_raised = gsm_carrier_raised,
--
drivers/tty/nozomi.c=351=static struct tty_driver *ntty_driver;
drivers/tty/nozomi.c-352-
drivers/tty/nozomi.c:353:static const struct tty_port_operations noz_tty_port_ops;
drivers/tty/nozomi.c-354-
--
drivers/tty/nozomi.c=1763=static unsigned int ntty_chars_in_buffer(struct tty_struct *tty)
--
drivers/tty/nozomi.c-1773-
drivers/tty/nozomi.c:1774:static const struct tty_port_operations noz_tty_port_ops = {
drivers/tty/nozomi.c-1775- .activate = ntty_activate,
--
drivers/tty/rpmsg_tty.c=155=static void rpmsg_tty_destruct_port(struct tty_port *port)
--
drivers/tty/rpmsg_tty.c-165-
drivers/tty/rpmsg_tty.c:166:static const struct tty_port_operations rpmsg_tty_port_ops = {
drivers/tty/rpmsg_tty.c-167- .destruct = rpmsg_tty_destruct_port,
--
drivers/tty/serial/serial_core.c=2650=static const struct tty_operations uart_ops = {
--
drivers/tty/serial/serial_core.c-2685-
drivers/tty/serial/serial_core.c:2686:static const struct tty_port_operations uart_port_ops = {
drivers/tty/serial/serial_core.c-2687- .carrier_raised = uart_carrier_raised,
--
drivers/tty/synclink_gt.c=3413=static void add_device(struct slgt_info *info)
--
drivers/tty/synclink_gt.c-3467-
drivers/tty/synclink_gt.c:3468:static const struct tty_port_operations slgt_port_ops = {
drivers/tty/synclink_gt.c-3469- .carrier_raised = carrier_raised,
--
drivers/tty/ttynull.c-12-
drivers/tty/ttynull.c:13:static const struct tty_port_operations ttynull_port_ops;
drivers/tty/ttynull.c-14-static struct tty_driver *ttynull_driver;
--
drivers/tty/vcc.c=471=static struct vio_version vcc_versions[] = {
--
drivers/tty/vcc.c-474-
drivers/tty/vcc.c:475:static struct tty_port_operations vcc_port_ops = { 0 };
drivers/tty/vcc.c-476-
--
drivers/tty/vt/vt.c=1029=static void vc_port_destruct(struct tty_port *port)
--
drivers/tty/vt/vt.c-1035-
drivers/tty/vt/vt.c:1036:static const struct tty_port_operations vc_port_ops = {
drivers/tty/vt/vt.c-1037- .destruct = vc_port_destruct,
--
drivers/usb/class/cdc-acm.c=1091=static void acm_tty_set_termios(struct tty_struct *tty,
--
drivers/usb/class/cdc-acm.c-1129-
drivers/usb/class/cdc-acm.c:1130:static const struct tty_port_operations acm_port_ops = {
drivers/usb/class/cdc-acm.c-1131- .dtr_rts = acm_port_dtr_rts,
--
drivers/usb/host/xhci-dbgtty.c=449=static int dbc_port_activate(struct tty_port *_port, struct tty_struct *tty)
--
drivers/usb/host/xhci-dbgtty.c-460-
drivers/usb/host/xhci-dbgtty.c:461:static const struct tty_port_operations dbc_port_ops = {
drivers/usb/host/xhci-dbgtty.c-462- .activate = dbc_port_activate,
--
drivers/usb/serial/usb-serial.c=787=ATTRIBUTE_GROUPS(usb_serial_port);
drivers/usb/serial/usb-serial.c-788-
drivers/usb/serial/usb-serial.c:789:static const struct tty_port_operations serial_port_ops = {
drivers/usb/serial/usb-serial.c-790- .carrier_raised = serial_port_carrier_raised,
--
include/linux/tty_port.h=14=struct tty_struct;
--
include/linux/tty_port.h-16-/**
include/linux/tty_port.h:17: * struct tty_port_operations -- operations on tty_port
include/linux/tty_port.h-18- * @carrier_raised: return true if the carrier is raised on @port
--
include/linux/tty_port.h-32- */
include/linux/tty_port.h:33:struct tty_port_operations {
include/linux/tty_port.h-34- bool (*carrier_raised)(struct tty_port *port);
--
include/linux/tty_port.h=49=extern const struct tty_port_client_operations tty_port_default_client_ops;
--
include/linux/tty_port.h-59- * @ops: tty port operations (like activate, shutdown), see &struct
include/linux/tty_port.h:60: * tty_port_operations
include/linux/tty_port.h-61- * @client_ops: tty port client operations (like receive_buf, write_wakeup).
--
include/linux/tty_port.h=101=struct tty_port {
--
include/linux/tty_port.h-104- struct tty_struct *itty;
include/linux/tty_port.h:105: const struct tty_port_operations *ops;
include/linux/tty_port.h-106- const struct tty_port_client_operations *client_ops;
--
net/bluetooth/rfcomm/tty.c=130=static void rfcomm_dev_shutdown(struct tty_port *port)
--
net/bluetooth/rfcomm/tty.c-140-
net/bluetooth/rfcomm/tty.c:141:static const struct tty_port_operations rfcomm_port_ops = {
net/bluetooth/rfcomm/tty.c-142- .destruct = rfcomm_dev_destruct,
]
|
| 92/2 |
2026/05/25 13:37 |
llm |
expert |
0m
Model:
Tokens:
input: 89670
output: 39
thoughts: 31
Thoughts: Here's my summary, as the thought process unfolds:
**Digging into the PTY Mystery**
Okay, hold on a second...something isn't quite clicking. My initial assumption was that the pseudo-terminal (PTY) driver, `pty`, would be leveraging the standard `tty_port_operations` structure. But something feels off. I need to verify that and see what's actually going on under the hood. Time to crack open the source code and get to the bottom of this. Right, let's go straight to the source. Let's start with `drivers/tty/pty.c` and figure out what's really happening.
|
| 93/2 |
2026/05/25 13:37 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/tty/pty.c IncludeLines:true Name:pty_close]
Results: map[SourceCode: 47: static void pty_close(struct tty_struct *tty, struct file *filp)
48: {
49: if (tty->driver->subtype == PTY_TYPE_MASTER)
50: WARN_ON(tty->count > 1);
51: else {
52: if (tty_io_error(tty))
53: return;
54: if (tty->count > 2)
55: return;
56: }
57: set_bit(TTY_IO_ERROR, &tty->flags);
58: wake_up_interruptible(&tty->read_wait);
59: wake_up_interruptible(&tty->write_wait);
60: scoped_guard(spinlock_irq, &tty->ctrl.lock)
61: tty->ctrl.packet = false;
62: /* Review - krefs on tty_link ?? */
63: if (!tty->link)
64: return;
65: set_bit(TTY_OTHER_CLOSED, &tty->link->flags);
66: wake_up_interruptible(&tty->link->read_wait);
67: wake_up_interruptible(&tty->link->write_wait);
68: if (tty->driver->subtype == PTY_TYPE_MASTER) {
69: set_bit(TTY_OTHER_CLOSED, &tty->flags);
70: #ifdef CONFIG_UNIX98_PTYS
71: if (tty->driver == ptm_driver) {
72: guard(mutex)(&devpts_mutex);
73: if (tty->link->driver_data)
74: devpts_pty_kill(tty->link->driver_data);
75: }
76: #endif
77: tty_vhangup(tty->link);
78: }
79: }
SourceFile:drivers/tty/pty.c]
|
| 94/2 |
2026/05/25 13:37 |
llm |
expert |
0m
Model:
Tokens:
input: 90418
output: 45
thoughts: 1642
Thoughts: **Analysis of the UART Softlockup Vulnerability**
Okay, so here's what I've got. This all starts with `pty_close` triggering a cascade of calls that eventually hits the `tty_port_hangup` function. But this particular vulnerability isn't tied to PTYs at all; the bug resides in `uart_write_room` and `uart_write`, meaning it's linked to serial ports, specifically UARTs.
The question then becomes, can an unprivileged user even *access* a UART to trigger this? Typically, `/dev/ttyS*` devices are locked down with permissions that prevent that. The user would need to be in the `dialout` group at minimum. But even *if* they're in that group, attaching `caif_serial` to a TTY requires `CAP_SYS_ADMIN` or `CAP_SYS_TTY_CONFIG`, which are capabilities usually only available to root within the *initial* user namespace. That's a critical point; we're not talking about user namespace capabilities. So, no, an unprivileged user *cannot* directly trigger this.
Therefore, the only realistic scenario for triggering the bug is one where root has attached `caif_serial` to a UART, and then root closes or hangs up the UART. This is where the race condition starts to form. If, during the shutdown window—the brief moment after the UART is "hung up"—an AoE (ATA over Ethernet) packet is received, the `aoe` protocol attempts to respond over the now-closing UART.
Here's the problem: if the UART is connected to a peripheral device (e.g., a modem) *that* device can send an AoE packet during this shutdown window (or even periodically if the `aoe` protocol is broadcasting). This is what sets off the infinite loop. Because the device is sending it *back* to the device (or back to itself)
The vulnerability is a softlockup, an infinite loop within the `handle_tx` function. Here's how it occurs. The loop checks to see if there's space available to write to the device. However, if the tty write operation, `tty_wr`, returns 0 because the transmit buffer is not available, the packet length isn't updated. `skb_pull(skb, 0)` does *nothing* to the buffer. The loop condition is always true.
So, this causes a CPU stall, a denial-of-service condition. There's no memory corruption or privilege escalation, which is good. But it's still a serious problem. It completely blocks the device.
But, is there a reliable attack vector? An unprivileged user is out of the question since they can't attach `caif_serial`. The same applies to user namespaces, as well as a VM guest (unless the host controls it).
Here's where it gets interesting: the Ethernet network. Because `aoe` sends packets over all interfaces, and if `caif_serial` is attached, it becomes a network interface! If an attacker on the Ethernet network sends an AoE packet, `aoe` attempts to respond. `aoecmd_cfg_rsp` responses use the interface that the packet was received on. So, normally the response would go out to Ethernet. However, `aoecmd_cfg_pkts` (used for discovery) broadcasts over *all* interfaces. If root is shutting down `caif_serial` at the exact same moment an attacker on the Ethernet network triggers a discovery, then `aoe` attempts to send over the UART, which causes the softlockup.
The problem here is that the shutdown requires a very specific action from root, and the race window is incredibly small.
But what about a malicious peripheral? If a malicious USB serial device is plugged in, it creates a `/dev/ttyUSB*` node, but doesn't automatically attach `caif_serial`. *If* a udev rule *automatically* attaches `caif_serial` to certain USB serial devices (which is possible), then plugging the device in would trigger it. If that same device is *unplugged*, `tty_vhangup` (through a series of functions) is called, which *initiates the shutdown path*. This, again, is the key race.
So, the malicious USB serial device is the most reliable way to trigger this because it can control when it's plugged in and unplugged. But, do USB serial drivers use `uart_write_room`? We'll need to confirm that. Otherwise, this whole chain is broken.
|
| 95/2 |
2026/05/25 13:37 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/usb/serial/usb-serial.c IncludeLines:true Name:serial_write_room]
Results: map[SourceCode: 381: static unsigned int serial_write_room(struct tty_struct *tty)
382: {
383: struct usb_serial_port *port = tty->driver_data;
384:
385: dev_dbg(&port->dev, "%s\n", __func__);
386:
387: return port->serial->type->write_room(tty);
388: }
SourceFile:drivers/usb/serial/usb-serial.c]
|
| 96/2 |
2026/05/25 13:37 |
llm |
expert |
1m
Model:
Tokens:
input: 93246
output: 43
thoughts: 687
Thoughts: **Analyzing a Potential UART Softlock**
Okay, so I'm diving into this bug report and the stack trace immediately caught my eye. It's showing `uart_write_room` and then `tty_write_room` and eventually, `handle_tx` within `caif_serial`. Hmm, that suggests the problem isn't within USB serial's own write room implementation, which is good. We're looking at a standard UART, likely `/dev/ttyS*`. That's pointing towards hardware UARTs like the 8250, or perhaps a PCI or PCMCIA serial card. But `caif_serial` requires root to attach, so how's this even being triggered?
The bug report came from syzkaller, which is usually root, or at least running in a user namespace with capabilities. But then I remember that `caif_serial` is checking `capable(CAP_SYS_ADMIN)`, and that checks the *initial* user namespace! Syzkaller *usually* doesn't have that in the initial namespace, right? Unless... Syzkaller's running *as* root in the initial namespace! Now that's interesting. I should check if that's a common syzkaller configuration. Alternatively, the attach could have been done by root.
Alright, time to refresh my memory on `capable`. Let's confirm that it indeed checks `init_user_ns`. Yep, looks like `ns_capable(&init_user_ns, cap);`. Okay, so it *has* to be running as root in the initial user namespace, or the attach would have failed. We are definitely looking at a scenario where syzkaller is running as root in the initial user namespace.
Now, let's assess the impact. It's not exploitable, thankfully. This seems to be a Denial of Service, an infinite loop causing a soft lockup. It's not accessible from unprivileged processes, and certainly not from user namespaces because of that `capable()` call. No VM guest or host trigger either. Definitely not a remote or malicious filesystem trigger.
Wait a second… Could there be another way `handle_tx` could loop infinitely? What if `tty_write_room` returns a positive number (meaning there's space) but `tty->ops->write` returns 0 for a *different* reason? Let me go back and re-examine the `uart_write` function...
|
| 97/2 |
2026/05/25 13:39 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/tty/serial/serial_core.c IncludeLines:true Name:uart_write]
Results: map[SourceCode: 610: static ssize_t uart_write(struct tty_struct *tty, const u8 *buf, size_t count)
611: {
612: struct uart_state *state = tty->driver_data;
613: struct uart_port *port;
614: unsigned long flags;
615: int ret = 0;
616:
617: /*
618: * This means you called this function _after_ the port was
619: * closed. No cookie for you.
620: */
621: if (WARN_ON(!state))
622: return -EL3HLT;
623:
624: port = uart_port_ref_lock(state, &flags);
625: if (!state->port.xmit_buf) {
626: uart_port_unlock_deref(port, flags);
627: return 0;
628: }
629:
630: if (port)
631: ret = kfifo_in(&state->port.xmit_fifo, buf, count);
632:
633: __uart_start(state);
634: uart_port_unlock_deref(port, flags);
635: return ret;
636: }
SourceFile:drivers/tty/serial/serial_core.c]
|
| 98/2 |
2026/05/25 13:39 |
llm |
expert |
0m
Model:
Tokens:
input: 94909
output: 47
thoughts: 63
Thoughts: **Analyzing the Return Value and Port State**
Okay, so I'm looking at this code and trying to understand the control flow. Right off the bat, I see a crucial point: if `port` is NULL, the `ret` variable stays at 0, and the function returns 0. That's the baseline scenario. The question immediately becomes: under what circumstances would `port` actually be NULL? That's the key to understanding this conditional.
My next step is to drill down into how `port` is obtained. I'm recalling that `uart_port_ref_lock` is likely the function responsible for providing or retrieving this `port` pointer. So, I need to understand the behaviour of that function. If it returns NULL, that's what triggers this entire scenario.
Specifically, I'm thinking, does `uart_port_ref_lock` return NULL if the UART port has been suspended, or perhaps if it hasn't been properly initialized in the first place? Those are the most likely reasons that come to mind. It's likely one of those states. Now, I need to confirm those assumptions by going straight to the source and taking a look at the implementation of `uart_port_ref_lock`.
|
| 99/2 |
2026/05/25 13:39 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/tty/serial/serial_core.c IncludeLines:true Name:uart_port_ref_lock]
Results: map[SourceCode: 78: static inline struct uart_port *uart_port_ref_lock(struct uart_state *state, unsigned long *flags)
79: {
80: struct uart_port *uport = uart_port_ref(state);
81:
82: if (uport)
83: uart_port_lock_irqsave(uport, flags);
84:
85: return uport;
86: }
SourceFile:drivers/tty/serial/serial_core.c]
|
| 100/2 |
2026/05/25 13:39 |
llm |
expert |
0m
Model:
Tokens:
input: 95438
output: 45
thoughts: 8
Thoughts: Okay, here's my summary, presented as a first-person account reflecting on the provided text, assuming the user is an expert.
**Analyzing `uart_port_ref`**
Alright, let's break this down. When I see `uart_port_ref`, my mind immediately goes to the core concept of reference counting within a UART (Universal Asynchronous Receiver/Transmitter) port context. My primary concern is how it impacts resource management, concurrency, and thread safety within the system. Is this a simple integer counter, or is there a more sophisticated mechanism involved? Are there any potential race conditions I need to be aware of if multiple threads or processes might access the same UART port simultaneously?
I start to think about the different scenarios. Is the `uart_port_ref` incremented when a driver or user calls `open()` and decremented on `close()`? Is there a corresponding mechanism for handling errors or unexpected terminations of processes that could leave the reference count in an inconsistent state, leading to memory leaks or premature port release? I'm already anticipating the need to check for overflow conditions, especially in systems with extended uptime or high port usage.
My next step is to consider how this reference count interacts with the underlying hardware resources, such as the UART controller registers and any associated DMA (Direct Memory Access) channels. If the reference count drops to zero, how is the UART port properly de-initialized and disabled to free up these resources? Is there a clean shutdown sequence? Are interrupts properly disabled, and is the interrupt service routine detached from the port?
I also wonder about the implications for driver design. Does this reference counting mechanism impose any restrictions on the driver's structure or behavior? Are there any potential performance bottlenecks or overhead associated with frequent increments and decrements of the reference counter, especially if this is a critical section? I'm now thinking about the locking mechanism used to protect the reference count variable and if it is efficient or likely to cause contention.
Basically, I want to know everything about its lifecycle. I'll need to dig into the surrounding code and documentation, focusing on the specific implementation of the reference counting mechanism to fully understand its implications and determine if there are any areas that need review or optimization.
|
| 101/2 |
2026/05/25 13:39 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/tty/serial/serial_core.c IncludeLines:true Name:uart_port_ref]
Results: map[SourceCode: 65: static inline struct uart_port *uart_port_ref(struct uart_state *state)
66: {
67: if (atomic_add_unless(&state->refcount, 1, 0))
68: return state->uart_port;
69: return NULL;
70: }
SourceFile:drivers/tty/serial/serial_core.c]
|
| 102/2 |
2026/05/25 13:39 |
llm |
expert |
0m
Model:
Tokens:
input: 96072
output: 45
thoughts: 70
Thoughts: Okay, let me think this through.
**Analyzing the UART Driver Behavior**
Alright, so the core of this seems to be about how the UART driver handles a disconnected port. My immediate concern is that if `state->refcount` is zero, the function returns NULL. That’s the critical condition to consider. I need to understand the scenarios where `state->refcount` hits zero. The text clearly indicates that this happens when the port is removed, like when a device is physically disconnected.
Now, if a write operation (`uart_write`) encounters this condition, it returns 0. That's straightforward, indicating some kind of failure or inability to write. But, I need to know the parallel case. What about `uart_write_room`? Does it return 0 also, or does it return an error code like the function `uart_write`? Understanding the behavior of `uart_write_room` in this scenario is crucial for robust error handling and knowing whether the write function should be retried. The implications are significant for buffer management and preventing potential deadlocks.
|
| 103/2 |
2026/05/25 13:39 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/tty/serial/serial_core.c IncludeLines:true Name:uart_write_room]
Results: map[SourceCode: 638: static unsigned int uart_write_room(struct tty_struct *tty)
639: {
640: struct uart_state *state = tty->driver_data;
641: struct uart_port *port;
642: unsigned long flags;
643: unsigned int ret;
644:
645: port = uart_port_ref_lock(state, &flags);
646: ret = kfifo_avail(&state->port.xmit_fifo);
647: uart_port_unlock_deref(port, flags);
648: return ret;
649: }
SourceFile:drivers/tty/serial/serial_core.c]
|
| 104/2 |
2026/05/25 13:39 |
llm |
expert |
0m
Model:
Tokens:
input: 96627
output: 43
thoughts: 903
Thoughts: **Analyzing a Potential Denial-of-Service Vulnerability in caif_serial**
Okay, so here's the breakdown of what I'm seeing. If the `port` in the `caif_serial` driver is NULL, `uart_port_unlock_deref` effectively does nothing. However, the `kfifo_avail` call still executes. If the transmit FIFO (`xmit_fifo`) is still allocated, this can return a value greater than zero, indicating available space. The problem is that while `uart_write_room` thinks there's space available (`>0`), `uart_write` can return zero, causing an infinite loop within the `handle_tx` function.
This scenario becomes interesting in the context of hot-pluggable serial devices, like USB serial devices. If a device is removed while `caif_serial` is attached, and then traffic is attempted, we hit that loop. The question then is, can an attacker leverage this for a denial-of-service (DoS) attack?
Initially, I considered a malicious USB serial device scenario. However, attaching `caif_serial` requires `CAP_SYS_ADMIN` in the initial user namespace. This makes it impossible for an unprivileged user to initiate it directly. However, if the system is configured to auto-attach `caif_serial` to specific devices, that's a different story. If an attacker can plug in a matching device, wait for the attachment, and then unplug it while traffic is being sent, then they could trigger this DoS. This does depend on a specific configuration, though. I'd have to figure out if there is a userspace daemon that may auto-attach, like `caifd` or a connection manager. Without that automatic attachment, an unprivileged user cannot trigger it.
So, digging deeper, I tried to see if there's any other code path that calls `handle_tx` that bypasses `CAP_SYS_ADMIN`. I traced the function and it's called exclusively from `caif_xmit`, which corresponds to `ndo_start_xmit`. The network interface is created within `ldisc_open`, and this function has the `CAP_SYS_ADMIN` check, so no luck.
The `aoe` part isn't really the vulnerability, it's just the trigger. Any network traffic would trigger it. The root cause is the assumption in `caif_serial`'s `handle_tx` that `tty->ops->write` will write something if `tty_write_room` returns a positive number. Specifically, `uart_write` can return zero if `xmit_buf` is NULL or if `port` is NULL due to a device removal. To fix this, the driver needs to either break the loop when `tty_wr == 0`, or have `uart_write_room` properly report a room size of zero if `port` or `xmit_buf` are null.
In summary, the security impact is a DoS, but it's not directly exploitable. An unprivileged process or user namespace can't trigger it without specific configuration. There's no remote, VM, or malicious filesystem trigger. The only trigger would be peripheral - but even that is conditional on auto-attach.
I should also check other line disciplines to see if they might share this bug, particularly `slip`, `slcan` and `ppp_async`. Let's start with `slip`.
|
| 105/2 |
2026/05/25 13:39 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/net/slip/slip.c IncludeLines:true Name:sl_tx_timeout]
Results: map[SourceCode: 465: static void sl_tx_timeout(struct net_device *dev, unsigned int txqueue)
466: {
467: struct slip *sl = netdev_priv(dev);
468:
469: spin_lock(&sl->lock);
470:
471: if (netif_queue_stopped(dev)) {
472: if (!netif_running(dev) || !sl->tty)
473: goto out;
474:
475: /* May be we must check transmitter timeout here ?
476: * 14 Oct 1994 Dmitry Gorodchanin.
477: */
478: #ifdef SL_CHECK_TRANSMIT
479: if (time_before(jiffies, dev_trans_start(dev) + 20 * HZ)) {
480: /* 20 sec timeout not reached */
481: goto out;
482: }
483: printk(KERN_WARNING "%s: transmit timed out, %s?\n",
484: dev->name,
485: (tty_chars_in_buffer(sl->tty) || sl->xleft) ?
486: "bad line quality" : "driver error");
487: sl->xleft = 0;
488: clear_bit(TTY_DO_WRITE_WAKEUP, &sl->tty->flags);
489: sl_unlock(sl);
490: #endif
491: }
492: out:
493: spin_unlock(&sl->lock);
494: }
SourceFile:drivers/net/slip/slip.c]
|
| 106/2 |
2026/05/25 13:39 |
llm |
expert |
0m
Model:
Tokens:
input: 98801
output: 43
thoughts: 18
Thoughts: Here's my take on those thoughts:
**Analyzing Potential Bottlenecks in the Network Stack**
Okay, so I'm thinking about where things might be getting held up in the network stack right now. We've got a system that's behaving in a way that suggests a bottleneck somewhere. Time to pinpoint it. My immediate inclination is to drill down into the SLIP encapsulation and the write-wake-up paths. Specifically, I'm thinking about those two functions, `sl_encaps` and `slip_write_wakeup`. I suspect one, or both, might be introducing latency or contention. I’m betting one of them is doing something synchronous that's causing it. Time to dive into the code and see what’s going on at that level. I'll need to scrutinize the data flow within these functions. I’m going to look for any potential blocking operations, memory allocation issues, or inefficiencies in interrupt handling.
|
| 107/2 |
2026/05/25 13:39 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/net/slip/slip.c IncludeLines:true Name:slip_write_wakeup]
Results: map[SourceCode: 450: /*
451: * Called by the driver when there's room for more data.
452: * Schedule the transmit.
453: */
454: static void slip_write_wakeup(struct tty_struct *tty)
455: {
456: struct slip *sl;
457:
458: rcu_read_lock();
459: sl = rcu_dereference(tty->disc_data);
460: if (sl)
461: schedule_work(&sl->tx_work);
462: rcu_read_unlock();
463: }
SourceFile:drivers/net/slip/slip.c]
|
| 108/2 |
2026/05/25 13:39 |
llm |
expert |
0m
Model:
Tokens:
input: 99277
output: 43
thoughts: 8
Thoughts: Okay, here's my interpretation of that.
**Analyzing `sl_tx_work` – A Deep Dive**
Alright, let's break down this `sl_tx_work` thing. From what I understand, it seems to be where the real heavy lifting happens in the transaction processing pipeline. We're talking about the core logic that actually pushes transactions through. The fact that its name suggests something related to "work" and "tx" (transaction) points directly to the execution phase. This is where the rubber meets the road, so to speak.
Now, I'd want to examine the function's internal workings. I would be looking for the crucial bits:
* **Data Structures:** What kind of data structures does it operate on? Are we dealing with queues, buffers, linked lists, or something more complex? The choice of data structure is going to have a massive impact on the performance characteristics, such as throughput, latency, and memory usage.
* **Concurrency:** How is concurrency handled? Is it single-threaded, using mutexes, semaphores, or a lock-free design? This is critical for understanding the potential bottlenecks and scaling limitations. Concurrent designs are notoriously difficult to get right, but absolutely essential for performance.
* **Error Handling:** How robust is the error handling? Is it defensive programming, ensuring that there is some form of handling of all possible failures? Error handling is more important that success handling, and the quality of this part will reveal the system's resilience to adverse conditions.
* **Resource Management:** Are there memory leaks, resource exhaustion problems, or are resources correctly managed? Improper resource management will cause the system to fail unpredictably.
* **Synchronization:** How does it interact with other components or threads? What kind of synchronization primitives are in use? This should be a significant source of latency and errors.
* **Algorithm:** Does it contain complex algorithms, or merely simple operations? I will want to trace the algorithmic complexity for performance and edge cases.
Ultimately, I need to understand the precise sequence of operations. Which reads and writes are happening, when, and in what order? What are the critical paths? What are the potential bottlenecks? A detailed analysis would reveal everything.
|
| 109/2 |
2026/05/25 13:39 |
tool |
codesearch-definition-source |
0m
Error:
Args: map[ContextFile:drivers/net/slip/slip.c IncludeLines:true Name:sl_tx_work]
Results: map[SourceCode: SourceFile:]
|
| 110/2 |
2026/05/25 13:39 |
llm |
expert |
0m
Model:
Tokens:
input: 99816
output: 17
thoughts: 16
Thoughts: Here's my thought process, as if I were considering this search:
**Diving into slip.c: Targeting tx_work**
Alright, time to get to work. I need to investigate something related to `tx_work`, so my first move is to pinpoint where this term is used within the `slip.c` file. This is standard operating procedure - a simple search is the fastest way to get an initial grasp of the context. I'm assuming `slip.c` is the most logical place to start based on the initial information. Hopefully, this search will lead me directly to the relevant functions or data structures. I'll be looking for usages of this in the code, where the `tx_work` identifier may appear, or maybe even related function names or data structures that are linked to the `tx_work` logic. That's the basic plan for now. Let's see what we uncover.
|
| 111/2 |
2026/05/25 13:39 |
tool |
grepper |
0m
Args:
Results: map[Output:
Full output is too long, showing 500 out of 3867 lines.
Use more precise expression if possible.
[Documentation/driver-api/nfc/nfc-hci.rst=28=HCI uses 2 execution contexts:
Documentation/driver-api/nfc/nfc-hci.rst-29-
Documentation/driver-api/nfc/nfc-hci.rst:30:- one for executing commands : nfc_hci_msg_tx_work(). Only one command
Documentation/driver-api/nfc/nfc-hci.rst-31- can be executing at any given moment.
--
Documentation/driver-api/nfc/nfc-hci.rst=239=complete after some short timeout anyway.
Documentation/driver-api/nfc/nfc-hci.rst-240-
Documentation/driver-api/nfc/nfc-hci.rst:241:MSGTXWQ context will then be scheduled and invoke nfc_hci_msg_tx_work().
Documentation/driver-api/nfc/nfc-hci.rst-242-This function will dequeue the next pending command and send its HCP fragments
--
Documentation/driver-api/nfc/nfc-hci.rst=253=waiting command execution. Response processing involves invoking the completion
Documentation/driver-api/nfc/nfc-hci.rst:254:callback that was provided by nfc_hci_msg_tx_work() when it sent the command.
Documentation/driver-api/nfc/nfc-hci.rst-255-The completion callback will then wake the syscall context.
--
drivers/base/firmware_loader/main.c=311=static int fw_decompress_zstd(struct device *dev, struct fw_priv *fw_priv,
--
drivers/base/firmware_loader/main.c-335-
drivers/base/firmware_loader/main.c:336: workspace_size = zstd_dctx_workspace_bound();
drivers/base/firmware_loader/main.c-337- workspace = kvzalloc(workspace_size, GFP_KERNEL);
--
drivers/block/zram/backend_zstd.c=119=static int zstd_create(struct zcomp_params *params, struct zcomp_ctx *ctx)
--
drivers/block/zram/backend_zstd.c-131- prm = zstd_get_params(params->level, PAGE_SIZE);
drivers/block/zram/backend_zstd.c:132: sz = zstd_cctx_workspace_bound(&prm.cParams);
drivers/block/zram/backend_zstd.c-133- zctx->cctx_mem = vzalloc(sz);
--
drivers/block/zram/backend_zstd.c-140-
drivers/block/zram/backend_zstd.c:141: sz = zstd_dctx_workspace_bound();
drivers/block/zram/backend_zstd.c-142- zctx->dctx_mem = vzalloc(sz);
--
drivers/bluetooth/btmtkuart.c=55=struct btmtkuart_dev {
--
drivers/bluetooth/btmtkuart.c-69-
drivers/bluetooth/btmtkuart.c:70: struct work_struct tx_work;
drivers/bluetooth/btmtkuart.c-71- unsigned long tx_state;
--
drivers/bluetooth/btmtkuart.c=232=static const struct h4_recv_pkt mtk_recv_pkts[] = {
--
drivers/bluetooth/btmtkuart.c-237-
drivers/bluetooth/btmtkuart.c:238:static void btmtkuart_tx_work(struct work_struct *work)
drivers/bluetooth/btmtkuart.c-239-{
drivers/bluetooth/btmtkuart.c-240- struct btmtkuart_dev *bdev = container_of(work, struct btmtkuart_dev,
drivers/bluetooth/btmtkuart.c:241: tx_work);
drivers/bluetooth/btmtkuart.c-242- struct serdev_device *serdev = bdev->serdev;
--
drivers/bluetooth/btmtkuart.c=287=static void btmtkuart_tx_wakeup(struct btmtkuart_dev *bdev)
--
drivers/bluetooth/btmtkuart.c-291-
drivers/bluetooth/btmtkuart.c:292: schedule_work(&bdev->tx_work);
drivers/bluetooth/btmtkuart.c-293-}
--
drivers/bluetooth/btmtkuart.c=484=static int btmtkuart_flush(struct hci_dev *hdev)
--
drivers/bluetooth/btmtkuart.c-491-
drivers/bluetooth/btmtkuart.c:492: cancel_work_sync(&bdev->tx_work);
drivers/bluetooth/btmtkuart.c-493-
--
drivers/bluetooth/btmtkuart.c=828=static int btmtkuart_probe(struct serdev_device *serdev)
--
drivers/bluetooth/btmtkuart.c-850-
drivers/bluetooth/btmtkuart.c:851: INIT_WORK(&bdev->tx_work, btmtkuart_tx_work);
drivers/bluetooth/btmtkuart.c-852- skb_queue_head_init(&bdev->txq);
--
drivers/bluetooth/btnxpuart.c=183=struct btnxpuart_dev {
--
drivers/bluetooth/btnxpuart.c-186-
drivers/bluetooth/btnxpuart.c:187: struct work_struct tx_work;
drivers/bluetooth/btnxpuart.c-188- unsigned long tx_state;
--
drivers/bluetooth/btnxpuart.c=372=static struct sk_buff *nxp_drv_send_cmd(struct hci_dev *hdev, u16 opcode,
--
drivers/bluetooth/btnxpuart.c-388- __hci_cmd_send(hdev, opcode, plen, param);
drivers/bluetooth/btnxpuart.c:389: /* Allow command to be sent before tx_work is cancelled
drivers/bluetooth/btnxpuart.c-390- * by btnxpuart_flush()
--
drivers/bluetooth/btnxpuart.c=399=static void btnxpuart_tx_wakeup(struct btnxpuart_dev *nxpdev)
drivers/bluetooth/btnxpuart.c-400-{
drivers/bluetooth/btnxpuart.c:401: if (schedule_work(&nxpdev->tx_work))
drivers/bluetooth/btnxpuart.c-402- set_bit(BTNXPUART_TX_STATE_ACTIVE, &nxpdev->tx_state);
--
drivers/bluetooth/btnxpuart.c=1647=static struct sk_buff *nxp_dequeue(void *data)
--
drivers/bluetooth/btnxpuart.c-1655-/* btnxpuart based on serdev */
drivers/bluetooth/btnxpuart.c:1656:static void btnxpuart_tx_work(struct work_struct *work)
drivers/bluetooth/btnxpuart.c-1657-{
drivers/bluetooth/btnxpuart.c-1658- struct btnxpuart_dev *nxpdev = container_of(work, struct btnxpuart_dev,
drivers/bluetooth/btnxpuart.c:1659: tx_work);
drivers/bluetooth/btnxpuart.c-1660- struct serdev_device *serdev = nxpdev->serdev;
--
drivers/bluetooth/btnxpuart.c=1724=static int btnxpuart_flush(struct hci_dev *hdev)
--
drivers/bluetooth/btnxpuart.c-1731-
drivers/bluetooth/btnxpuart.c:1732: cancel_work_sync(&nxpdev->tx_work);
drivers/bluetooth/btnxpuart.c-1733-
--
drivers/bluetooth/btnxpuart.c=1815=static int nxp_serdev_probe(struct serdev_device *serdev)
--
drivers/bluetooth/btnxpuart.c-1832-
drivers/bluetooth/btnxpuart.c:1833: INIT_WORK(&nxpdev->tx_work, btnxpuart_tx_work);
drivers/bluetooth/btnxpuart.c-1834- skb_queue_head_init(&nxpdev->txq);
--
drivers/firmware/arm_scmi/transports/virtio.c-45- * @free_list: List of unused scmi_vio_msg, maintained for Tx channels only
drivers/firmware/arm_scmi/transports/virtio.c:46: * @deferred_tx_work: Worker for TX deferred replies processing
drivers/firmware/arm_scmi/transports/virtio.c-47- * @deferred_tx_wq: Workqueue for TX deferred replies
--
drivers/firmware/arm_scmi/transports/virtio.c=57=struct scmi_vio_channel {
--
drivers/firmware/arm_scmi/transports/virtio.c-65- struct list_head pending_cmds_list;
drivers/firmware/arm_scmi/transports/virtio.c:66: struct work_struct deferred_tx_work;
drivers/firmware/arm_scmi/transports/virtio.c-67- struct workqueue_struct *deferred_tx_wq;
--
drivers/firmware/arm_scmi/transports/virtio.c=267=static void scmi_vio_complete_cb(struct virtqueue *vqueue)
--
drivers/firmware/arm_scmi/transports/virtio.c-319-
drivers/firmware/arm_scmi/transports/virtio.c:320:static void scmi_vio_deferred_tx_worker(struct work_struct *work)
drivers/firmware/arm_scmi/transports/virtio.c-321-{
--
drivers/firmware/arm_scmi/transports/virtio.c-325-
drivers/firmware/arm_scmi/transports/virtio.c:326: vioch = container_of(work, struct scmi_vio_channel, deferred_tx_work);
drivers/firmware/arm_scmi/transports/virtio.c-327-
--
drivers/firmware/arm_scmi/transports/virtio.c=376=static bool virtio_chan_available(struct device_node *of_node, int idx)
--
drivers/firmware/arm_scmi/transports/virtio.c-399-
drivers/firmware/arm_scmi/transports/virtio.c:400:static void scmi_destroy_tx_workqueue(void *deferred_tx_wq)
drivers/firmware/arm_scmi/transports/virtio.c-401-{
--
drivers/firmware/arm_scmi/transports/virtio.c=405=static int virtio_chan_setup(struct scmi_chan_info *cinfo, struct device *dev,
--
drivers/firmware/arm_scmi/transports/virtio.c-427-
drivers/firmware/arm_scmi/transports/virtio.c:428: ret = devm_add_action_or_reset(dev, scmi_destroy_tx_workqueue,
drivers/firmware/arm_scmi/transports/virtio.c-429- vioch->deferred_tx_wq);
--
drivers/firmware/arm_scmi/transports/virtio.c-432-
drivers/firmware/arm_scmi/transports/virtio.c:433: INIT_WORK(&vioch->deferred_tx_work,
drivers/firmware/arm_scmi/transports/virtio.c:434: scmi_vio_deferred_tx_worker);
drivers/firmware/arm_scmi/transports/virtio.c-435- }
--
drivers/firmware/arm_scmi/transports/virtio.c=667=static bool virtio_poll_done(struct scmi_chan_info *cinfo,
--
drivers/firmware/arm_scmi/transports/virtio.c-772- if (vioch->deferred_tx_wq && (any_prefetched || pending))
drivers/firmware/arm_scmi/transports/virtio.c:773: queue_work(vioch->deferred_tx_wq, &vioch->deferred_tx_work);
drivers/firmware/arm_scmi/transports/virtio.c-774-
--
drivers/firmware/efi/libstub/zboot-decompress-zstd.c=17=efi_status_t efi_zboot_decompress_init(unsigned long *alloc_size)
--
drivers/firmware/efi/libstub/zboot-decompress-zstd.c-20-
drivers/firmware/efi/libstub/zboot-decompress-zstd.c:21: wksp_size = zstd_dctx_workspace_bound();
drivers/firmware/efi/libstub/zboot-decompress-zstd.c-22- status = efi_allocate_pages(wksp_size, (unsigned long *)&wksp, ULONG_MAX);
--
drivers/gpu/drm/display/drm_dp_mst_topology.c=4815=static void drm_dp_mst_kick_tx(struct drm_dp_mst_topology_mgr *mgr)
drivers/gpu/drm/display/drm_dp_mst_topology.c-4816-{
drivers/gpu/drm/display/drm_dp_mst_topology.c:4817: queue_work(system_long_wq, &mgr->tx_work);
drivers/gpu/drm/display/drm_dp_mst_topology.c-4818-}
--
drivers/gpu/drm/display/drm_dp_mst_topology.c=5007=EXPORT_SYMBOL(drm_dp_mst_dump_topology);
drivers/gpu/drm/display/drm_dp_mst_topology.c-5008-
drivers/gpu/drm/display/drm_dp_mst_topology.c:5009:static void drm_dp_tx_work(struct work_struct *work)
drivers/gpu/drm/display/drm_dp_mst_topology.c-5010-{
drivers/gpu/drm/display/drm_dp_mst_topology.c:5011: struct drm_dp_mst_topology_mgr *mgr = container_of(work, struct drm_dp_mst_topology_mgr, tx_work);
drivers/gpu/drm/display/drm_dp_mst_topology.c-5012-
--
drivers/gpu/drm/display/drm_dp_mst_topology.c=5706=int drm_dp_mst_topology_mgr_init(struct drm_dp_mst_topology_mgr *mgr,
--
drivers/gpu/drm/display/drm_dp_mst_topology.c-5735- INIT_WORK(&mgr->work, drm_dp_mst_link_probe_work);
drivers/gpu/drm/display/drm_dp_mst_topology.c:5736: INIT_WORK(&mgr->tx_work, drm_dp_tx_work);
drivers/gpu/drm/display/drm_dp_mst_topology.c-5737- INIT_WORK(&mgr->delayed_destroy_work, drm_dp_delayed_destroy_work);
--
drivers/gpu/drm/i915/gt/intel_engine_types.h=69=struct intel_instdone {
--
drivers/gpu/drm/i915/gt/intel_engine_types.h-91- */
drivers/gpu/drm/i915/gt/intel_engine_types.h:92:struct i915_ctx_workarounds {
drivers/gpu/drm/i915/gt/intel_engine_types.h-93- struct i915_wa_ctx_bb {
--
drivers/gpu/drm/i915/gt/intel_engine_types.h=365=struct intel_engine_cs {
--
drivers/gpu/drm/i915/gt/intel_engine_types.h-498- struct intel_hw_status_page status_page;
drivers/gpu/drm/i915/gt/intel_engine_types.h:499: struct i915_ctx_workarounds wa_ctx;
drivers/gpu/drm/i915/gt/intel_engine_types.h-500- struct i915_wa_list ctx_wa_list;
--
drivers/gpu/drm/i915/gt/intel_lrc.c=868=static void init_wa_bb_regs(u32 * const regs,
--
drivers/gpu/drm/i915/gt/intel_lrc.c-870-{
drivers/gpu/drm/i915/gt/intel_lrc.c:871: const struct i915_ctx_workarounds * const wa_ctx = &engine->wa_ctx;
drivers/gpu/drm/i915/gt/intel_lrc.c-872-
--
drivers/gpu/drm/i915/gt/intel_lrc.c=1838=void lrc_init_wa_ctx(struct intel_engine_cs *engine)
drivers/gpu/drm/i915/gt/intel_lrc.c-1839-{
drivers/gpu/drm/i915/gt/intel_lrc.c:1840: struct i915_ctx_workarounds *wa_ctx = &engine->wa_ctx;
drivers/gpu/drm/i915/gt/intel_lrc.c-1841- struct i915_wa_ctx_bb *wa_bb[] = {
--
drivers/gpu/drm/i915/gt/intel_workarounds.c-37- *
drivers/gpu/drm/i915/gt/intel_workarounds.c:38: * Context workarounds should be implemented in the \*_ctx_workarounds_init()
drivers/gpu/drm/i915/gt/intel_workarounds.c-39- * variants respective to the targeted platforms.
--
drivers/gpu/drm/i915/gt/intel_workarounds.c=330=wa_mcr_masked_field_set(struct i915_wa_list *wal, i915_mcr_reg_t reg,
--
drivers/gpu/drm/i915/gt/intel_workarounds.c-335-
drivers/gpu/drm/i915/gt/intel_workarounds.c:336:static void gen6_ctx_workarounds_init(struct intel_engine_cs *engine,
drivers/gpu/drm/i915/gt/intel_workarounds.c-337- struct i915_wa_list *wal)
--
drivers/gpu/drm/i915/gt/intel_workarounds.c-344-
drivers/gpu/drm/i915/gt/intel_workarounds.c:345:static void gen7_ctx_workarounds_init(struct intel_engine_cs *engine,
drivers/gpu/drm/i915/gt/intel_workarounds.c-346- struct i915_wa_list *wal)
--
drivers/gpu/drm/i915/gt/intel_workarounds.c-361-
drivers/gpu/drm/i915/gt/intel_workarounds.c:362:static void gen8_ctx_workarounds_init(struct intel_engine_cs *engine,
drivers/gpu/drm/i915/gt/intel_workarounds.c-363- struct i915_wa_list *wal)
--
drivers/gpu/drm/i915/gt/intel_workarounds.c-409-
drivers/gpu/drm/i915/gt/intel_workarounds.c:410:static void bdw_ctx_workarounds_init(struct intel_engine_cs *engine,
drivers/gpu/drm/i915/gt/intel_workarounds.c-411- struct i915_wa_list *wal)
--
drivers/gpu/drm/i915/gt/intel_workarounds.c-414-
drivers/gpu/drm/i915/gt/intel_workarounds.c:415: gen8_ctx_workarounds_init(engine, wal);
drivers/gpu/drm/i915/gt/intel_workarounds.c-416-
--
drivers/gpu/drm/i915/gt/intel_workarounds.c-437-
drivers/gpu/drm/i915/gt/intel_workarounds.c:438:static void chv_ctx_workarounds_init(struct intel_engine_cs *engine,
drivers/gpu/drm/i915/gt/intel_workarounds.c-439- struct i915_wa_list *wal)
drivers/gpu/drm/i915/gt/intel_workarounds.c-440-{
drivers/gpu/drm/i915/gt/intel_workarounds.c:441: gen8_ctx_workarounds_init(engine, wal);
drivers/gpu/drm/i915/gt/intel_workarounds.c-442-
--
drivers/gpu/drm/i915/gt/intel_workarounds.c-449-
drivers/gpu/drm/i915/gt/intel_workarounds.c:450:static void gen9_ctx_workarounds_init(struct intel_engine_cs *engine,
drivers/gpu/drm/i915/gt/intel_workarounds.c-451- struct i915_wa_list *wal)
--
drivers/gpu/drm/i915/gt/intel_workarounds.c=546=static void skl_tune_iz_hashing(struct intel_engine_cs *engine,
--
drivers/gpu/drm/i915/gt/intel_workarounds.c-585-
drivers/gpu/drm/i915/gt/intel_workarounds.c:586:static void skl_ctx_workarounds_init(struct intel_engine_cs *engine,
drivers/gpu/drm/i915/gt/intel_workarounds.c-587- struct i915_wa_list *wal)
drivers/gpu/drm/i915/gt/intel_workarounds.c-588-{
drivers/gpu/drm/i915/gt/intel_workarounds.c:589: gen9_ctx_workarounds_init(engine, wal);
drivers/gpu/drm/i915/gt/intel_workarounds.c-590- skl_tune_iz_hashing(engine, wal);
--
drivers/gpu/drm/i915/gt/intel_workarounds.c-592-
drivers/gpu/drm/i915/gt/intel_workarounds.c:593:static void bxt_ctx_workarounds_init(struct intel_engine_cs *engine,
drivers/gpu/drm/i915/gt/intel_workarounds.c-594- struct i915_wa_list *wal)
drivers/gpu/drm/i915/gt/intel_workarounds.c-595-{
drivers/gpu/drm/i915/gt/intel_workarounds.c:596: gen9_ctx_workarounds_init(engine, wal);
drivers/gpu/drm/i915/gt/intel_workarounds.c-597-
--
drivers/gpu/drm/i915/gt/intel_workarounds.c-606-
drivers/gpu/drm/i915/gt/intel_workarounds.c:607:static void kbl_ctx_workarounds_init(struct intel_engine_cs *engine,
drivers/gpu/drm/i915/gt/intel_workarounds.c-608- struct i915_wa_list *wal)
--
drivers/gpu/drm/i915/gt/intel_workarounds.c-611-
drivers/gpu/drm/i915/gt/intel_workarounds.c:612: gen9_ctx_workarounds_init(engine, wal);
drivers/gpu/drm/i915/gt/intel_workarounds.c-613-
--
drivers/gpu/drm/i915/gt/intel_workarounds.c-623-
drivers/gpu/drm/i915/gt/intel_workarounds.c:624:static void glk_ctx_workarounds_init(struct intel_engine_cs *engine,
drivers/gpu/drm/i915/gt/intel_workarounds.c-625- struct i915_wa_list *wal)
drivers/gpu/drm/i915/gt/intel_workarounds.c-626-{
drivers/gpu/drm/i915/gt/intel_workarounds.c:627: gen9_ctx_workarounds_init(engine, wal);
drivers/gpu/drm/i915/gt/intel_workarounds.c-628-
--
drivers/gpu/drm/i915/gt/intel_workarounds.c-633-
drivers/gpu/drm/i915/gt/intel_workarounds.c:634:static void cfl_ctx_workarounds_init(struct intel_engine_cs *engine,
drivers/gpu/drm/i915/gt/intel_workarounds.c-635- struct i915_wa_list *wal)
drivers/gpu/drm/i915/gt/intel_workarounds.c-636-{
drivers/gpu/drm/i915/gt/intel_workarounds.c:637: gen9_ctx_workarounds_init(engine, wal);
drivers/gpu/drm/i915/gt/intel_workarounds.c-638-
--
drivers/gpu/drm/i915/gt/intel_workarounds.c-647-
drivers/gpu/drm/i915/gt/intel_workarounds.c:648:static void icl_ctx_workarounds_init(struct intel_engine_cs *engine,
drivers/gpu/drm/i915/gt/intel_workarounds.c-649- struct i915_wa_list *wal)
--
drivers/gpu/drm/i915/gt/intel_workarounds.c=703=static void dg2_ctx_gt_tuning_init(struct intel_engine_cs *engine,
--
drivers/gpu/drm/i915/gt/intel_workarounds.c-712-
drivers/gpu/drm/i915/gt/intel_workarounds.c:713:static void gen12_ctx_workarounds_init(struct intel_engine_cs *engine,
drivers/gpu/drm/i915/gt/intel_workarounds.c-714- struct i915_wa_list *wal)
--
drivers/gpu/drm/i915/gt/intel_workarounds.c-777-
drivers/gpu/drm/i915/gt/intel_workarounds.c:778:static void dg1_ctx_workarounds_init(struct intel_engine_cs *engine,
drivers/gpu/drm/i915/gt/intel_workarounds.c-779- struct i915_wa_list *wal)
drivers/gpu/drm/i915/gt/intel_workarounds.c-780-{
drivers/gpu/drm/i915/gt/intel_workarounds.c:781: gen12_ctx_workarounds_init(engine, wal);
drivers/gpu/drm/i915/gt/intel_workarounds.c-782-
--
drivers/gpu/drm/i915/gt/intel_workarounds.c-791-
drivers/gpu/drm/i915/gt/intel_workarounds.c:792:static void dg2_ctx_workarounds_init(struct intel_engine_cs *engine,
drivers/gpu/drm/i915/gt/intel_workarounds.c-793- struct i915_wa_list *wal)
--
drivers/gpu/drm/i915/gt/intel_workarounds.c=814=static void xelpg_ctx_gt_tuning_init(struct intel_engine_cs *engine,
--
drivers/gpu/drm/i915/gt/intel_workarounds.c-830-
drivers/gpu/drm/i915/gt/intel_workarounds.c:831:static void xelpg_ctx_workarounds_init(struct intel_engine_cs *engine,
drivers/gpu/drm/i915/gt/intel_workarounds.c-832- struct i915_wa_list *wal)
--
drivers/gpu/drm/i915/gt/intel_workarounds.c=929=__intel_engine_init_ctx_wa(struct intel_engine_cs *engine,
--
drivers/gpu/drm/i915/gt/intel_workarounds.c-948- if (IS_GFX_GT_IP_RANGE(engine->gt, IP_VER(12, 70), IP_VER(12, 74)))
drivers/gpu/drm/i915/gt/intel_workarounds.c:949: xelpg_ctx_workarounds_init(engine, wal);
drivers/gpu/drm/i915/gt/intel_workarounds.c-950- else if (IS_DG2(i915))
drivers/gpu/drm/i915/gt/intel_workarounds.c:951: dg2_ctx_workarounds_init(engine, wal);
drivers/gpu/drm/i915/gt/intel_workarounds.c-952- else if (IS_DG1(i915))
drivers/gpu/drm/i915/gt/intel_workarounds.c:953: dg1_ctx_workarounds_init(engine, wal);
drivers/gpu/drm/i915/gt/intel_workarounds.c-954- else if (GRAPHICS_VER(i915) == 12)
drivers/gpu/drm/i915/gt/intel_workarounds.c:955: gen12_ctx_workarounds_init(engine, wal);
drivers/gpu/drm/i915/gt/intel_workarounds.c-956- else if (GRAPHICS_VER(i915) == 11)
drivers/gpu/drm/i915/gt/intel_workarounds.c:957: icl_ctx_workarounds_init(engine, wal);
drivers/gpu/drm/i915/gt/intel_workarounds.c-958- else if (IS_COFFEELAKE(i915) || IS_COMETLAKE(i915))
drivers/gpu/drm/i915/gt/intel_workarounds.c:959: cfl_ctx_workarounds_init(engine, wal);
drivers/gpu/drm/i915/gt/intel_workarounds.c-960- else if (IS_GEMINILAKE(i915))
drivers/gpu/drm/i915/gt/intel_workarounds.c:961: glk_ctx_workarounds_init(engine, wal);
drivers/gpu/drm/i915/gt/intel_workarounds.c-962- else if (IS_KABYLAKE(i915))
drivers/gpu/drm/i915/gt/intel_workarounds.c:963: kbl_ctx_workarounds_init(engine, wal);
drivers/gpu/drm/i915/gt/intel_workarounds.c-964- else if (IS_BROXTON(i915))
drivers/gpu/drm/i915/gt/intel_workarounds.c:965: bxt_ctx_workarounds_init(engine, wal);
drivers/gpu/drm/i915/gt/intel_workarounds.c-966- else if (IS_SKYLAKE(i915))
drivers/gpu/drm/i915/gt/intel_workarounds.c:967: skl_ctx_workarounds_init(engine, wal);
drivers/gpu/drm/i915/gt/intel_workarounds.c-968- else if (IS_CHERRYVIEW(i915))
drivers/gpu/drm/i915/gt/intel_workarounds.c:969: chv_ctx_workarounds_init(engine, wal);
drivers/gpu/drm/i915/gt/intel_workarounds.c-970- else if (IS_BROADWELL(i915))
drivers/gpu/drm/i915/gt/intel_workarounds.c:971: bdw_ctx_workarounds_init(engine, wal);
drivers/gpu/drm/i915/gt/intel_workarounds.c-972- else if (GRAPHICS_VER(i915) == 7)
drivers/gpu/drm/i915/gt/intel_workarounds.c:973: gen7_ctx_workarounds_init(engine, wal);
drivers/gpu/drm/i915/gt/intel_workarounds.c-974- else if (GRAPHICS_VER(i915) == 6)
drivers/gpu/drm/i915/gt/intel_workarounds.c:975: gen6_ctx_workarounds_init(engine, wal);
drivers/gpu/drm/i915/gt/intel_workarounds.c-976- else if (GRAPHICS_VER(i915) < 8)
--
drivers/gpu/drm/i915/gt/intel_workarounds.c=2233=rcs_engine_wa_init(struct intel_engine_cs *engine, struct i915_wa_list *wal)
--
drivers/gpu/drm/i915/gt/intel_workarounds.c-2427- * object-level preemption disabled by default (see
drivers/gpu/drm/i915/gt/intel_workarounds.c:2428: * WaDisable3DMidCmdPreemption in gen9_ctx_workarounds_init), but
drivers/gpu/drm/i915/gt/intel_workarounds.c-2429- * userspace drivers could opt-in to object-level preemption as they
--
drivers/gpu/drm/panthor/panthor_mmu.c=392=struct panthor_vm_bind_job {
--
drivers/gpu/drm/panthor/panthor_mmu.c-398-
drivers/gpu/drm/panthor/panthor_mmu.c:399: /** @cleanup_op_ctx_work: Work used to cleanup the VM operation context. */
drivers/gpu/drm/panthor/panthor_mmu.c:400: struct work_struct cleanup_op_ctx_work;
drivers/gpu/drm/panthor/panthor_mmu.c-401-
--
drivers/gpu/drm/panthor/panthor_mmu.c=2365=panthor_vm_bind_free_job(struct drm_sched_job *sched_job)
--
drivers/gpu/drm/panthor/panthor_mmu.c-2374- */
drivers/gpu/drm/panthor/panthor_mmu.c:2375: queue_work(panthor_cleanup_wq, &job->cleanup_op_ctx_work);
drivers/gpu/drm/panthor/panthor_mmu.c-2376-}
--
drivers/gpu/drm/panthor/panthor_mmu.c=2525=panthor_vm_bind_prepare_op_ctx(struct drm_file *file,
--
drivers/gpu/drm/panthor/panthor_mmu.c-2579-
drivers/gpu/drm/panthor/panthor_mmu.c:2580:static void panthor_vm_bind_job_cleanup_op_ctx_work(struct work_struct *work)
drivers/gpu/drm/panthor/panthor_mmu.c-2581-{
drivers/gpu/drm/panthor/panthor_mmu.c-2582- struct panthor_vm_bind_job *job =
drivers/gpu/drm/panthor/panthor_mmu.c:2583: container_of(work, struct panthor_vm_bind_job, cleanup_op_ctx_work);
drivers/gpu/drm/panthor/panthor_mmu.c-2584-
--
drivers/gpu/drm/panthor/panthor_mmu.c=2597=panthor_vm_bind_job_create(struct drm_file *file,
--
drivers/gpu/drm/panthor/panthor_mmu.c-2619-
drivers/gpu/drm/panthor/panthor_mmu.c:2620: INIT_WORK(&job->cleanup_op_ctx_work, panthor_vm_bind_job_cleanup_op_ctx_work);
drivers/gpu/drm/panthor/panthor_mmu.c-2621- kref_init(&job->refcount);
--
drivers/greybus/gb-beagleplay.c-48- *
drivers/greybus/gb-beagleplay.c:49: * @tx_work: hdlc transmit work
drivers/greybus/gb-beagleplay.c-50- * @tx_producer_lock: hdlc transmit data producer lock. acquired when appending data to buffer.
--
drivers/greybus/gb-beagleplay.c=70=struct gb_beagleplay {
--
drivers/greybus/gb-beagleplay.c-74-
drivers/greybus/gb-beagleplay.c:75: struct work_struct tx_work;
drivers/greybus/gb-beagleplay.c-76- spinlock_t tx_producer_lock;
--
drivers/greybus/gb-beagleplay.c=307=static void hdlc_transmit(struct work_struct *work)
drivers/greybus/gb-beagleplay.c-308-{
drivers/greybus/gb-beagleplay.c:309: struct gb_beagleplay *bg = container_of(work, struct gb_beagleplay, tx_work);
drivers/greybus/gb-beagleplay.c-310-
--
drivers/greybus/gb-beagleplay.c=316=static void hdlc_tx_frames(struct gb_beagleplay *bg, u8 address, u8 control,
--
drivers/greybus/gb-beagleplay.c-334-
drivers/greybus/gb-beagleplay.c:335: schedule_work(&bg->tx_work);
drivers/greybus/gb-beagleplay.c-336-}
--
drivers/greybus/gb-beagleplay.c=412=static int hdlc_init(struct gb_beagleplay *bg)
drivers/greybus/gb-beagleplay.c-413-{
drivers/greybus/gb-beagleplay.c:414: INIT_WORK(&bg->tx_work, hdlc_transmit);
drivers/greybus/gb-beagleplay.c-415- spin_lock_init(&bg->tx_producer_lock);
--
drivers/greybus/gb-beagleplay.c=430=static void hdlc_deinit(struct gb_beagleplay *bg)
drivers/greybus/gb-beagleplay.c-431-{
drivers/greybus/gb-beagleplay.c:432: flush_work(&bg->tx_work);
drivers/greybus/gb-beagleplay.c-433-}
--
drivers/greybus/gb-beagleplay.c=567=static void gb_tty_wakeup(struct serdev_device *serdev)
--
drivers/greybus/gb-beagleplay.c-571- if (!READ_ONCE(bg->flashing_mode))
drivers/greybus/gb-beagleplay.c:572: schedule_work(&bg->tx_work);
drivers/greybus/gb-beagleplay.c-573-}
--
drivers/greybus/gb-beagleplay.c=860=static enum fw_upload_err cc1352_prepare(struct fw_upload *fw_upload,
--
drivers/greybus/gb-beagleplay.c-877- msleep(200);
drivers/greybus/gb-beagleplay.c:878: flush_work(&bg->tx_work);
drivers/greybus/gb-beagleplay.c-879-
--
drivers/hsi/controllers/omap_ssi_port.c=510=static int ssi_flush(struct hsi_client *cl)
--
drivers/hsi/controllers/omap_ssi_port.c-574-
drivers/hsi/controllers/omap_ssi_port.c:575:static void start_tx_work(struct work_struct *work)
drivers/hsi/controllers/omap_ssi_port.c-576-{
--
drivers/hsi/controllers/omap_ssi_port.c=1108=static int ssi_port_probe(struct platform_device *pd)
--
drivers/hsi/controllers/omap_ssi_port.c-1162- INIT_DEFERRABLE_WORK(&omap_port->errqueue_work, ssi_process_errqueue);
drivers/hsi/controllers/omap_ssi_port.c:1163: INIT_WORK(&omap_port->work, start_tx_work);
drivers/hsi/controllers/omap_ssi_port.c-1164-
--
drivers/infiniband/sw/siw/siw_qp_rx.c=656=static int siw_init_rresp(struct siw_qp *qp, struct siw_rx_stream *srx)
drivers/infiniband/sw/siw/siw_qp_rx.c-657-{
drivers/infiniband/sw/siw/siw_qp_rx.c:658: struct siw_wqe *tx_work = tx_wqe(qp);
drivers/infiniband/sw/siw/siw_qp_rx.c-659- struct siw_sqe *resp;
--
drivers/infiniband/sw/siw/siw_qp_rx.c-682- }
drivers/infiniband/sw/siw/siw_qp_rx.c:683: if (tx_work->wr_status == SIW_WR_IDLE) {
drivers/infiniband/sw/siw/siw_qp_rx.c-684- /*
--
drivers/infiniband/sw/siw/siw_qp_rx.c-687- */
drivers/infiniband/sw/siw/siw_qp_rx.c:688: tx_work->processed = 0;
drivers/infiniband/sw/siw/siw_qp_rx.c:689: tx_work->mem[0] = NULL;
drivers/infiniband/sw/siw/siw_qp_rx.c:690: tx_work->wr_status = SIW_WR_QUEUED;
drivers/infiniband/sw/siw/siw_qp_rx.c:691: resp = &tx_work->sqe;
drivers/infiniband/sw/siw/siw_qp_rx.c-692- } else {
--
drivers/input/serio/ps2-gpio.c=130=static int ps2_gpio_write(struct serio *serio, unsigned char val)
--
drivers/input/serio/ps2-gpio.c-148-
drivers/input/serio/ps2-gpio.c:149:static void ps2_gpio_tx_work_fn(struct work_struct *work)
drivers/input/serio/ps2-gpio.c-150-{
--
drivers/input/serio/ps2-gpio.c=400=static int ps2_gpio_probe(struct platform_device *pdev)
--
drivers/input/serio/ps2-gpio.c-462-
drivers/input/serio/ps2-gpio.c:463: INIT_DELAYED_WORK(&drvdata->tx.work, ps2_gpio_tx_work_fn);
drivers/input/serio/ps2-gpio.c-464- init_completion(&drvdata->tx.complete);
--
drivers/media/cec/usb/pulse8/pulse8-cec.c=173=struct pulse8 {
--
drivers/media/cec/usb/pulse8/pulse8-cec.c-188-
drivers/media/cec/usb/pulse8/pulse8-cec.c:189: struct work_struct tx_work;
drivers/media/cec/usb/pulse8/pulse8-cec.c-190- u32 tx_done_status;
--
drivers/media/cec/usb/pulse8/pulse8-cec.c=264=static int pulse8_send_and_wait(struct pulse8 *pulse8,
--
drivers/media/cec/usb/pulse8/pulse8-cec.c-283-
drivers/media/cec/usb/pulse8/pulse8-cec.c:284:static void pulse8_tx_work_handler(struct work_struct *work)
drivers/media/cec/usb/pulse8/pulse8-cec.c-285-{
drivers/media/cec/usb/pulse8/pulse8-cec.c:286: struct pulse8 *pulse8 = container_of(work, struct pulse8, tx_work);
drivers/media/cec/usb/pulse8/pulse8-cec.c-287- struct cec_msg *msg = &pulse8->tx_msg;
--
drivers/media/cec/usb/pulse8/pulse8-cec.c=623=static int pulse8_cec_adap_transmit(struct cec_adapter *adap, u8 attempts,
--
drivers/media/cec/usb/pulse8/pulse8-cec.c-632- pulse8->tx_signal_free_time = signal_free_time;
drivers/media/cec/usb/pulse8/pulse8-cec.c:633: schedule_work(&pulse8->tx_work);
drivers/media/cec/usb/pulse8/pulse8-cec.c-634- return 0;
--
drivers/media/cec/usb/pulse8/pulse8-cec.c=637=static void pulse8_cec_adap_free(struct cec_adapter *adap)
--
drivers/media/cec/usb/pulse8/pulse8-cec.c-642- cancel_work_sync(&pulse8->irq_work);
drivers/media/cec/usb/pulse8/pulse8-cec.c:643: cancel_work_sync(&pulse8->tx_work);
drivers/media/cec/usb/pulse8/pulse8-cec.c-644- kfree(pulse8);
--
drivers/media/cec/usb/pulse8/pulse8-cec.c=835=static int pulse8_connect(struct serio *serio, struct serio_driver *drv)
--
drivers/media/cec/usb/pulse8/pulse8-cec.c-859- INIT_WORK(&pulse8->irq_work, pulse8_irq_work_handler);
drivers/media/cec/usb/pulse8/pulse8-cec.c:860: INIT_WORK(&pulse8->tx_work, pulse8_tx_work_handler);
drivers/media/cec/usb/pulse8/pulse8-cec.c-861- INIT_DELAYED_WORK(&pulse8->ping_eeprom_work,
--
drivers/media/pci/cx23885/cx23885-core.c=1967=static void cx23885_v4l2_dev_notify_init(struct cx23885_dev *dev)
--
drivers/media/pci/cx23885/cx23885-core.c-1970- INIT_WORK(&dev->ir_rx_work, cx23885_ir_rx_work_handler);
drivers/media/pci/cx23885/cx23885-core.c:1971: INIT_WORK(&dev->ir_tx_work, cx23885_ir_tx_work_handler);
drivers/media/pci/cx23885/cx23885-core.c-1972- dev->v4l2_dev.notify = cx23885_v4l2_dev_notify;
--
drivers/media/pci/cx23885/cx23885-input.c=222=static void cx23885_input_ir_stop(struct cx23885_dev *dev)
--
drivers/media/pci/cx23885/cx23885-input.c-246- flush_work(&dev->ir_rx_work);
drivers/media/pci/cx23885/cx23885-input.c:247: flush_work(&dev->ir_tx_work);
drivers/media/pci/cx23885/cx23885-input.c-248-}
--
drivers/media/pci/cx23885/cx23885-ir.c=24=void cx23885_ir_rx_work_handler(struct work_struct *work)
--
drivers/media/pci/cx23885/cx23885-ir.c-46-
drivers/media/pci/cx23885/cx23885-ir.c:47:void cx23885_ir_tx_work_handler(struct work_struct *work)
drivers/media/pci/cx23885/cx23885-ir.c-48-{
drivers/media/pci/cx23885/cx23885-ir.c-49- struct cx23885_dev *dev =
drivers/media/pci/cx23885/cx23885-ir.c:50: container_of(work, struct cx23885_dev, ir_tx_work);
drivers/media/pci/cx23885/cx23885-ir.c-51- u32 events = 0;
--
drivers/media/pci/cx23885/cx23885-ir.c=88=void cx23885_ir_tx_v4l2_dev_notify(struct v4l2_subdev *sd, u32 events)
--
drivers/media/pci/cx23885/cx23885-ir.c-100- if (sd == dev->sd_cx25840)
drivers/media/pci/cx23885/cx23885-ir.c:101: cx23885_ir_tx_work_handler(&dev->ir_tx_work);
drivers/media/pci/cx23885/cx23885-ir.c-102- else
]
]
|
| 112/2 |
2026/05/25 13:39 |
llm |
expert |
0m
Model:
Tokens:
input: 113246
output: 43
thoughts: 41
Thoughts: Here's my thought process, summarized as if I were considering the code:
**Digging into the SLIP Driver's TX Path**
Okay, so `slip_write_wakeup` schedules `sl->tx_work`. That's a key clue. I need to understand what's happening when data is sent out over SLIP. I'll need to confirm what the function `sl_tx_work` does in `drivers/net/slip/slip.c`. That's where the actual transmission logic likely resides. Let's get right to it and see how data is actually placed on the wire. I bet there's some interesting framing going on in there.
|
| 113/2 |
2026/05/25 13:40 |
tool |
codesearch-definition-source |
0m
Error:
Args: map[ContextFile:drivers/net/slip/slip.c IncludeLines:true Name:sl_tx_work]
Results: map[SourceCode: SourceFile:]
|
| 114/2 |
2026/05/25 13:40 |
llm |
expert |
0m
Model:
Tokens:
input: 113496
output: 19
thoughts: 13
Thoughts: Here's my take on the thought process, as requested:
**Deconstructing the `sl_tx_work` Definition**
Okay, so I need to get a handle on what's going on with `sl_tx_work`. It's pretty obvious this is a crucial element in our system – likely related to the transmit side of things, given the "tx" in the name. "Work" is vague, of course. I'll need to dig into the definition to really understand its purpose and behavior. Is it a function, a data structure, a macro? My expertise tells me it could be any of these, or a combination. The context surrounding its usage will be crucial, but understanding the raw definition is the first necessary step. Time to dive in and get the details.
|
| 115/2 |
2026/05/25 13:40 |
tool |
grepper |
0m
Error:
Args: map[Expression:sl_tx_work]
Results:
|
| 116/2 |
2026/05/25 13:40 |
llm |
expert |
0m
Model:
Tokens:
input: 113708
output: 19
thoughts: 16
Thoughts: Here's my thought process, as if I were considering this search:
**Diving into the `slip.c` Source**
Okay, I need to find where `tx_work` is defined or used within the `slip.c` file. This sounds like I'm dealing with a potentially crucial component of SLIP (Serial Line Internet Protocol) implementation. The term `tx_work` suggests it's related to the transmission (TX) side, likely some kind of work queue or function responsible for handling outgoing data.
First, I'll use the search tools; likely I'll start with a grep, or maybe a more sophisticated search tool if this is part of a larger codebase. My goal is to find all instances of `tx_work`. I'll pay close attention to context - is it a variable name, a function name, a macro, or something else? Understanding the context will be key. Is this part of a driver, a networking stack component, or something more specialized?
I anticipate seeing it in function calls, variable declarations, or possibly as part of a data structure. I'll need to analyze the surrounding code to determine how `tx_work` interacts with other functions and data structures involved in the SLIP transmission process. I'll be looking for clues about the work's nature. Is it scheduling, buffering, framing, or actual hardware interaction? I'll need to understand the logic behind how the transmission work is initiated, how it's executed, and how it handles errors or completions. I'll note any locking or synchronization mechanisms associated with `tx_work`, as concurrent access to transmission resources is a common challenge.
Given the name, and the domain, it's likely a critical piece of the puzzle for understanding data transmission. I'm keen to get to the bottom of this.
|
| 117/2 |
2026/05/25 13:40 |
tool |
grepper |
0m
Args: map[Expression:tx_work.*slip]
Results: map[Output:drivers/net/slip/slip.c=739=static struct slip *sl_alloc(void)
--
drivers/net/slip/slip.c-766- spin_lock_init(&sl->lock);
drivers/net/slip/slip.c:767: INIT_WORK(&sl->tx_work, slip_transmit);
drivers/net/slip/slip.c-768- sl->mode = SL_MODE_DEFAULT;
]
|
| 118/2 |
2026/05/25 13:40 |
llm |
expert |
0m
Model:
Tokens:
input: 114249
output: 41
thoughts: 8
Thoughts: Okay, here's the summary, assuming I'm a seasoned professional and this "slip_transmit" concept has just come to mind:
**Initial Assessment of `slip_transmit`**
Ah, `slip_transmit`! Right away, that brings up some interesting possibilities. My mind immediately starts running through the implications of using a slip transmission scheme. Is this regarding physical layer protocols or is this regarding a higher layer? I need to clarify what the context is. Are we talking about intentional use, or is this an error condition that needs mitigation? Is this about the transmitter slipping bits, frames, or packets?
I need to quickly assess if this refers to the asynchronous nature of the data flow, the error control coding, or perhaps it relates to clock recovery and synchronization. Is it related to congestion management? Or maybe it's linked to the concept of 'slip frames', which I've seen in some older SONET/SDH implementations, where a frame is intentionally dropped or duplicated for synchronization purposes.
I need to consider the trade-offs. The potential benefits: perhaps improved throughput in certain scenarios, or resilience to specific types of channel impairments. But, the potential drawbacks are also instantly obvious: increased complexity, potential for data loss or corruption if not implemented carefully, and the need for sophisticated receiver-side processing.
I'm making a mental checklist of questions to ask, requirements to consider, and potential implementation pitfalls to watch out for. I'd need to dive deeper into the specific application. Then I'd need to determine what specific characteristics of the application make `slip_transmit` a suitable technique.
|
| 119/2 |
2026/05/25 13:40 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/net/slip/slip.c IncludeLines:true Name:slip_transmit]
Results: map[SourceCode: 421: /* Write out any remaining transmit buffer. Scheduled when tty is writable */
422: static void slip_transmit(struct work_struct *work)
423: {
424: struct slip *sl = container_of(work, struct slip, tx_work);
425: int actual;
426:
427: spin_lock_bh(&sl->lock);
428: /* First make sure we're connected. */
429: if (!sl->tty || sl->magic != SLIP_MAGIC || !netif_running(sl->dev)) {
430: spin_unlock_bh(&sl->lock);
431: return;
432: }
433:
434: if (sl->xleft <= 0) {
435: /* Now serial buffer is almost free & we can start
436: * transmission of another packet */
437: sl->dev->stats.tx_packets++;
438: clear_bit(TTY_DO_WRITE_WAKEUP, &sl->tty->flags);
439: spin_unlock_bh(&sl->lock);
440: sl_unlock(sl);
441: return;
442: }
443:
444: actual = sl->tty->ops->write(sl->tty, sl->xhead, sl->xleft);
445: sl->xleft -= actual;
446: sl->xhead += actual;
447: spin_unlock_bh(&sl->lock);
448: }
SourceFile:drivers/net/slip/slip.c]
|
| 120/2 |
2026/05/25 13:40 |
llm |
expert |
0m
Model:
Tokens:
input: 115097
output: 48
thoughts: 84
Thoughts: Okay, let me think this through.
**Analyzing the Potential for an Infinite Loop in the Code**
So, `slip_transmit` calls the `write` operation on the tty device, passing in the data. The crucial part here is the conditional: if the amount of data actually written (`actual`) is zero, then `sl->xleft` remains unchanged. That's a key observation.
But it *doesn't* loop. The function simply returns after that `write` call, regardless of how much was written. Therefore, the implementation in `slip` definitely *doesn't* have an infinite loop bug, because the loop condition, or lack thereof, is explicitly defined. I would expect it to return and for another process to call it.
Okay, so `slip` is fine. Now, what about `slcan`? I need to check the exact same logic there, to make sure it functions in the same way.
|
| 121/2 |
2026/05/25 13:40 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/net/can/slcan/slcan-core.c IncludeLines:true Name:slcan_transmit]
Results: map[SourceCode: 557: /* Write out any remaining transmit buffer. Scheduled when tty is writable */
558: static void slcan_transmit(struct work_struct *work)
559: {
560: struct slcan *sl = container_of(work, struct slcan, tx_work);
561: int actual;
562:
563: spin_lock_bh(&sl->lock);
564: /* First make sure we're connected. */
565: if (unlikely(!netif_running(sl->dev)) &&
566: likely(!test_bit(SLF_XCMD, &sl->flags))) {
567: spin_unlock_bh(&sl->lock);
568: return;
569: }
570:
571: if (sl->xleft <= 0) {
572: if (unlikely(test_bit(SLF_XCMD, &sl->flags))) {
573: clear_bit(SLF_XCMD, &sl->flags);
574: clear_bit(TTY_DO_WRITE_WAKEUP, &sl->tty->flags);
575: spin_unlock_bh(&sl->lock);
576: wake_up(&sl->xcmd_wait);
577: return;
578: }
579:
580: /* Now serial buffer is almost free & we can start
581: * transmission of another packet
582: */
583: sl->dev->stats.tx_packets++;
584: clear_bit(TTY_DO_WRITE_WAKEUP, &sl->tty->flags);
585: spin_unlock_bh(&sl->lock);
586: netif_wake_queue(sl->dev);
587: return;
588: }
589:
590: actual = sl->tty->ops->write(sl->tty, sl->xhead, sl->xleft);
591: sl->xleft -= actual;
592: sl->xhead += actual;
593: spin_unlock_bh(&sl->lock);
594: }
SourceFile:drivers/net/can/slcan/slcan-core.c]
|
| 122/2 |
2026/05/25 13:40 |
llm |
expert |
0m
Model:
Tokens:
input: 116066
output: 45
thoughts: 19
Thoughts: Here's my thought process, summarized as you requested:
**Considering Alternatives to Looping with `slcan`**
Okay, so `slcan` is out because it doesn't loop. That's a critical constraint for what I'm trying to achieve. I need to find something that *does* loop. The question now is, what's another option? Let's see... what about `ppp_async`? I need to quickly evaluate if that's a viable path forward. I need to consider its capabilities, its suitability for the hardware and the application, and if it's got the looping functionality that I require. Let's dig deeper into that.
|
| 123/2 |
2026/05/25 13:40 |
tool |
codesearch-definition-source |
0m
Args: map[ContextFile:drivers/net/ppp/ppp_async.c IncludeLines:true Name:ppp_async_push]
Results: map[SourceCode: 638: /*
639: * Push as much data as possible out to the tty.
640: */
641: static int
642: ppp_async_push(struct asyncppp *ap)
643: {
644: int avail, sent, done = 0;
645: struct tty_struct *tty = ap->tty;
646: int tty_stuffed = 0;
647:
648: /*
649: * We can get called recursively here if the tty write
650: * function calls our wakeup function. This can happen
651: * for example on a pty with both the master and slave
652: * set to PPP line discipline.
653: * We use the XMIT_BUSY bit to detect this and get out,
654: * leaving the XMIT_WAKEUP bit set to tell the other
655: * instance that it may now be able to write more now.
656: */
657: if (test_and_set_bit(XMIT_BUSY, &ap->xmit_flags))
658: return 0;
659: spin_lock_bh(&ap->xmit_lock);
660: for (;;) {
661: if (test_and_clear_bit(XMIT_WAKEUP, &ap->xmit_flags))
662: tty_stuffed = 0;
663: if (!tty_stuffed && ap->optr < ap->olim) {
664: avail = ap->olim - ap->optr;
665: set_bit(TTY_DO_WRITE_WAKEUP, &tty->flags);
666: sent = tty->ops->write(tty, ap->optr, avail);
667: if (sent < 0)
668: goto flush; /* error, e.g. loss of CD */
669: ap->optr += sent;
670: if (sent < avail)
671: tty_stuffed = 1;
672: continue;
673: }
674: if (ap->optr >= ap->olim && ap->tpkt) {
675: if (ppp_async_encode(ap)) {
676: /* finished processing ap->tpkt */
677: clear_bit(XMIT_FULL, &ap->xmit_flags);
678: done = 1;
679: }
680: continue;
681: }
682: /*
683: * We haven't made any progress this time around.
684: * Clear XMIT_BUSY to let other callers in, but
685: * after doing so we have to check if anyone set
686: * XMIT_WAKEUP since we last checked it. If they
687: * did, we should try again to set XMIT_BUSY and go
688: * around again in case XMIT_BUSY was still set when
689: * the other caller tried.
690: */
691: clear_bit(XMIT_BUSY, &ap->xmit_flags);
692: /* any more work to do? if not, exit the loop */
693: if (!(test_bit(XMIT_WAKEUP, &ap->xmit_flags) ||
694: (!tty_stuffed && ap->tpkt)))
695: break;
696: /* more work to do, see if we can do it now */
697: if (test_and_set_bit(XMIT_BUSY, &ap->xmit_flags))
698: break;
699: }
700: spin_unlock_bh(&ap->xmit_lock);
701: return done;
702:
703: flush:
704: clear_bit(XMIT_BUSY, &ap->xmit_flags);
705: if (ap->tpkt) {
706: kfree_skb(ap->tpkt);
707: ap->tpkt = NULL;
708: clear_bit(XMIT_FULL, &ap->xmit_flags);
709: done = 1;
710: }
711: ap->optr = ap->olim;
712: spin_unlock_bh(&ap->xmit_lock);
713: return done;
714: }
SourceFile:drivers/net/ppp/ppp_async.c]
|
| 124/2 |
2026/05/25 13:40 |
llm |
expert |
0m
Model:
Tokens:
input: 117561
output: 66
thoughts: 1008
Thoughts: **Analysis of the Infinite Loop Bug in `caif_serial`**
Okay, so I've been digging into this infinite loop within the `ppp_async_push` function, and here's what I've figured out. The core of the problem lies within this loop structure:
```c
for (;;) {
if (test_and_clear_bit(XMIT_WAKEUP, &ap->xmit_flags))
tty_stuffed = 0;
if (!tty_stuffed && ap->optr < ap->olim) {
avail = ap->olim - ap->optr;
set_bit(TTY_DO_WRITE_WAKEUP, &tty->flags);
sent = tty->ops->write(tty, ap->optr, avail);
if (sent < 0)
goto flush; /* error, e.g. loss of CD */
ap->optr += sent;
if (sent < avail)
tty_stuffed = 1;
continue;
}
```
The issue arises when `tty->ops->write()` returns `sent == 0`. This sets `tty_stuffed = 1`, which then *intentionally* skips the write attempt in the next loop iteration. This is valid code. It's meant to backpressure the TTY if the underlying driver can't accept any data at that moment. The loop checks if the write can continue or needs to wait.
The key to the *bug* is that `caif_serial` is the driver involved in causing the infinite loop. If `ap->optr >= ap->olim` the loop breaks, but if `tty_stuffed` is set to one, the loop is skipped.
The implications are clear: This is a Denial of Service vulnerability. However, it's *not* exploitable in a typical sense, based on what I can see. Here's why:
* **Privilege Required:** Triggering this bug necessitates `CAP_SYS_ADMIN` or `CAP_SYS_TTY_CONFIG`. The `capable()` check in the code confirms this. Unprivileged users *cannot* attach `caif_serial`, thereby preventing them from inducing this state. So, the bug is not Unprivileged or UserNamespace.
* **Triggering Scenarios:** The bug is only likely to happen during the shutdown of the TTY. It requires specific timing issues.
* **Remote/Network Trigger:** A remote attacker *cannot* directly exploit this. Even if a CAIF serial link is remotely connected and sending data, the shutdown of the interface must be triggered (likely by root) at the same time. The timing to cause this is practically impossible to rely upon.
* **Virtualization:** This cannot be triggered reliably within a VM guest or host, no Network, Remote or Filesystem triggers.
* **Peripheral Devices:** The bug *could* potentially be triggered by a peripheral device if the system is misconfigured to automatically attach `caif_serial` to it, and then the device is unplugged while transmitting data. But this would be a highly unusual setup and not the default behavior. It is not likely.
Therefore, my assessment is:
* **Exploitable: false**
* **DenialOfService: true**
* **Unprivileged: false**
* **UserNamespace: false**
* **VMGuestTrigger: false**
* **VMHostTrigger: false**
* **NetworkTrigger: false**
* **RemoteTrigger: false**
* **PeripheralTrigger: false**
* **FilesystemTrigger: false**
I've also quickly revisited the potential for other related attack vectors, like AoE (ATA over Ethernet). `aoe` requires root to trigger, and relies on an external Ethernet network to send/receive AoE packets. The infinite loop doesn't happen with standard `aoe` packet operations. The race condition of `caif_serial` shutdown is very hard to win reliably, so `aoe` is not a viable trigger. So I am confident in my assessment.
|
| 125/2 |
2026/05/25 13:40 |
tool |
set-results |
0m
Args: map[DenialOfService:true Exploitable:false FilesystemTrigger:false NetworkTrigger:false PeripheralTrigger:false RemoteTrigger:false Unprivileged:false UserNamespace:false VMGuestTrigger:false VMHostTrigger:false]
Results: map[DenialOfService:true Exploitable:false FilesystemTrigger:false NetworkTrigger:false PeripheralTrigger:false RemoteTrigger:false Unprivileged:false UserNamespace:false VMGuestTrigger:false VMHostTrigger:false]
|
| 126/2 |
2026/05/25 13:40 |
llm |
expert |
1m
Model:
Tokens:
input: 119604
output: 900
thoughts: 13
Thoughts: Okay, here's the summary, tailored for an expert audience, in the first person:
**Finalizing the Analysis & Response**
Alright, the deep dive is done. The model is trained, the data is sliced, diced, and understood. The nuances, the edge cases, the correlations, all considered. I've wrung the information dry and now I'm ready to craft the final response. It's time to synthesize everything and present a coherent, defensible conclusion. No more iterations on the analytical side; my understanding is firm. Let's make sure I convey this with precision and clarity.
|
| 127/1 |
2026/05/25 13:41 |
action |
format-explanation |
0m
Results: map[Explanation:**Bug Analysis:**
The bug report indicates a softlockup (RCU stall) in the `caif_serial` network
device driver, specifically within the `handle_tx` function.
1. **Root Cause:**
The `caif_serial` driver registers a line discipline that can be attached to
a TTY (like a UART serial port). When the network stack queues a packet for
transmission via `dev_queue_xmit`, it eventually calls `handle_tx`.
In `handle_tx`, there is a loop that attempts to write the socket buffer
(`skb`) data to the TTY:
```c
while ((skb = skb_peek(&ser->head)) != NULL) {
len = skb->len;
room = tty_write_room(tty);
if (!room)
break;
// ...
tty_wr = tty->ops->write(tty, skb->data, len);
// ...
skb_pull(skb, tty_wr);
}
```
The bug occurs because `tty_write_room()` (which maps to `uart_write_room()`)
can return a value `> 0` while `tty->ops->write()` (which maps to
`uart_write()`) returns `0`. If `tty_wr == 0`, `skb_pull()` does not consume
any data, `skb->len` remains unchanged, and the loop continues infinitely,
causing a CPU softlockup.
This mismatch happens during the TTY shutdown phase. When a UART is being
closed or hung up, `uart_shutdown()` frees the transmission buffer
(`xmit_buf`) and re-initializes the `xmit_fifo`. An empty/uninitialized
`kfifo` reports that it has available room, so `uart_write_room()` returns `>
0`. However, `uart_write()` explicitly checks if `xmit_buf` is `NULL` and
returns `0` if it is. If a packet is queued for transmission during this
narrow shutdown window, the infinite loop is triggered.
2. **Trigger Mechanism:**
In the provided crash report, the `aoe` (ATA over Ethernet) kernel thread
`aoe_tx0` is sending a packet. `aoe` broadcasts discovery packets over all
available network interfaces, including the `caif_serial` interface. If `aoe`
transmits a packet exactly when the `caif_serial` TTY is being closed, the
softlockup occurs.
3. **Security Impact:**
- **Exploitable:** No. The bug is a classic infinite loop leading to a CPU
stall. It does not cause memory corruption, use-after-free, or out-of-bounds
accesses.
- **Denial of Service:** Yes. The infinite loop halts the CPU, leading to a
system-wide Denial of Service (RCU stall / softlockup).
- **Unprivileged / User Namespace:** No. Attaching the `caif_serial` line
discipline to a TTY requires `CAP_SYS_ADMIN` or `CAP_SYS_TTY_CONFIG` in the
**initial** user namespace (`capable()` is used instead of `ns_capable()`).
Therefore, an unprivileged user (even within a user namespace) cannot set up
the vulnerable `caif_serial` interface.
- **Remote / Network / Peripheral:** Triggering the bug requires a highly
specific race condition where a privileged user (or a system daemon) is
actively closing the TTY while network traffic is concurrently routed to it.
While network traffic (like `aoe` broadcasts) is involved, an attacker cannot
reliably trigger the TTY shutdown sequence remotely or via a peripheral
device unless the system is specifically configured to auto-attach and
auto-detach `caif_serial` on hotplug events (which is not the default).
**Conclusion:**
This is a Denial of Service vulnerability caused by a race condition during TTY
shutdown in the `caif_serial` driver. It is not exploitable for privilege
escalation or memory corruption, and it cannot be reached by unprivileged users
or reliably triggered by external attackers.]
|