| 0/0 |
2026/09/05 00:00 |
flow |
assessment-security |
8m
Results: map[DenialOfService:true Explanation:**Bug Analysis:**
The bug is a stack-use-after-free (reported as `vmalloc-out-of-bounds` due to
`CONFIG_VMAP_STACK`) in the SunRPC pipe code, specifically when handling NFSv4
client tracking upcalls (`cld_pipe_upcall`).
1. **The Vulnerability Mechanism:**
In `__cld_pipe_upcall()`, an `rpc_pipe_msg` struct is allocated on the stack.
It is then queued to the `rpc_pipe` via `rpc_queue_upcall()`, which adds it
to the `pipe->pipe` list. The function then waits for the upcall to be
processed using `wait_for_completion(&cup->cu_done)`.
Normally, the user-space daemon (`nfsdcld`) reads the upcall from the pipe.
The `read()` operation (`rpc_pipe_read()`) removes the `msg` from the pipe's
lists once fully read. Later, the daemon writes a reply to the pipe, which
invokes `cld_pipe_downcall()`. This downcall completes the `cu_done`
completion, waking up `__cld_pipe_upcall()` which then safely returns.
However, if a process writes a reply to the pipe *before* the upcall is fully
read (or guesses the `xid` and writes a preemptive reply),
`cld_pipe_downcall()` will complete `cu_done` immediately.
`__cld_pipe_upcall()` wakes up and returns, destroying its stack frame.
Crucially, `cld_pipe_downcall()` does not remove the `msg` from the
`pipe->pipe` list. This leaves a dangling pointer to the freed stack frame on
the list. A subsequent upcall will traverse this corrupted list in
`list_add_tail()`, leading to the out-of-bounds access and crash.
2. **Exploitability:**
Memory safety issues involving linked list corruption and
stack-use-after-free are generally exploitable for arbitrary code execution
or privilege escalation. However, the context of this bug heavily restricts
its threat model.
3. **Access and Privileges:**
To trigger this bug, an attacker must be able to write to the `nfsdcld` pipe
(typically located at `/var/lib/nfs/rpc_pipefs/nfsd/cld`).
- This pipe is created with `0600` permissions (`S_IRUSR | S_IWUSR`) and is
owned by root.
- The `rpc_pipefs` filesystem does not support `FS_USERNS_MOUNT`, meaning it
cannot be mounted inside an unprivileged user namespace.
- Therefore, only a local root user (or a compromised `nfsdcld` daemon) can
write to this pipe and trigger the bug. Syzkaller (which runs as root in its
test environment) easily triggers this by writing random data to the pipe.
4. **Remote/Network Trigger:**
While NFS is a network service and a remote client can induce the server to
generate upcalls, the remote client cannot write to the local `rpc_pipefs`
pipe. The bug strictly requires a local write to the pipe to cause the
premature completion. Thus, it cannot be triggered over the network.
**Conclusion:**
The bug is a valid memory corruption issue (Stack UAF) that causes a Denial of
Service and is theoretically exploitable. However, because it strictly requires
local root privileges to write to the restricted `rpc_pipefs` pipe, it does not
cross any security boundaries. It is inaccessible to unprivileged users, user
namespaces, or remote attackers. Exploitable:true FilesystemTrigger:false NetworkTrigger:true PeripheralTrigger:false RemoteTrigger:false Unprivileged:false UserNamespace:false VMGuestTrigger:false VMHostTrigger:false]
|
| 1/1 |
2026/09/05 00:00 |
action |
syz-repro-to-c-repro |
0m
Results:
|
| 2/1 |
2026/09/05 00:00 |
action |
kernel-checkouter |
0m
Results: map[KernelSrc:/app/workdir/cache/src/3e9556fdea5ea68aeb007d973d2ad74d50ccef20]
|
| 3/1 |
2026/09/05 00:00 |
action |
kernel-builder |
0m
Results: map[KernelObj:/app/workdir/cache/build/1b5af2471ec5ab044138942b30db65cada537d96]
|
| 4/1 |
2026/09/05 00:00 |
action |
codesearch-prepare |
0m
Results: map[Index:codesearch-index]
|
| 5/1 |
2026/09/05 00:01 |
agent |
expert |
8m
Model:
Results: map[DenialOfService:true Exploitable:true FilesystemTrigger:false NetworkTrigger:true PeripheralTrigger:false RemoteTrigger:false Unprivileged:false UserNamespace:false VMGuestTrigger:false VMHostTrigger:false]
Instruction: You are an experienced Linux kernel security engineer. Your task is to analyze given kernel bug report
and determine its security impact based on the following dimensions.
Use the provided tools to examine the source code, check for capability checks (e.g., capable(), ns_capable()),
and understand the nature of the bug. Analyze the given kernel build and configuration.
You can check the kernel config by grepping ".config" file; you can check kernel cmdline by grepping
".config" file for "CONFIG_CMDLINE=". Assume sysctl parameters have default values.
But analyze for the corresponding production build w/o debugging tools enabled (like KASAN, KMSAN, UBSAN).
Try different strategies when analyzing the bug:
- think of ways in which the vulnerable code is unreachable
- or the other way around: try to come up with different ideas of how an unprivileged user can reach the bug
If still unsure err on the side of the bug being non-exploitable/not-accessible.
In the final reply, provide a reasoning for your assessment.
Analysis dimensions:
* Exploitable:
Determine if the bug can result in memory corruption, elevated privileges, or an information leak.
Memory safety issues are almost always exploitable (KASAN or UBSAN reports for use-after-free, out-of-bounds;
refcounting issues, corrupted lists, etc). When kernel is crashing on a completely wild pointer access
(e.g. user-space address, or non-canonical address, but not on NULL or address corresponding to KASAN shadow
for NULL address), including both data accesses and control transfers, that also usually implies possibility
of exploitation. Such reports usually say "unable to handle kernel paging request".
Uses of uninitialized values detected by KMSAN may be exploitable b/c attacker frequently can affect uninit
values with spraying techniques. However, for these exploitability depends on how exactly the uninit value
is used in the code, and what it affects.
Information leaks are exploitable on their own and should be classified as such. A bug that copies kernel
memory contents to userspace (e.g. an out-of-bounds read whose result is returned to the caller, or
uninitialized stack/heap bytes written to a user buffer) is exploitable: it can reveal kernel pointer
values and defeat KASLR, expose sensitive data such as cryptographic keys or other processes' memory, and
serves as a necessary building block in most modern kernel privilege-escalation exploit chains. Do not classify
an information leak as non-exploitable solely because it does not directly cause a memory write or control-flow
hijack; the leak itself is the exploit primitive.
Think of what happens after the bug is triggered. Some bugs cause kernel panic and halt execution,
they are harder to exploit. For example, BUG reports halts the kernel. However, WARNING reports don't halt
execution in production builds. Debug bug detection tools (like KASAN, KMSAN, KCSAN, UBSAN) are also not enabled
in production builds, so attacker can freely exploit these bugs w/o being detected by these tools.
If you see an integer overflow, think how the overflowed value used later (if it's used as allocation size,
or an array index). If you see an out-of-bounds read, think if it's followed by an out-of-bounds write as well.
Some KCSAN data-races may be exploitable by skilled attackers as well. Think what data structures got corrupted
as the result of data races and how. However, note that kernel has lots of "benign" data races that don't lead
to any runtime misbehavior at all.
* Denial Of Service:
Determine if the bug can result in denial-of-service. Most bugs can, since they cause system crash,
hangs, deadlocks, or resource leaks. This is mostly applicable to WARNING bugs that won't cause system crash
in production. For these think what will be consequences of the violation of the kernel assumptions flagged
by the WARNING. In some cases the unexpected condition is also properly handled by the normal control flow
(e.g. with "if (WARN_ON(...))"), these won't cause denial-of-service. If the condition is not handled,
then it may or may not cause denial-of-service.
* Accessible From Unprivileged Processes:
Determine if the bug can be reached from a typical (non-root) user process that does NOT have any special capabilities
(like CAP_SYS_ADMIN, CAP_NET_ADMIN, CAP_NET_RAW, CAP_PERFMON) or access to device nodes restricted to root.
Assume that unprivileged_bpf_disabled=1, that is eBPF loading is not accessible. However, cBPF (classical BPF)
is still accessible to non-root processes.
Assume that user namespaces are not accessible, that is, the process cannot get the mentioned capabilities even
within a new user namespace (checked by ns_capable() function in the kernel sources).
* Accessible From User Namespaces:
Determine if the bug can be reached within a user-namespace where the process has all capabilities
(including CAP_SYS_ADMIN, CAP_NET_ADMIN, CAP_NET_RAW, CAP_PERFMON). Such capabilities are checked with ns_capable()
function in the kernel sources.
* VM Guest Trigger:
Determine if the bug can be triggered from the context of a typical KVM guest (e.g., set up by a QEMU VMM).
Consider accesses to standard Linux host paravirtualized features (virtio-blk, virtio-net, etc.),
and handling of VM exits in the KVM code.
* VM Host Trigger in The Confidential Computing Context:
Determine if the bug can be triggered in a confidential computing guest kernel from the context of a KVM host.
Consider access to standard Linux guest paravirtualized features (virtio-blk, virtio-net, etc.).
* Ethernet Network Trigger:
Determine if the bug can be triggered by processing ingress network Ethernet traffic, either directly (network stack)
or via drivers exposed to network data.
* Other Remote Trigger:
Determine if the bug can be triggered by processing remote traffic other than Ethernet (Wifi, Bluetooth, NFC, etc).
* Peripheral Trigger:
Determine if the bug can be triggered via an untrusted peripheral device that can be physically plugged
into a system, such as a USB device or a niche hardware driver handling external hardware inputs.
This is particularly important for mobile and desktop environments where users can plug in unknown devices.
* Malicious Filesystem Trigger:
Determine if the bug can be triggered by the kernel mounting and parsing a malicious filesystem image.
This is highly critical for Desktop and Mobile environments where external media or downloaded images
might be auto-mounted.
Don't make assumptions about the kernel source code (it may be different from what you assume it is).
Extensively use the provided code access tools (codesearch-*, git-*, grepper, etc)
to examine the actual source code, and confirm any assumptions.
Prefer calling several tools at the same time to save round-trips.
Use set-results tool to provide results of the analysis.
It must be called exactly once before the final reply.
Ignore results of this tool.
Prompt:
The kernel bug report is:
==================================================================
BUG: KASAN: vmalloc-out-of-bounds in __list_add_valid_or_report+0x6a/0x130 lib/list_debug.c:32
Read of size 8 at addr ffffc900045e7930 by task syz.3.195/7121
CPU: 1 UID: 0 PID: 7121 Comm: syz.3.195 Not tainted syzkaller #0 PREEMPT_{RT,(full)}
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 07/24/2026
Call Trace:
<TASK>
dump_stack_lvl+0xe8/0x150 lib/dump_stack.c:120
print_address_description+0x55/0x1e0 mm/kasan/report.c:378
print_report+0x58/0x70 mm/kasan/report.c:482
kasan_report+0x117/0x150 mm/kasan/report.c:595
__list_add_valid_or_report+0x6a/0x130 lib/list_debug.c:32
__list_add_valid include/linux/list.h:104 [inline]
__list_add include/linux/list.h:169 [inline]
list_add_tail include/linux/list.h:206 [inline]
rpc_queue_upcall+0x86/0x320 net/sunrpc/rpc_pipe.c:142
__cld_pipe_upcall fs/nfsd/nfs4recover.c:668 [inline]
cld_pipe_upcall fs/nfsd/nfs4recover.c:691 [inline]
nfsd4_cld_grace_start fs/nfsd/nfs4recover.c:1305 [inline]
nfsd4_cld_tracking_init+0xd85/0x13a0 fs/nfsd/nfs4recover.c:1494
nfsd4_client_tracking_init+0xca/0x1c0 fs/nfsd/nfs4recover.c:1941
nfs4_state_start_net+0xcbd/0x11b0 fs/nfsd/nfs4state.c:9838
nfsd_startup_net fs/nfsd/nfssvc.c:391 [inline]
nfsd_svc+0x4d5/0x760 fs/nfsd/nfssvc.c:775
Reply: **Bug Analysis:**
The bug is a stack-use-after-free (reported as `vmalloc-out-of-bounds` due to `CONFIG_VMAP_STACK`) in the SunRPC pipe code, specifically when handling NFSv4 client tracking upcalls (`cld_pipe_upcall`).
1. **The Vulnerability Mechanism:**
In `__cld_pipe_upcall()`, an `rpc_pipe_msg` struct is allocated on the stack. It is then queued to the `rpc_pipe` via `rpc_queue_upcall()`, which adds it to the `pipe->pipe` list. The function then waits for the upcall to be processed using `wait_for_completion(&cup->cu_done)`.
Normally, the user-space daemon (`nfsdcld`) reads the upcall from the pipe. The `read()` operation (`rpc_pipe_read()`) removes the `msg` from the pipe's lists once fully read. Later, the daemon writes a reply to the pipe, which invokes `cld_pipe_downcall()`. This downcall completes the `cu_done` completion, waking up `__cld_pipe_upcall()` which then safely returns.
However, if a process writes a reply to the pipe *before* the upcall is fully read (or guesses the `xid` and writes a preemptive reply), `cld_pipe_downcall()` will complete `cu_done` immediately. `__cld_pipe_upcall()` wakes up and returns, destroying its stack frame. Crucially, `cld_pipe_downcall()` does not remove the `msg` from the `pipe->pipe` list. This leaves a dangling pointer to the freed stack frame on the list. A subsequent upcall will traverse this corrupted list in `list_add_tail()`, leading to the out-of-bounds access and crash.
2. **Exploitability:**
Memory safety issues involving linked list corruption and stack-use-after-free are generally exploitable for arbitrary code execution or privilege escalation. However, the context of this bug heavily restricts its threat model.
3. **Access and Privileges:**
To trigger this bug, an attacker must be able to write to the `nfsdcld` pipe (typically located at `/var/lib/nfs/rpc_pipefs/nfsd/cld`).
- This pipe is created with `0600` permissions (`S_IRUSR | S_IWUSR`) and is owned by root.
- The `rpc_pipefs` filesystem does not support `FS_USERNS_MOUNT`, meaning it cannot be mounted inside an unprivileged user namespace.
- Therefore, only a local root user (or a compromised `nfsdcld` daemon) can write to this pipe and trigger the bug. Syzkaller (which runs as root in its test environment) easily triggers this by writing random data to the pipe.
4. **Remote/Network Trigger:**
While NFS is a network service and a remote client can induce the server to generate upcalls, the remote client cannot write to the local `rpc_pipefs` pipe. The bug strictly requires a local write to the pipe to cause the premature completion. Thus, it cannot be triggered over the network.
**Conclusion:**
The bug is a valid memory corruption issue (Stack UAF) that causes a Denial of Service and is theoretically exploitable. However, because it strictly requires local root privileges to write to the restricted `rpc_pipefs` pipe, it does not cross any security boundaries. It is inaccessible to unprivileged users, user namespaces, or remote attackers.
|
| 6/2 |
2026/09/05 00:01 |
llm |
expert |
0m
Model:
Tokens:
input: 6512
output: 24
thoughts: 233
Thoughts: **KASAN vmalloc-out-of-bounds Bug Analysis**
Okay, so I've got a KASAN vmalloc-out-of-bounds bug report here. The crash is happening within `__list_add_valid_or_report`, and the call trace is quite illuminating. It starts with `rpc_queue_upcall`, which is where I need to focus my attention. This call is originating from `net/sunrpc/rpc_pipe.c:142`, and it's being called as a result of a pretty convoluted path through the NFS server initialization: `nfsd_svc` -> `nfsd_startup_net` -> `nfs4_state_start_net` -> `nfsd4_client_tracking_init` -> `nfsd4_cld_tracking_init` -> `nfsd4_cld_grace_start` -> `cld_pipe_upcall` -> `__cld_pipe_upcall` -> `rpc_queue_upcall`.
Clearly, this involves a bunch of core NFS server setup functions, and I suspect some sort of race condition or memory corruption related to the client tracking initialization. Now, let's dive into `rpc_queue_upcall` in `net/sunrpc/rpc_pipe.c`, and see what the function is supposed to do. Hopefully, this will lead me to the root cause of the memory error during the list manipulation. I'm especially interested in the inputs to `rpc_queue_upcall` and how `list_add_tail` is used within that function.
|
| 7/2 |
2026/09/05 00:01 |
tool |
codesearch-definition-source |
0m
Args: map[Name:rpc_queue_upcall]
Results: map[SourceCode: 124: /**
125: * rpc_queue_upcall - queue an upcall message to userspace
126: * @pipe: upcall pipe on which to queue given message
127: * @msg: message to queue
128: *
129: * Call with an @inode created by rpc_mkpipe() to queue an upcall.
130: * A userspace process may then later read the upcall by performing a
131: * read on an open file for this inode. It is up to the caller to
132: * initialize the fields of @msg (other than @msg->list) appropriately.
133: */
134: int
135: rpc_queue_upcall(struct rpc_pipe *pipe, struct rpc_pipe_msg *msg)
136: {
137: int res = -EPIPE;
138: struct dentry *dentry;
139:
140: spin_lock(&pipe->lock);
141: if (pipe->nreaders) {
142: list_add_tail(&msg->list, &pipe->pipe);
143: pipe->pipelen += msg->len;
144: res = 0;
145: } else if (pipe->flags & RPC_PIPE_WAIT_FOR_OPEN) {
146: if (list_empty(&pipe->pipe))
147: queue_delayed_work(rpciod_workqueue,
148: &pipe->queue_timeout,
149: RPC_UPCALL_TIMEOUT);
150: list_add_tail(&msg->list, &pipe->pipe);
151: pipe->pipelen += msg->len;
152: res = 0;
153: }
154: dentry = dget(pipe->dentry);
155: spin_unlock(&pipe->lock);
156: if (dentry) {
157: wake_up(&RPC_I(d_inode(dentry))->waitq);
158: dput(dentry);
159: }
160: return res;
161: }
SourceFile:net/sunrpc/rpc_pipe.c]
|
| 8/2 |
2026/09/05 00:01 |
llm |
expert |
0m
Model:
Tokens:
input: 7519
output: 26
thoughts: 182
Thoughts: **Debugging a Vmalloc Out-of-Bounds Read in NFSd**
Okay, so I've got a tricky one here. It looks like we have a vmalloc-out-of-bounds read, and it's happening within `__list_add_valid_or_report`. The culprit call originates from `list_add_tail` inside `rpc_queue_upcall`. This is interesting because `rpc_queue_upcall` is a pretty core function within the RPC handling, so this potentially touches a fair amount of code.
Now let's trace the path: `nfsd_svc` is calling `nfsd_startup_net`, which then goes to `nfs4_state_start_net`, then `nfsd4_client_tracking_init`, which in turn leads to `nfsd4_cld_tracking_init`, `nfsd4_cld_grace_start`, `cld_pipe_upcall`, and finally `__cld_pipe_upcall`, which then calls `rpc_queue_upcall`. That's quite a chain, but it provides a good starting point for investigation.
My immediate focus will be on `__cld_pipe_upcall` located in `fs/nfsd/nfs4recover.c`. I need to understand what data it's passing to `rpc_queue_upcall` and how it's interacting with the lists. Hopefully, I'll be able to spot the flaw in either how memory is being allocated or how list manipulation is taking place, leading to this out-of-bounds read. Let's dig into that code and see what we can find.
|
| 9/2 |
2026/09/05 00:01 |
tool |
codesearch-definition-source |
0m
Args: map[Name:__cld_pipe_upcall]
Results: map[SourceCode: 657: static int
658: __cld_pipe_upcall(struct rpc_pipe *pipe, void *cmsg, struct nfsd_net *nn)
659: {
660: int ret;
661: struct rpc_pipe_msg msg;
662: struct cld_upcall *cup = container_of(cmsg, struct cld_upcall, cu_u);
663:
664: memset(&msg, 0, sizeof(msg));
665: msg.data = cmsg;
666: msg.len = nn->client_tracking_ops->msglen;
667:
668: ret = rpc_queue_upcall(pipe, &msg);
669: if (ret < 0) {
670: goto out;
671: }
672:
673: wait_for_completion(&cup->cu_done);
674:
675: if (msg.errno < 0)
676: ret = msg.errno;
677: out:
678: return ret;
679: }
SourceFile:fs/nfsd/nfs4recover.c]
|
| 10/2 |
2026/09/05 00:01 |
llm |
expert |
0m
Model:
Tokens:
input: 8270
output: 25
thoughts: 347
Thoughts: **My Analysis of the Potential Vulnerability**
Okay, so I've got a handle on this. It looks like we're dealing with a vmalloc-out-of-bounds in `__list_add_valid_or_report`, which is triggered by `list_add_tail` within `rpc_queue_upcall`. The core issue seems to revolve around how `msg` is handled. It's allocated on the stack within `__cld_pipe_upcall`, specifically:
```c
struct rpc_pipe_msg msg;
```
Right, so `msg` is stack-allocated within `__cld_pipe_upcall`. Then `rpc_queue_upcall(pipe, &msg)` is invoked. This is where things get interesting. `rpc_queue_upcall` adds `&msg->list` to `pipe->pipe`. This looks like a standard queue insertion.
Then, `__cld_pipe_upcall` waits for completion using `wait_for_completion(&cup->cu_done);`. Okay, standard synchronization, waiting for the upcall to be processed.
Now, if `rpc_queue_upcall` returns `< 0`, it goes straight to `out` and returns. That makes sense. However, if `rpc_queue_upcall` returns 0, it *also* waits for completion. But hold on, the documentation of wait_for_completion states it cannot be interrupted or timeout.
The real problem lies in the sequence: `rpc_queue_upcall` adds the message to the list, and *then* `__cld_pipe_upcall` returns. The message is still on the list, but it's stack-allocated! That screams dangling pointer vulnerability.
I have to be missing something, though. Let me think, `wait_for_completion` is used to wait until the message is processed. Once processed, shouldn't the message be removed from the list? I bet the removal is handled in `rpc_pipe_read` or some similar function. I need to go dig into that code now to confirm.
|
| 11/2 |
2026/09/05 00:01 |
tool |
codesearch-definition-source |
0m
Args: map[Name:cld_pipe_upcall]
Results: map[SourceCode: 681: static int
682: cld_pipe_upcall(struct rpc_pipe *pipe, void *cmsg, struct nfsd_net *nn)
683: {
684: int ret;
685:
686: /*
687: * -EAGAIN occurs when pipe is closed and reopened while there are
688: * upcalls queued.
689: */
690: do {
691: ret = __cld_pipe_upcall(pipe, cmsg, nn);
692: } while (ret == -EAGAIN);
693:
694: return ret;
695: }
SourceFile:fs/nfsd/nfs4recover.c]
|
| 12/2 |
2026/09/05 00:01 |
llm |
expert |
0m
Model:
Tokens:
input: 9744
output: 28
thoughts: 333
Thoughts: **Analyzing the KASAN Report: A Deep Dive**
Okay, the KASAN report is screaming "vmalloc-out-of-bounds." My initial thought is to zero in on this. Given modern kernels often vmalloc the stack with `CONFIG_VMAP_STACK`, this suggests a stack-related issue. Either a stack-out-of-bounds or perhaps a use-after-free on the stack, which KASAN might be reporting this way. Let's re-examine that stack trace.
Right, the trace shows the crash within `list_add_tail`, specifically during the `rpc_queue_upcall` call. This immediately narrows the focus. If `list_add_tail` is failing, then either `&msg->list` or `&pipe->pipe` is invalid. The crucial piece is that `msg` is on the stack *within* `__cld_pipe_upcall`, and `pipe` is passed as an argument to `__cld_pipe_upcall`. Time to check `__list_add_valid_or_report` for clues.
|
| 13/2 |
2026/09/05 00:01 |
tool |
codesearch-definition-source |
0m
Args: map[Name:__list_add_valid_or_report]
Results: map[SourceCode: 22: bool __list_add_valid_or_report(struct list_head *new, struct list_head *prev,
23: struct list_head *next)
24: {
25: if (CHECK_DATA_CORRUPTION(prev == NULL, NULL,
26: "list_add corruption. prev is NULL.\n") ||
27: CHECK_DATA_CORRUPTION(next == NULL, NULL,
28: "list_add corruption. next is NULL.\n") ||
29: CHECK_DATA_CORRUPTION(next->prev != prev, next,
30: "list_add corruption. next->prev should be prev (%px), but was %px. (next=%px).\n",
31: prev, next->prev, next) ||
32: CHECK_DATA_CORRUPTION(prev->next != next, prev,
33: "list_add corruption. prev->next should be next (%px), but was %px. (prev=%px).\n",
34: next, prev->next, prev) ||
35: CHECK_DATA_CORRUPTION(new == prev || new == next, NULL,
36: "list_add double add: new=%px, prev=%px, next=%px.\n",
37: new, prev, next))
38: return false;
39:
40: return true;
41: }
SourceFile:lib/list_debug.c]
|
| 14/2 |
2026/09/05 00:01 |
llm |
expert |
0m
Model:
Tokens:
input: 9641
output: 23
thoughts: 1028
Thoughts: **Vmalloc-Out-of-Bounds in `__list_add_valid_or_report` Deep Dive**
Okay, so I've got a vmalloc-out-of-bounds error, specifically inside `__list_add_valid_or_report`. The trace is pointing me through `nfsd_svc`, `nfsd_startup_net`, `nfs4_state_start_net`, down the rabbit hole to `nfsd4_cld_grace_start`, ultimately landing in `__cld_pipe_upcall`. That function is the key here.
In `__cld_pipe_upcall`, I'm seeing a stack-allocated `rpc_pipe_msg` named `msg`. This struct gets filled, and crucially, `msg.list` gets added to `pipe->pipe` using `rpc_queue_upcall`. After `rpc_queue_upcall` returns zero (success), the code then waits for completion of a related structure. If `rpc_queue_upcall` fails (returns a negative value), the code jumps out after completion.
Now, the interesting bit hits me. What happens if `rpc_queue_upcall` returns `-EAGAIN`? The code in `cld_pipe_upcall` shows a loop: the `__cld_pipe_upcall` function is re-entered if it returns `-EAGAIN`. My immediate thought is, if there's a `-EAGAIN` return from the initial `rpc_queue_upcall` call, *is* that message's list entry properly removed from the pipe? Let's check `rpc_queue_upcall`.
Alright, I see it. `rpc_queue_upcall` adds the message to the list if the pipe has readers or if it's waiting for one. The return of `-EPIPE` indicates that the message wasn't added to the list. I'm still trying to grok the flow, and now I'm thinking about the root cause and where `-EAGAIN` might originate. Ah, here we go, looking at `wait_for_completion`, the reader side of the pipe can set `msg.errno` to `-EAGAIN`! That's it! If `msg.errno` is `-EAGAIN`, `__cld_pipe_upcall` will then return `-EAGAIN`, and we'll loop! The stack variable is destroyed at the end of the loop, right?
But wait. When `__cld_pipe_upcall` returns, the `msg` on the stack is destroyed. So, if `-EAGAIN` is encountered, does the reader *remove* the message from the list? I need to look at how `rpc_pipe_msg` is handled by the *reader*. I think I've got it narrowed down.
|
| 15/2 |
2026/09/05 00:01 |
tool |
codesearch-find-references |
0m
Args:
Results: map[References:[map[ReferenceKind:uses ReferencingEntityKind:function ReferencingEntityName:__cld_pipe_upcall SourceFile:fs/nfsd/nfs4recover.c SourceLine:661] map[ReferenceKind:uses ReferencingEntityKind:function ReferencingEntityName:bl_pipe_destroy_msg SourceFile:fs/nfs/blocklayout/rpc_pipefs.c SourceLine:128] map[ReferenceKind:uses ReferencingEntityKind:function ReferencingEntityName:bl_resolve_deviceid SourceFile:fs/nfs/blocklayout/rpc_pipefs.c SourceLine:59] map[ReferenceKind:uses ReferencingEntityKind:function ReferencingEntityName:cld_pipe_destroy_msg SourceFile:fs/nfsd/nfs4recover.c SourceLine:835] map[ReferenceKind:uses ReferencingEntityKind:function ReferencingEntityName:gss_pipe_destroy_msg SourceFile:net/sunrpc/auth_gss/auth_gss.c SourceLine:875] map[ReferenceKind:uses ReferencingEntityKind:function ReferencingEntityName:gss_v0_upcall SourceFile:net/sunrpc/auth_gss/auth_gss.c SourceLine:421] map[ReferenceKind:uses ReferencingEntityKind:function ReferencingEntityName:gss_v1_upcall SourceFile:net/sunrpc/auth_gss/auth_gss.c SourceLine:506] map[ReferenceKind:uses ReferencingEntityKind:function ReferencingEntityName:idmap_pipe_destroy_msg SourceFile:fs/nfs/nfs4idmap.c SourceLine:709] map[ReferenceKind:uses ReferencingEntityKind:function ReferencingEntityName:nfs_idmap_legacy_upcall SourceFile:fs/nfs/nfs4idmap.c SourceLine:571] map[ReferenceKind:uses ReferencingEntityKind:function ReferencingEntityName:nfs_idmap_prepare_message SourceFile:fs/nfs/nfs4idmap.c SourceLine:500] map[ReferenceKind:uses ReferencingEntityKind:function ReferencingEntityName:rpc_msg_is_inflight SourceFile:include/linux/sunrpc/rpc_pipe_fs.h SourceLine:96] map[ReferenceKind:uses ReferencingEntityKind:function ReferencingEntityName:rpc_pipe_generic_upcall SourceFile:net/sunrpc/rpc_pipe.c SourceLine:104] map[ReferenceKind:uses ReferencingEntityKind:function ReferencingEntityName:rpc_pipe_ioctl SourceFile:net/sunrpc/rpc_pipe.c SourceLine:375] map[ReferenceKind:uses ReferencingEntityKind:function ReferencingEntityName:rpc_pipe_read SourceFile:net/sunrpc/rpc_pipe.c SourceLine:286] map[ReferenceKind:uses ReferencingEntityKind:function ReferencingEntityName:rpc_pipe_read SourceFile:net/sunrpc/rpc_pipe.c SourceLine:299] map[ReferenceKind:uses ReferencingEntityKind:function ReferencingEntityName:rpc_pipe_read SourceFile:net/sunrpc/rpc_pipe.c SourceLine:299] map[ReferenceKind:uses ReferencingEntityKind:function ReferencingEntityName:rpc_pipe_read SourceFile:net/sunrpc/rpc_pipe.c SourceLine:299] map[ReferenceKind:uses ReferencingEntityKind:function ReferencingEntityName:rpc_pipe_release SourceFile:net/sunrpc/rpc_pipe.c SourceLine:244] map[ReferenceKind:uses ReferencingEntityKind:function ReferencingEntityName:rpc_purge_list SourceFile:net/sunrpc/rpc_pipe.c SourceLine:65] map[ReferenceKind:uses ReferencingEntityKind:function ReferencingEntityName:rpc_purge_list SourceFile:net/sunrpc/rpc_pipe.c SourceLine:67] map[ReferenceKind:uses ReferencingEntityKind:function ReferencingEntityName:rpc_purge_list SourceFile:net/sunrpc/rpc_pipe.c SourceLine:72] map[ReferenceKind:uses ReferencingEntityKind:function ReferencingEntityName:rpc_purge_list SourceFile:net/sunrpc/rpc_pipe.c SourceLine:72] map[ReferenceKind:uses ReferencingEntityKind:function ReferencingEntityName:rpc_purge_list SourceFile:net/sunrpc/rpc_pipe.c SourceLine:72] map[ReferenceKind:uses ReferencingEntityKind:function ReferencingEntityName:rpc_queue_upcall SourceFile:net/sunrpc/rpc_pipe.c SourceLine:135] map[ReferenceKind:uses ReferencingEntityKind:function ReferencingEntityName:rpc_timeout_upcall_queue SourceFile:net/sunrpc/rpc_pipe.c SourceLine:88] map[ReferenceKind:uses ReferencingEntityKind:struct ReferencingEntityName:rpc_pipe_ops SourceFile:include/linux/sunrpc/rpc_pipe_fs.h SourceLine:36] map[ReferenceKind:uses ReferencingEntityKind:struct ReferencingEntityName:rpc_pipe_ops SourceFile:include/linux/sunrpc/rpc_pipe_fs.h SourceLine:40]] TruncatedOutput:false]
|
| 16/2 |
2026/09/05 00:01 |
llm |
expert |
0m
Model:
Tokens:
input: 11789
output: 23
thoughts: 1321
Thoughts: **Analyzing a KASAN vmalloc-out-of-bounds in `__list_add_valid_or_report`**
Okay, so I'm looking at a KASAN vmalloc-out-of-bounds error. The crash originates in `__list_add_valid_or_report`, which is called from `rpc_queue_upcall`. The call trace tells the story: it's coming from `rpc_queue_upcall` within the NFSd client tracking code, specifically within the `nfs4recover` module, starting from `nfsd4_cld_grace_start`.
My immediate thought is to zero in on `rpc_queue_upcall` and the code that calls it. Let's see what `__cld_pipe_upcall` is doing. Okay, it looks like it's taking a `struct rpc_pipe` and a generic `void *cmsg`. Inside, there is a `struct rpc_pipe_msg msg`, which is allocated on the *stack*! This is interesting...
`msg` is passed to `rpc_queue_upcall`. Inside `rpc_queue_upcall`, if there are readers, it adds the `msg->list` to the `pipe->pipe` list. But then, the code immediately calls `wait_for_completion(&cup->cu_done)`. Once this completes, the stack frame is released and the `msg` goes out of scope. *That's a potential problem.*
However, I see the code also checks the return value of `rpc_queue_upcall`: `if (ret < 0) goto out;`. If `rpc_queue_upcall` *fails* (returns a negative value), it *doesn't* add `msg` to the list. That makes sense, because that would prevent it from creating the invalid pointer.
So, the issue is that if `rpc_queue_upcall` *succeeds*, the `msg->list` is added to the list. Then, `wait_for_completion` is called and returns. The function completes, and the stack frame is released. So, the message is *not* removed from the list when `__cld_pipe_upcall` returns!
Hold on, I see something else. `cld_pipe_upcall` calls `__cld_pipe_upcall` in a loop. If `__cld_pipe_upcall` returns `-EAGAIN`, it loops. However, this doesn't explain the bug.
I need to understand what happens to this `msg` on the other side. This points me to the `rpc_pipe_read` path β that's where the reader should be processing the messages. I need to understand how messages are removed from the list to be certain.
|
| 17/2 |
2026/09/05 00:02 |
tool |
codesearch-definition-source |
0m
Args:
Results: map[SourceCode: 281: static ssize_t
282: rpc_pipe_read(struct file *filp, char __user *buf, size_t len, loff_t *offset)
283: {
284: struct inode *inode = file_inode(filp);
285: struct rpc_pipe *pipe;
286: struct rpc_pipe_msg *msg;
287: int res = 0;
288:
289: inode_lock(inode);
290: pipe = RPC_I(inode)->pipe;
291: if (pipe == NULL) {
292: res = -EPIPE;
293: goto out_unlock;
294: }
295: msg = filp->private_data;
296: if (msg == NULL) {
297: spin_lock(&pipe->lock);
298: if (!list_empty(&pipe->pipe)) {
299: msg = list_entry(pipe->pipe.next,
300: struct rpc_pipe_msg,
301: list);
302: list_move(&msg->list, &pipe->in_upcall);
303: pipe->pipelen -= msg->len;
304: filp->private_data = msg;
305: msg->copied = 0;
306: }
307: spin_unlock(&pipe->lock);
308: if (msg == NULL)
309: goto out_unlock;
310: }
311: /* NOTE: it is up to the callback to update msg->copied */
312: res = pipe->ops->upcall(filp, msg, buf, len);
313: if (res < 0 || msg->len == msg->copied) {
314: filp->private_data = NULL;
315: spin_lock(&pipe->lock);
316: list_del_init(&msg->list);
317: spin_unlock(&pipe->lock);
318: pipe->ops->destroy_msg(msg);
319: }
320: out_unlock:
321: inode_unlock(inode);
322: return res;
323: }
SourceFile:net/sunrpc/rpc_pipe.c]
|
| 18/2 |
2026/09/05 00:02 |
llm |
expert |
0m
Model:
Tokens:
input: 13091
output: 23
thoughts: 0
|
| 19/2 |
2026/09/05 00:02 |
tool |
codesearch-definition-source |
0m
Args: map[Name:rpc_pipe_release]
Results: map[SourceCode: 240: static int
241: rpc_pipe_release(struct inode *inode, struct file *filp)
242: {
243: struct rpc_pipe *pipe;
244: struct rpc_pipe_msg *msg;
245: int last_close;
246:
247: inode_lock(inode);
248: pipe = RPC_I(inode)->pipe;
249: if (pipe == NULL)
250: goto out;
251: msg = filp->private_data;
252: if (msg != NULL) {
253: spin_lock(&pipe->lock);
254: msg->errno = -EAGAIN;
255: list_del_init(&msg->list);
256: spin_unlock(&pipe->lock);
257: pipe->ops->destroy_msg(msg);
258: }
259: if (filp->f_mode & FMODE_WRITE)
260: pipe->nwriters --;
261: if (filp->f_mode & FMODE_READ) {
262: pipe->nreaders --;
263: if (pipe->nreaders == 0) {
264: LIST_HEAD(free_list);
265: spin_lock(&pipe->lock);
266: list_splice_init(&pipe->pipe, &free_list);
267: pipe->pipelen = 0;
268: spin_unlock(&pipe->lock);
269: rpc_purge_list(&RPC_I(inode)->waitq, &free_list,
270: pipe->ops->destroy_msg, -EAGAIN);
271: }
272: }
273: last_close = pipe->nwriters == 0 && pipe->nreaders == 0;
274: if (last_close && pipe->ops->release_pipe)
275: pipe->ops->release_pipe(inode);
276: out:
277: inode_unlock(inode);
278: return 0;
279: }
SourceFile:net/sunrpc/rpc_pipe.c]
|
| 20/2 |
2026/09/05 00:02 |
llm |
expert |
0m
Model:
Tokens:
input: 13748
output: 23
thoughts: 0
|
| 21/2 |
2026/09/05 00:02 |
tool |
codesearch-definition-source |
0m
Args:
Results: map[SourceCode: 64: static void rpc_purge_list(wait_queue_head_t *waitq, struct list_head *head,
65: void (*destroy_msg)(struct rpc_pipe_msg *), int err)
66: {
67: struct rpc_pipe_msg *msg;
68:
69: if (list_empty(head))
70: return;
71: do {
72: msg = list_entry(head->next, struct rpc_pipe_msg, list);
73: list_del_init(&msg->list);
74: msg->errno = err;
75: destroy_msg(msg);
76: } while (!list_empty(head));
77:
78: if (waitq)
79: wake_up(waitq);
80: }
SourceFile:net/sunrpc/rpc_pipe.c]
|
| 22/2 |
2026/09/05 00:02 |
llm |
expert |
0m
Model:
Tokens:
input: 14038
output: 29
thoughts: 0
|
| 23/2 |
2026/09/05 00:02 |
tool |
codesearch-definition-source |
0m
Args: map[Name:nfsd4_cld_tracking_init]
Results: map[SourceCode:1458: static int
1459: nfsd4_cld_tracking_init(struct net *net)
1460: {
1461: int status;
1462: struct nfsd_net *nn = net_generic(net, nfsd_net_id);
1463: bool running;
1464: int retries = 10;
1465:
1466: status = nfs4_cld_state_init(net);
1467: if (status)
1468: return status;
1469:
1470: status = __nfsd4_init_cld_pipe(net);
1471: if (status)
1472: goto err_shutdown;
1473:
1474: /*
1475: * rpc pipe upcalls take 30 seconds to time out, so we don't want to
1476: * queue an upcall unless we know that nfsdcld is running (because we
1477: * want this to fail fast so that nfsd4_client_tracking_init() can try
1478: * the next client tracking method). nfsdcld should already be running
1479: * before nfsd is started, so the wait here is for nfsdcld to open the
1480: * pipefs file we just created.
1481: */
1482: while (!(running = cld_running(nn)) && retries--)
1483: msleep(100);
1484:
1485: if (!running) {
1486: status = -ETIMEDOUT;
1487: goto err_remove;
1488: }
1489:
1490: status = nfsd4_cld_get_version(nn);
1491: if (status == -EOPNOTSUPP)
1492: pr_warn("NFSD: nfsdcld GetVersion upcall failed. Please upgrade nfsdcld.\n");
1493:
1494: status = nfsd4_cld_grace_start(nn);
1495: if (status) {
1496: if (status == -EOPNOTSUPP)
1497: pr_warn("NFSD: nfsdcld GraceStart upcall failed. Please upgrade nfsdcld.\n");
1498: nfs4_release_reclaim(nn);
1499: goto err_remove;
1500: } else
1501: pr_info("NFSD: Using nfsdcld client tracking operations.\n");
1502: return 0;
1503:
1504: err_remove:
1505: nfsd4_remove_cld_pipe(net);
1506: err_shutdown:
1507: nfs4_cld_state_shutdown(net);
1508: return status;
1509: }
SourceFile:fs/nfsd/nfs4recover.c]
|
| 24/2 |
2026/09/05 00:02 |
llm |
expert |
0m
Model:
Tokens:
input: 14910
output: 29
thoughts: 0
|
| 25/2 |
2026/09/05 00:02 |
tool |
codesearch-definition-source |
0m
Args: map[Name:nfsd4_cld_grace_start]
Results: map[SourceCode:1291: static int
1292: nfsd4_cld_grace_start(struct nfsd_net *nn)
1293: {
1294: int ret;
1295: struct cld_upcall *cup;
1296: struct cld_net *cn = nn->cld_net;
1297:
1298: cup = alloc_cld_upcall(nn);
1299: if (!cup) {
1300: ret = -ENOMEM;
1301: goto out_err;
1302: }
1303:
1304: cup->cu_u.cu_msg.cm_cmd = Cld_GraceStart;
1305: ret = cld_pipe_upcall(cn->cn_pipe, &cup->cu_u.cu_msg, nn);
1306: if (!ret)
1307: ret = cup->cu_u.cu_msg.cm_status;
1308:
1309: free_cld_upcall(cup);
1310: out_err:
1311: if (ret)
1312: dprintk("%s: Unable to get clients from userspace: %d\n",
1313: __func__, ret);
1314: return ret;
1315: }
SourceFile:fs/nfsd/nfs4recover.c]
|
| 26/2 |
2026/09/05 00:02 |
llm |
expert |
0m
Model:
Tokens:
input: 15344
output: 25
thoughts: 0
|
| 27/2 |
2026/09/05 00:02 |
tool |
codesearch-definition-source |
0m
Args: map[Name:alloc_cld_upcall]
Results: map[SourceCode: 961: static struct cld_upcall *
962: alloc_cld_upcall(struct nfsd_net *nn)
963: {
964: struct cld_upcall *new, *tmp;
965: struct cld_net *cn = nn->cld_net;
966:
967: new = kzalloc_obj(*new);
968: if (!new)
969: return new;
970:
971: /* FIXME: hard cap on number in flight? */
972: restart_search:
973: spin_lock(&cn->cn_lock);
974: list_for_each_entry(tmp, &cn->cn_list, cu_list) {
975: if (tmp->cu_u.cu_msg.cm_xid == cn->cn_xid) {
976: cn->cn_xid++;
977: spin_unlock(&cn->cn_lock);
978: goto restart_search;
979: }
980: }
981: init_completion(&new->cu_done);
982: new->cu_u.cu_msg.cm_vers = nn->client_tracking_ops->version;
983: put_unaligned(cn->cn_xid++, &new->cu_u.cu_msg.cm_xid);
984: new->cu_net = cn;
985: list_add(&new->cu_list, &cn->cn_list);
986: spin_unlock(&cn->cn_lock);
987:
988: dprintk("%s: allocated xid %u\n", __func__, new->cu_u.cu_msg.cm_xid);
989:
990: return new;
991: }
SourceFile:fs/nfsd/nfs4recover.c]
|
| 28/2 |
2026/09/05 00:02 |
llm |
expert |
0m
Model:
Tokens:
input: 15918
output: 23
thoughts: 0
|
| 29/2 |
2026/09/05 00:02 |
tool |
codesearch-definition-source |
0m
Args:
Results: map[SourceCode: 646: struct cld_upcall {
647: struct list_head cu_list;
648: struct cld_net *cu_net;
649: struct completion cu_done;
650: union {
651: struct cld_msg_hdr cu_hdr;
652: struct cld_msg cu_msg;
653: struct cld_msg_v2 cu_msg_v2;
654: } cu_u;
655: };
SourceFile:fs/nfsd/nfs4recover.c]
|
| 30/2 |
2026/09/05 00:02 |
llm |
expert |
0m
Model:
Tokens:
input: 16126
output: 26
thoughts: 0
|
| 31/2 |
2026/09/05 00:02 |
tool |
codesearch-definition-source |
0m
Args: map[Name:cld_pipe_destroy_msg]
Results: map[SourceCode: 834: static void
835: cld_pipe_destroy_msg(struct rpc_pipe_msg *msg)
836: {
837: struct cld_msg *cmsg = msg->data;
838: struct cld_upcall *cup = container_of(cmsg, struct cld_upcall,
839: cu_u.cu_msg);
840:
841: /* errno >= 0 means we got a downcall */
842: if (msg->errno >= 0)
843: return;
844:
845: complete(&cup->cu_done);
846: }
SourceFile:fs/nfsd/nfs4recover.c]
|
| 32/2 |
2026/09/05 00:02 |
llm |
expert |
0m
Model:
Tokens:
input: 16376
output: 25
thoughts: 0
|
| 33/2 |
2026/09/05 00:02 |
tool |
codesearch-definition-source |
0m
Args: map[Name:free_cld_upcall]
Results: map[SourceCode: 993: static void
994: free_cld_upcall(struct cld_upcall *victim)
995: {
996: struct cld_net *cn = victim->cu_net;
997:
998: spin_lock(&cn->cn_lock);
999: list_del(&victim->cu_list);
1000: spin_unlock(&cn->cn_lock);
1001: kfree(victim);
1002: }
SourceFile:fs/nfsd/nfs4recover.c]
|
| 34/2 |
2026/09/05 00:02 |
llm |
expert |
0m
Model:
Tokens:
input: 16576
output: 23
thoughts: 0
|
| 35/2 |
2026/09/05 00:02 |
tool |
codesearch-definition-source |
0m
Args:
Results: map[SourceCode: 27: struct rpc_pipe_msg {
28: struct list_head list;
29: void *data;
30: size_t len;
31: size_t copied;
32: int errno;
33: };
SourceFile:include/linux/sunrpc/rpc_pipe_fs.h]
|
| 36/2 |
2026/09/05 00:02 |
llm |
expert |
0m
Model:
Tokens:
input: 16710
output: 26
thoughts: 0
|
| 37/2 |
2026/09/05 00:02 |
tool |
codesearch-definition-source |
0m
Args: map[Name:__cld_pipe_upcall]
Results: map[SourceCode: 657: static int
658: __cld_pipe_upcall(struct rpc_pipe *pipe, void *cmsg, struct nfsd_net *nn)
659: {
660: int ret;
661: struct rpc_pipe_msg msg;
662: struct cld_upcall *cup = container_of(cmsg, struct cld_upcall, cu_u);
663:
664: memset(&msg, 0, sizeof(msg));
665: msg.data = cmsg;
666: msg.len = nn->client_tracking_ops->msglen;
667:
668: ret = rpc_queue_upcall(pipe, &msg);
669: if (ret < 0) {
670: goto out;
671: }
672:
673: wait_for_completion(&cup->cu_done);
674:
675: if (msg.errno < 0)
676: ret = msg.errno;
677: out:
678: return ret;
679: }
SourceFile:fs/nfsd/nfs4recover.c]
|
| 38/2 |
2026/09/05 00:02 |
llm |
expert |
0m
Model:
Tokens:
input: 17098
output: 25
thoughts: 0
|
| 39/2 |
2026/09/05 00:02 |
tool |
codesearch-definition-source |
0m
Args: map[Name:cld_pipe_upcall]
Results: map[SourceCode: 681: static int
682: cld_pipe_upcall(struct rpc_pipe *pipe, void *cmsg, struct nfsd_net *nn)
683: {
684: int ret;
685:
686: /*
687: * -EAGAIN occurs when pipe is closed and reopened while there are
688: * upcalls queued.
689: */
690: do {
691: ret = __cld_pipe_upcall(pipe, cmsg, nn);
692: } while (ret == -EAGAIN);
693:
694: return ret;
695: }
SourceFile:fs/nfsd/nfs4recover.c]
|
| 40/2 |
2026/09/05 00:02 |
llm |
expert |
0m
Model:
Tokens:
input: 17356
output: 24
thoughts: 0
|
| 41/2 |
2026/09/05 00:02 |
tool |
codesearch-definition-source |
0m
Args: map[Name:rpc_queue_upcall]
Results: map[SourceCode: 124: /**
125: * rpc_queue_upcall - queue an upcall message to userspace
126: * @pipe: upcall pipe on which to queue given message
127: * @msg: message to queue
128: *
129: * Call with an @inode created by rpc_mkpipe() to queue an upcall.
130: * A userspace process may then later read the upcall by performing a
131: * read on an open file for this inode. It is up to the caller to
132: * initialize the fields of @msg (other than @msg->list) appropriately.
133: */
134: int
135: rpc_queue_upcall(struct rpc_pipe *pipe, struct rpc_pipe_msg *msg)
136: {
137: int res = -EPIPE;
138: struct dentry *dentry;
139:
140: spin_lock(&pipe->lock);
141: if (pipe->nreaders) {
142: list_add_tail(&msg->list, &pipe->pipe);
143: pipe->pipelen += msg->len;
144: res = 0;
145: } else if (pipe->flags & RPC_PIPE_WAIT_FOR_OPEN) {
146: if (list_empty(&pipe->pipe))
147: queue_delayed_work(rpciod_workqueue,
148: &pipe->queue_timeout,
149: RPC_UPCALL_TIMEOUT);
150: list_add_tail(&msg->list, &pipe->pipe);
151: pipe->pipelen += msg->len;
152: res = 0;
153: }
154: dentry = dget(pipe->dentry);
155: spin_unlock(&pipe->lock);
156: if (dentry) {
157: wake_up(&RPC_I(d_inode(dentry))->waitq);
158: dput(dentry);
159: }
160: return res;
161: }
SourceFile:net/sunrpc/rpc_pipe.c]
|
| 42/2 |
2026/09/05 00:02 |
llm |
expert |
0m
Model:
Tokens:
input: 18015
output: 26
thoughts: 0
|
| 43/2 |
2026/09/05 00:02 |
tool |
codesearch-definition-source |
0m
Args: map[Name:__cld_pipe_upcall]
Results: map[SourceCode: 657: static int
658: __cld_pipe_upcall(struct rpc_pipe *pipe, void *cmsg, struct nfsd_net *nn)
659: {
660: int ret;
661: struct rpc_pipe_msg msg;
662: struct cld_upcall *cup = container_of(cmsg, struct cld_upcall, cu_u);
663:
664: memset(&msg, 0, sizeof(msg));
665: msg.data = cmsg;
666: msg.len = nn->client_tracking_ops->msglen;
667:
668: ret = rpc_queue_upcall(pipe, &msg);
669: if (ret < 0) {
670: goto out;
671: }
672:
673: wait_for_completion(&cup->cu_done);
674:
675: if (msg.errno < 0)
676: ret = msg.errno;
677: out:
678: return ret;
679: }
SourceFile:fs/nfsd/nfs4recover.c]
|
| 44/2 |
2026/09/05 00:02 |
llm |
expert |
0m
Model:
Tokens:
input: 18403
output: 25
thoughts: 0
|
| 45/2 |
2026/09/05 00:03 |
tool |
codesearch-definition-source |
0m
Args: map[Name:cld_pipe_upcall]
Results: map[SourceCode: 681: static int
682: cld_pipe_upcall(struct rpc_pipe *pipe, void *cmsg, struct nfsd_net *nn)
683: {
684: int ret;
685:
686: /*
687: * -EAGAIN occurs when pipe is closed and reopened while there are
688: * upcalls queued.
689: */
690: do {
691: ret = __cld_pipe_upcall(pipe, cmsg, nn);
692: } while (ret == -EAGAIN);
693:
694: return ret;
695: }
SourceFile:fs/nfsd/nfs4recover.c]
|
| 46/2 |
2026/09/05 00:03 |
llm |
expert |
0m
Model:
Tokens:
input: 18661
output: 60
thoughts: 0
|
| 47/2 |
2026/09/05 00:03 |
tool |
git-log |
0m
Args: map[CodeRegexp: Count:10 MessageRegexps:[__cld_pipe_upcall] PathPrefix: Since: SourcePath: SymbolName:]
Results: map[Output:b31da62889e6 nfsd: Initialize ssc before laundromat_work to prevent NULL dereference
df60446cd1fb nfsd: avoid a NULL dereference in __cld_pipe_upcall()
b493fd31c0b8 nfsd: fix a warning in __cld_pipe_upcall()
]
|
| 48/2 |
2026/09/05 00:03 |
llm |
expert |
0m
Model:
Tokens:
input: 18821
output: 26
thoughts: 0
|
| 49/2 |
2026/09/05 00:03 |
tool |
git-show |
0m
Args:
Results: map[Output:commit b493fd31c0b89d9453917e977002de58bebc3802
Author: Scott Mayhew <smayhew@redhat.com>
Date: Tue Nov 6 13:35:08 2018 -0500
nfsd: fix a warning in __cld_pipe_upcall()
__cld_pipe_upcall() emits a "do not call blocking ops when
!TASK_RUNNING" warning due to the dput() call in rpc_queue_upcall().
Fix it by using a completion instead of hand coding the wait.
Signed-off-by: Scott Mayhew <smayhew@redhat.com>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
diff --git a/fs/nfsd/nfs4recover.c b/fs/nfsd/nfs4recover.c
index 9c247fa1e959..5188f9f70c78 100644
--- a/fs/nfsd/nfs4recover.c
+++ b/fs/nfsd/nfs4recover.c
@@ -662,7 +662,7 @@ struct cld_net {
struct cld_upcall {
struct list_head cu_list;
struct cld_net *cu_net;
- struct task_struct *cu_task;
+ struct completion cu_done;
struct cld_msg cu_msg;
};
@@ -671,23 +671,18 @@ __cld_pipe_upcall(struct rpc_pipe *pipe, struct cld_msg *cmsg)
{
int ret;
struct rpc_pipe_msg msg;
+ struct cld_upcall *cup = container_of(cmsg, struct cld_upcall, cu_msg);
memset(&msg, 0, sizeof(msg));
msg.data = cmsg;
msg.len = sizeof(*cmsg);
- /*
- * Set task state before we queue the upcall. That prevents
- * wake_up_process in the downcall from racing with schedule.
- */
- set_current_state(TASK_UNINTERRUPTIBLE);
ret = rpc_queue_upcall(pipe, &msg);
if (ret < 0) {
- set_current_state(TASK_RUNNING);
goto out;
}
- schedule();
+ wait_for_completion(&cup->cu_done);
if (msg.errno < 0)
ret = msg.errno;
@@ -754,7 +749,7 @@ cld_pipe_downcall(struct file *filp, const char __user *src, size_t mlen)
if (copy_from_user(&cup->cu_msg, src, mlen) != 0)
return -EFAULT;
- wake_up_process(cup->cu_task);
+ complete(&cup->cu_done);
return mlen;
}
@@ -769,7 +764,7 @@ cld_pipe_destroy_msg(struct rpc_pipe_msg *msg)
if (msg->errno >= 0)
return;
- wake_up_process(cup->cu_task);
+ complete(&cup->cu_done);
}
static const struct rpc_pipe_ops cld_upcall_ops = {
@@ -900,7 +895,7 @@ alloc_cld_upcall(struct cld_net *cn)
goto restart_search;
}
}
- new->cu_task = current;
+ init_completion(&new->cu_done);
new->cu_msg.cm_vers = CLD_UPCALL_VERSION;
put_unaligned(cn->cn_xid++, &new->cu_msg.cm_xid);
new->cu_net = cn;
]
|
| 50/2 |
2026/09/05 00:03 |
llm |
expert |
0m
Model:
Tokens:
input: 19896
output: 24
thoughts: 0
|
| 51/2 |
2026/09/05 00:03 |
tool |
git-show |
0m
Args:
Results: map[Output:commit df60446cd1fb487becd1f36f4c0da9e0e523c0cf
Author: Scott Mayhew <smayhew@redhat.com>
Date: Fri Jul 10 16:33:07 2020 -0400
nfsd: avoid a NULL dereference in __cld_pipe_upcall()
If the rpc_pipefs is unmounted, then the rpc_pipe->dentry becomes NULL
and dereferencing the dentry->d_sb will trigger an oops. The only
reason we're doing that is to determine the nfsd_net, which could
instead be passed in by the caller. So do that instead.
Fixes: 11a60d159259 ("nfsd: add a "GetVersion" upcall for nfsdcld")
Signed-off-by: Scott Mayhew <smayhew@redhat.com>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
diff --git a/fs/nfsd/nfs4recover.c b/fs/nfsd/nfs4recover.c
index 9e40dfecf1b1..186fa2c2c6ba 100644
--- a/fs/nfsd/nfs4recover.c
+++ b/fs/nfsd/nfs4recover.c
@@ -747,13 +747,11 @@ struct cld_upcall {
};
static int
-__cld_pipe_upcall(struct rpc_pipe *pipe, void *cmsg)
+__cld_pipe_upcall(struct rpc_pipe *pipe, void *cmsg, struct nfsd_net *nn)
{
int ret;
struct rpc_pipe_msg msg;
struct cld_upcall *cup = container_of(cmsg, struct cld_upcall, cu_u);
- struct nfsd_net *nn = net_generic(pipe->dentry->d_sb->s_fs_info,
- nfsd_net_id);
memset(&msg, 0, sizeof(msg));
msg.data = cmsg;
@@ -773,7 +771,7 @@ __cld_pipe_upcall(struct rpc_pipe *pipe, void *cmsg)
}
static int
-cld_pipe_upcall(struct rpc_pipe *pipe, void *cmsg)
+cld_pipe_upcall(struct rpc_pipe *pipe, void *cmsg, struct nfsd_net *nn)
{
int ret;
@@ -782,7 +780,7 @@ cld_pipe_upcall(struct rpc_pipe *pipe, void *cmsg)
* upcalls queued.
*/
do {
- ret = __cld_pipe_upcall(pipe, cmsg);
+ ret = __cld_pipe_upcall(pipe, cmsg, nn);
} while (ret == -EAGAIN);
return ret;
@@ -1115,7 +1113,7 @@ nfsd4_cld_create(struct nfs4_client *clp)
memcpy(cup->cu_u.cu_msg.cm_u.cm_name.cn_id, clp->cl_name.data,
clp->cl_name.len);
- ret = cld_pipe_upcall(cn->cn_pipe, &cup->cu_u.cu_msg);
+ ret = cld_pipe_upcall(cn->cn_pipe, &cup->cu_u.cu_msg, nn);
if (!ret) {
ret = cup->cu_u.cu_msg.cm_status;
set_bit(NFSD4_CLIENT_STABLE, &clp->cl_flags);
@@ -1180,7 +1178,7 @@ nfsd4_cld_create_v2(struct nfs4_client *clp)
} else
cmsg->cm_u.cm_clntinfo.cc_princhash.cp_len = 0;
- ret = cld_pipe_upcall(cn->cn_pipe, cmsg);
+ ret = cld_pipe_upcall(cn->cn_pipe, cmsg, nn);
if (!ret) {
ret = cmsg->cm_status;
set_bit(NFSD4_CLIENT_STABLE, &clp->cl_flags);
@@ -1218,7 +1216,7 @@ nfsd4_cld_remove(struct nfs4_client *clp)
memcpy(cup->cu_u.cu_msg.cm_u.cm_name.cn_id, clp->cl_name.data,
clp->cl_name.len);
- ret = cld_pipe_upcall(cn->cn_pipe, &cup->cu_u.cu_msg);
+ ret = cld_pipe_upcall(cn->cn_pipe, &cup->cu_u.cu_msg, nn);
if (!ret) {
ret = cup->cu_u.cu_msg.cm_status;
clear_bit(NFSD4_CLIENT_STABLE, &clp->cl_flags);
@@ -1261,7 +1259,7 @@ nfsd4_cld_check_v0(struct nfs4_client *clp)
memcpy(cup->cu_u.cu_msg.cm_u.cm_name.cn_id, clp->cl_name.data,
clp->cl_name.len);
- ret = cld_pipe_upcall(cn->cn_pipe, &cup->cu_u.cu_msg);
+ ret = cld_pipe_upcall(cn->cn_pipe, &cup->cu_u.cu_msg, nn);
if (!ret) {
ret = cup->cu_u.cu_msg.cm_status;
set_bit(NFSD4_CLIENT_STABLE, &clp->cl_flags);
@@ -1404,7 +1402,7 @@ nfsd4_cld_grace_start(struct nfsd_net *nn)
}
cup->cu_u.cu_msg.cm_cmd = Cld_GraceStart;
- ret = cld_pipe_upcall(cn->cn_pipe, &cup->cu_u.cu_msg);
+ ret = cld_pipe_upcall(cn->cn_pipe, &cup->cu_u.cu_msg, nn);
if (!ret)
ret = cup->cu_u.cu_msg.cm_status;
@@ -1432,7 +1430,7 @@ nfsd4_cld_grace_done_v0(struct nfsd_net *nn)
cup->cu_u.cu_msg.cm_cmd = Cld_GraceDone;
cup->cu_u.cu_msg.cm_u.cm_gracetime = nn->boot_time;
- ret = cld_pipe_upcall(cn->cn_pipe, &cup->cu_u.cu_msg);
+ ret = cld_pipe_upcall(cn->cn_pipe, &cup->cu_u.cu_msg, nn);
if (!ret)
ret = cup->cu_u.cu_msg.cm_status;
@@ -1460,7 +1458,7 @@ nfsd4_cld_grace_done(struct nfsd_net *nn)
}
cup->cu_u.cu_msg.cm_cmd = Cld_GraceDone;
- ret = cld_pipe_upcall(cn->cn_pipe, &cup->cu_u.cu_msg);
+ ret = cld_pipe_upcall(cn->cn_pipe, &cup->cu_u.cu_msg, nn);
if (!ret)
ret = cup->cu_u.cu_msg.cm_status;
@@ -1524,7 +1522,7 @@ nfsd4_cld_get_version(struct nfsd_net *nn)
goto out_err;
}
cup->cu_u.cu_msg.cm_cmd = Cld_GetVersion;
- ret = cld_pipe_upcall(cn->cn_pipe, &cup->cu_u.cu_msg);
+ ret = cld_pipe_upcall(cn->cn_pipe, &cup->cu_u.cu_msg, nn);
if (!ret) {
ret = cup->cu_u.cu_msg.cm_status;
if (ret)
]
|
| 52/2 |
2026/09/05 00:03 |
llm |
expert |
0m
Model:
Tokens:
input: 22157
output: 58
thoughts: 0
|
| 53/2 |
2026/09/05 00:03 |
tool |
git-log |
0m
Args: map[CodeRegexp: Count:10 MessageRegexps:[rpc_queue_upcall] PathPrefix: Since: SourcePath: SymbolName:]
Results: map[Output:19a6314a997f rpc_mkpipe_dentry(): saner calling conventions
b493fd31c0b8 nfsd: fix a warning in __cld_pipe_upcall()
1cded9d2974f SUNRPC: fix refcounting problems with auth_gss messages.
bda14606a3c0 sunrpc: fix kernel-doc warnings
11588f493a24 NFS: Check return value from rpc_queue_upcall()
9e2e74dba6dd NFS: blocklayout pipe creation per network namespace context introduced
5a67657a2e90 SUNRPC: Fix race corrupting rpc upcall
]
|
| 54/2 |
2026/09/05 00:04 |
llm |
expert |
0m
Model:
Tokens:
input: 22400
output: 27
thoughts: 0
|
| 55/2 |
2026/09/05 00:04 |
tool |
git-show |
0m
Args:
Results: map[Output:commit 5a67657a2e90c9e4a48518f95d4ba7777aa20fbb
Author: Trond Myklebust <Trond.Myklebust@netapp.com>
Date: Sun Sep 12 19:55:25 2010 -0400
SUNRPC: Fix race corrupting rpc upcall
If rpc_queue_upcall() adds a new upcall to the rpci->pipe list just
after rpc_pipe_release calls rpc_purge_list(), but before it calls
gss_pipe_release (as rpci->ops->release_pipe(inode)), then the latter
will free a message without deleting it from the rpci->pipe list.
We will be left with a freed object on the rpc->pipe list. Most
frequent symptoms are kernel crashes in rpc.gssd system calls on the
pipe in question.
Reported-by: J. Bruce Fields <bfields@redhat.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Cc: stable@kernel.org
diff --git a/net/sunrpc/auth_gss/auth_gss.c b/net/sunrpc/auth_gss/auth_gss.c
index dcfc66bab2bb..12c485982814 100644
--- a/net/sunrpc/auth_gss/auth_gss.c
+++ b/net/sunrpc/auth_gss/auth_gss.c
@@ -745,17 +745,18 @@ gss_pipe_release(struct inode *inode)
struct rpc_inode *rpci = RPC_I(inode);
struct gss_upcall_msg *gss_msg;
+restart:
spin_lock(&inode->i_lock);
- while (!list_empty(&rpci->in_downcall)) {
+ list_for_each_entry(gss_msg, &rpci->in_downcall, list) {
- gss_msg = list_entry(rpci->in_downcall.next,
- struct gss_upcall_msg, list);
+ if (!list_empty(&gss_msg->msg.list))
+ continue;
gss_msg->msg.errno = -EPIPE;
atomic_inc(&gss_msg->count);
__gss_unhash_msg(gss_msg);
spin_unlock(&inode->i_lock);
gss_release_msg(gss_msg);
- spin_lock(&inode->i_lock);
+ goto restart;
}
spin_unlock(&inode->i_lock);
diff --git a/net/sunrpc/rpc_pipe.c b/net/sunrpc/rpc_pipe.c
index 95ccbcf45d3e..41a762f82630 100644
--- a/net/sunrpc/rpc_pipe.c
+++ b/net/sunrpc/rpc_pipe.c
@@ -48,7 +48,7 @@ static void rpc_purge_list(struct rpc_inode *rpci, struct list_head *head,
return;
do {
msg = list_entry(head->next, struct rpc_pipe_msg, list);
- list_del(&msg->list);
+ list_del_init(&msg->list);
msg->errno = err;
destroy_msg(msg);
} while (!list_empty(head));
@@ -208,7 +208,7 @@ rpc_pipe_release(struct inode *inode, struct file *filp)
if (msg != NULL) {
spin_lock(&inode->i_lock);
msg->errno = -EAGAIN;
- list_del(&msg->list);
+ list_del_init(&msg->list);
spin_unlock(&inode->i_lock);
rpci->ops->destroy_msg(msg);
}
@@ -268,7 +268,7 @@ rpc_pipe_read(struct file *filp, char __user *buf, size_t len, loff_t *offset)
if (res < 0 || msg->len == msg->copied) {
filp->private_data = NULL;
spin_lock(&inode->i_lock);
- list_del(&msg->list);
+ list_del_init(&msg->list);
spin_unlock(&inode->i_lock);
rpci->ops->destroy_msg(msg);
}
]
|
| 56/2 |
2026/09/05 00:04 |
llm |
expert |
0m
Model:
Tokens:
input: 23626
output: 57
thoughts: 0
|
| 57/2 |
2026/09/05 00:04 |
tool |
git-log |
0m
Args: map[CodeRegexp: Count:10 MessageRegexps:[rpc_pipe_msg] PathPrefix: Since: SourcePath: SymbolName:]
Results: map[Output:5ffaf8554163 NFS: replace global bl_wq with per-net one
]
|
| 58/2 |
2026/09/05 00:04 |
llm |
expert |
0m
Model:
Tokens:
input: 23719
output: 57
thoughts: 0
|
| 59/2 |
2026/09/05 00:04 |
tool |
git-log |
0m
Args: map[CodeRegexp: Count:10 MessageRegexps:[rpc_pipe_release] PathPrefix: Since: SourcePath: SymbolName:]
Results: map[Output:5a67657a2e90 SUNRPC: Fix race corrupting rpc upcall
747c5534c9a6 RPC: stops the release_pipe() funtion from being called twice
]
|
| 60/2 |
2026/09/05 00:04 |
llm |
expert |
0m
Model:
Tokens:
input: 23840
output: 57
thoughts: 0
|
| 61/2 |
2026/09/05 00:05 |
tool |
git-log |
0m
Args: map[CodeRegexp: Count:10 MessageRegexps:[rpc_pipe_read] PathPrefix: Since: SourcePath: SymbolName:]
Results: map[Output:1cded9d2974f SUNRPC: fix refcounting problems with auth_gss messages.
]
|
| 62/2 |
2026/09/05 00:05 |
llm |
expert |
0m
Model:
Tokens:
input: 23935
output: 25
thoughts: 0
|
| 63/2 |
2026/09/05 00:05 |
tool |
git-show |
0m
Args:
Results: map[Output:commit 1cded9d2974fe4fe339fc0ccd6638b80d465ab2c
Author: NeilBrown <neilb@suse.com>
Date: Mon Dec 5 15:10:11 2016 +1100
SUNRPC: fix refcounting problems with auth_gss messages.
There are two problems with refcounting of auth_gss messages.
First, the reference on the pipe->pipe list (taken by a call
to rpc_queue_upcall()) is not counted. It seems to be
assumed that a message in pipe->pipe will always also be in
pipe->in_downcall, where it is correctly reference counted.
However there is no guaranty of this. I have a report of a
NULL dereferences in rpc_pipe_read() which suggests a msg
that has been freed is still on the pipe->pipe list.
One way I imagine this might happen is:
- message is queued for uid=U and auth->service=S1
- rpc.gssd reads this message and starts processing.
This removes the message from pipe->pipe
- message is queued for uid=U and auth->service=S2
- rpc.gssd replies to the first message. gss_pipe_downcall()
calls __gss_find_upcall(pipe, U, NULL) and it finds the
*second* message, as new messages are placed at the head
of ->in_downcall, and the service type is not checked.
- This second message is removed from ->in_downcall and freed
by gss_release_msg() (even though it is still on pipe->pipe)
- rpc.gssd tries to read another message, and dereferences a pointer
to this message that has just been freed.
I fix this by incrementing the reference count before calling
rpc_queue_upcall(), and decrementing it if that fails, or normally in
gss_pipe_destroy_msg().
It seems strange that the reply doesn't target the message more
precisely, but I don't know all the details. In any case, I think the
reference counting irregularity became a measureable bug when the
extra arg was added to __gss_find_upcall(), hence the Fixes: line
below.
The second problem is that if rpc_queue_upcall() fails, the new
message is not freed. gss_alloc_msg() set the ->count to 1,
gss_add_msg() increments this to 2, gss_unhash_msg() decrements to 1,
then the pointer is discarded so the memory never gets freed.
Fixes: 9130b8dbc6ac ("SUNRPC: allow for upcalls for same uid but different gss service")
Cc: stable@vger.kernel.org
Link: https://bugzilla.opensuse.org/show_bug.cgi?id=1011250
Signed-off-by: NeilBrown <neilb@suse.com>
Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
diff --git a/net/sunrpc/auth_gss/auth_gss.c b/net/sunrpc/auth_gss/auth_gss.c
index 3dfd769dc5b5..16cea00c959b 100644
--- a/net/sunrpc/auth_gss/auth_gss.c
+++ b/net/sunrpc/auth_gss/auth_gss.c
@@ -541,9 +541,13 @@ gss_setup_upcall(struct gss_auth *gss_auth, struct rpc_cred *cred)
return gss_new;
gss_msg = gss_add_msg(gss_new);
if (gss_msg == gss_new) {
- int res = rpc_queue_upcall(gss_new->pipe, &gss_new->msg);
+ int res;
+ atomic_inc(&gss_msg->count);
+ res = rpc_queue_upcall(gss_new->pipe, &gss_new->msg);
if (res) {
gss_unhash_msg(gss_new);
+ atomic_dec(&gss_msg->count);
+ gss_release_msg(gss_new);
gss_msg = ERR_PTR(res);
}
} else
@@ -836,6 +840,7 @@ gss_pipe_destroy_msg(struct rpc_pipe_msg *msg)
warn_gssd();
gss_release_msg(gss_msg);
}
+ gss_release_msg(gss_msg);
}
static void gss_pipe_dentry_destroy(struct dentry *dir,
]
|
| 64/2 |
2026/09/05 00:05 |
llm |
expert |
0m
Model:
Tokens:
input: 25203
output: 26
thoughts: 0
|
| 65/2 |
2026/09/05 00:05 |
tool |
codesearch-definition-source |
0m
Args: map[Name:cld_pipe_destroy_msg]
Results: map[SourceCode: 834: static void
835: cld_pipe_destroy_msg(struct rpc_pipe_msg *msg)
836: {
837: struct cld_msg *cmsg = msg->data;
838: struct cld_upcall *cup = container_of(cmsg, struct cld_upcall,
839: cu_u.cu_msg);
840:
841: /* errno >= 0 means we got a downcall */
842: if (msg->errno >= 0)
843: return;
844:
845: complete(&cup->cu_done);
846: }
SourceFile:fs/nfsd/nfs4recover.c]
|
| 66/2 |
2026/09/05 00:05 |
llm |
expert |
0m
Model:
Tokens:
input: 25453
output: 23
thoughts: 0
|
| 67/2 |
2026/09/05 00:05 |
tool |
codesearch-definition-source |
0m
Args:
Results: map[SourceCode: 281: static ssize_t
282: rpc_pipe_read(struct file *filp, char __user *buf, size_t len, loff_t *offset)
283: {
284: struct inode *inode = file_inode(filp);
285: struct rpc_pipe *pipe;
286: struct rpc_pipe_msg *msg;
287: int res = 0;
288:
289: inode_lock(inode);
290: pipe = RPC_I(inode)->pipe;
291: if (pipe == NULL) {
292: res = -EPIPE;
293: goto out_unlock;
294: }
295: msg = filp->private_data;
296: if (msg == NULL) {
297: spin_lock(&pipe->lock);
298: if (!list_empty(&pipe->pipe)) {
299: msg = list_entry(pipe->pipe.next,
300: struct rpc_pipe_msg,
301: list);
302: list_move(&msg->list, &pipe->in_upcall);
303: pipe->pipelen -= msg->len;
304: filp->private_data = msg;
305: msg->copied = 0;
306: }
307: spin_unlock(&pipe->lock);
308: if (msg == NULL)
309: goto out_unlock;
310: }
311: /* NOTE: it is up to the callback to update msg->copied */
312: res = pipe->ops->upcall(filp, msg, buf, len);
313: if (res < 0 || msg->len == msg->copied) {
314: filp->private_data = NULL;
315: spin_lock(&pipe->lock);
316: list_del_init(&msg->list);
317: spin_unlock(&pipe->lock);
318: pipe->ops->destroy_msg(msg);
319: }
320: out_unlock:
321: inode_unlock(inode);
322: return res;
323: }
SourceFile:net/sunrpc/rpc_pipe.c]
|
| 68/2 |
2026/09/05 00:05 |
llm |
expert |
0m
Model:
Tokens:
input: 26144
output: 23
thoughts: 0
|
| 69/2 |
2026/09/05 00:05 |
tool |
codesearch-definition-source |
0m
Args: map[Name:rpc_pipe_release]
Results: map[SourceCode: 240: static int
241: rpc_pipe_release(struct inode *inode, struct file *filp)
242: {
243: struct rpc_pipe *pipe;
244: struct rpc_pipe_msg *msg;
245: int last_close;
246:
247: inode_lock(inode);
248: pipe = RPC_I(inode)->pipe;
249: if (pipe == NULL)
250: goto out;
251: msg = filp->private_data;
252: if (msg != NULL) {
253: spin_lock(&pipe->lock);
254: msg->errno = -EAGAIN;
255: list_del_init(&msg->list);
256: spin_unlock(&pipe->lock);
257: pipe->ops->destroy_msg(msg);
258: }
259: if (filp->f_mode & FMODE_WRITE)
260: pipe->nwriters --;
261: if (filp->f_mode & FMODE_READ) {
262: pipe->nreaders --;
263: if (pipe->nreaders == 0) {
264: LIST_HEAD(free_list);
265: spin_lock(&pipe->lock);
266: list_splice_init(&pipe->pipe, &free_list);
267: pipe->pipelen = 0;
268: spin_unlock(&pipe->lock);
269: rpc_purge_list(&RPC_I(inode)->waitq, &free_list,
270: pipe->ops->destroy_msg, -EAGAIN);
271: }
272: }
273: last_close = pipe->nwriters == 0 && pipe->nreaders == 0;
274: if (last_close && pipe->ops->release_pipe)
275: pipe->ops->release_pipe(inode);
276: out:
277: inode_unlock(inode);
278: return 0;
279: }
SourceFile:net/sunrpc/rpc_pipe.c]
|
| 70/2 |
2026/09/05 00:05 |
llm |
expert |
0m
Model:
Tokens:
input: 26801
output: 25
thoughts: 0
|
| 71/2 |
2026/09/05 00:05 |
tool |
codesearch-definition-source |
0m
Args: map[Name:cld_pipe_downcall]
Results: map[SourceCode: 771: static ssize_t
772: cld_pipe_downcall(struct file *filp, const char __user *src, size_t mlen)
773: {
774: struct cld_upcall *tmp, *cup;
775: struct cld_msg_hdr __user *hdr = (struct cld_msg_hdr __user *)src;
776: struct cld_msg_v2 __user *cmsg = (struct cld_msg_v2 __user *)src;
777: uint32_t xid;
778: struct nfsd_net *nn = net_generic(file_inode(filp)->i_sb->s_fs_info,
779: nfsd_net_id);
780: struct cld_net *cn = nn->cld_net;
781: int16_t status;
782:
783: if (mlen != nn->client_tracking_ops->msglen) {
784: dprintk("%s: got %zu bytes, expected %zu\n", __func__, mlen,
785: nn->client_tracking_ops->msglen);
786: return -EINVAL;
787: }
788:
789: /* copy just the xid so we can try to find that */
790: if (copy_from_user(&xid, &hdr->cm_xid, sizeof(xid)) != 0) {
791: dprintk("%s: error when copying xid from userspace", __func__);
792: return -EFAULT;
793: }
794:
795: /*
796: * copy the status so we know whether to remove the upcall from the
797: * list (for -EINPROGRESS, we just want to make sure the xid is
798: * valid, not remove the upcall from the list)
799: */
800: if (get_user(status, &hdr->cm_status)) {
801: dprintk("%s: error when copying status from userspace", __func__);
802: return -EFAULT;
803: }
804:
805: /* walk the list and find corresponding xid */
806: cup = NULL;
807: spin_lock(&cn->cn_lock);
808: list_for_each_entry(tmp, &cn->cn_list, cu_list) {
809: if (get_unaligned(&tmp->cu_u.cu_hdr.cm_xid) == xid) {
810: cup = tmp;
811: if (status != -EINPROGRESS)
812: list_del_init(&cup->cu_list);
813: break;
814: }
815: }
816: spin_unlock(&cn->cn_lock);
817:
818: /* couldn't find upcall? */
819: if (!cup) {
820: dprintk("%s: couldn't find upcall -- xid=%u\n", __func__, xid);
821: return -EINVAL;
822: }
823:
824: if (status == -EINPROGRESS)
825: return __cld_pipe_inprogress_downcall(cmsg, nn);
826:
827: if (copy_from_user(&cup->cu_u.cu_msg_v2, src, mlen) != 0)
828: return -EFAULT;
829:
830: complete(&cup->cu_done);
831: return mlen;
832: }
SourceFile:fs/nfsd/nfs4recover.c]
|
| 72/2 |
2026/09/05 00:05 |
llm |
expert |
0m
Model:
Tokens:
input: 27896
output: 28
thoughts: 0
|
| 73/2 |
2026/09/05 00:05 |
tool |
codesearch-definition-source |
0m
Args: map[Name:__cld_pipe_inprogress_downcall]
Results: map[SourceCode: 697: static ssize_t
698: __cld_pipe_inprogress_downcall(const struct cld_msg_v2 __user *cmsg,
699: struct nfsd_net *nn)
700: {
701: uint8_t cmd, princhashlen;
702: struct xdr_netobj name, princhash = { .len = 0, .data = NULL };
703: char *namecopy __free(kfree) = NULL;
704: char *princhashcopy __free(kfree) = NULL;
705: uint16_t namelen;
706:
707: if (get_user(cmd, &cmsg->cm_cmd)) {
708: dprintk("%s: error when copying cmd from userspace", __func__);
709: return -EFAULT;
710: }
711: if (cmd == Cld_GraceStart) {
712: if (nn->client_tracking_ops->version >= 2) {
713: const struct cld_clntinfo __user *ci;
714:
715: ci = &cmsg->cm_u.cm_clntinfo;
716: if (get_user(namelen, &ci->cc_name.cn_len))
717: return -EFAULT;
718: if (namelen == 0 || namelen > NFS4_OPAQUE_LIMIT) {
719: dprintk("%s: invalid namelen (%u)", __func__, namelen);
720: return -EINVAL;
721: }
722: namecopy = memdup_user(&ci->cc_name.cn_id, namelen);
723: if (IS_ERR(namecopy))
724: return PTR_ERR(namecopy);
725: name.data = namecopy;
726: name.len = namelen;
727: if (get_user(princhashlen, &ci->cc_princhash.cp_len))
728: return -EFAULT;
729: if (princhashlen > 0) {
730: princhashcopy = memdup_user(
731: &ci->cc_princhash.cp_data,
732: princhashlen);
733: if (IS_ERR(princhashcopy))
734: return PTR_ERR(princhashcopy);
735: princhash.data = princhashcopy;
736: princhash.len = princhashlen;
737: } else
738: princhash.len = 0;
739: } else {
740: const struct cld_name __user *cnm;
741:
742: cnm = &cmsg->cm_u.cm_name;
743: if (get_user(namelen, &cnm->cn_len))
744: return -EFAULT;
745: if (namelen == 0 || namelen > NFS4_OPAQUE_LIMIT) {
746: dprintk("%s: invalid namelen (%u)", __func__, namelen);
747: return -EINVAL;
748: }
749: namecopy = memdup_user(&cnm->cn_id, namelen);
750: if (IS_ERR(namecopy))
751: return PTR_ERR(namecopy);
752: name.data = namecopy;
753: name.len = namelen;
754: }
755: #ifdef CONFIG_NFSD_LEGACY_CLIENT_TRACKING
756: if (name.len > 5 && memcmp(name.data, "hash:", 5) == 0) {
757: struct cld_net *cn = nn->cld_net;
758:
759: name.len = name.len - 5;
760: name.data = name.data + 5;
761: cn->cn_has_legacy = true;
762: }
763: #endif
764: if (!nfs4_client_to_reclaim(name, princhash, nn))
765: return -EFAULT;
766: return nn->client_tracking_ops->msglen;
767: }
768: return -EFAULT;
769: }
SourceFile:fs/nfsd/nfs4recover.c]
|
| 74/2 |
2026/09/05 00:05 |
llm |
expert |
0m
Model:
Tokens:
input: 29199
output: 25
thoughts: 0
|
| 75/2 |
2026/09/05 00:05 |
tool |
codesearch-definition-source |
0m
Args:
Results: map[SourceCode: 848: static const struct rpc_pipe_ops cld_upcall_ops = {
849: .upcall = rpc_pipe_generic_upcall,
850: .downcall = cld_pipe_downcall,
851: .destroy_msg = cld_pipe_destroy_msg,
852: };
SourceFile:fs/nfsd/nfs4recover.c]
|
| 76/2 |
2026/09/05 00:05 |
llm |
expert |
0m
Model:
Tokens:
input: 29356
output: 26
thoughts: 0
|
| 77/2 |
2026/09/05 00:05 |
tool |
codesearch-definition-source |
0m
Args: map[Name:rpc_pipe_generic_upcall]
Results: map[SourceCode: 104: ssize_t rpc_pipe_generic_upcall(struct file *filp, struct rpc_pipe_msg *msg,
105: char __user *dst, size_t buflen)
106: {
107: char *data = (char *)msg->data + msg->copied;
108: size_t mlen = min(msg->len - msg->copied, buflen);
109: unsigned long left;
110:
111: left = copy_to_user(dst, data, mlen);
112: if (left == mlen) {
113: msg->errno = -EFAULT;
114: return -EFAULT;
115: }
116:
117: mlen -= left;
118: msg->copied += mlen;
119: msg->errno = 0;
120: return mlen;
121: }
SourceFile:net/sunrpc/rpc_pipe.c]
|
| 78/2 |
2026/09/05 00:05 |
llm |
expert |
0m
Model:
Tokens:
input: 29685
output: 60
thoughts: 0
|
| 79/2 |
2026/09/05 00:05 |
tool |
git-log |
0m
Args: map[CodeRegexp: Count:10 MessageRegexps:[rpc_pipe_generic_upcall] PathPrefix: Since: SourcePath: SymbolName:]
Results: map[Output:b18cba09e374 SUNRPC: ensure the matching upcall is in-flight upon downcall
]
|
| 80/2 |
2026/09/05 00:06 |
llm |
expert |
0m
Model:
Tokens:
input: 29785
output: 26
thoughts: 0
|
| 81/2 |
2026/09/05 00:06 |
tool |
git-show |
0m
Args:
Results: map[Output:commit b18cba09e374637a0a3759d856a6bca94c133952
Author: minoura makoto <minoura@valinux.co.jp>
Date: Tue Dec 13 13:14:31 2022 +0900
SUNRPC: ensure the matching upcall is in-flight upon downcall
Commit 9130b8dbc6ac ("SUNRPC: allow for upcalls for the same uid
but different gss service") introduced `auth` argument to
__gss_find_upcall(), but in gss_pipe_downcall() it was left as NULL
since it (and auth->service) was not (yet) determined.
When multiple upcalls with the same uid and different service are
ongoing, it could happen that __gss_find_upcall(), which returns the
first match found in the pipe->in_downcall list, could not find the
correct gss_msg corresponding to the downcall we are looking for.
Moreover, it might return a msg which is not sent to rpc.gssd yet.
We could see mount.nfs process hung in D state with multiple mount.nfs
are executed in parallel. The call trace below is of CentOS 7.9
kernel-3.10.0-1160.24.1.el7.x86_64 but we observed the same hang w/
elrepo kernel-ml-6.0.7-1.el7.
PID: 71258 TASK: ffff91ebd4be0000 CPU: 36 COMMAND: "mount.nfs"
#0 [ffff9203ca3234f8] __schedule at ffffffffa3b8899f
#1 [ffff9203ca323580] schedule at ffffffffa3b88eb9
#2 [ffff9203ca323590] gss_cred_init at ffffffffc0355818 [auth_rpcgss]
#3 [ffff9203ca323658] rpcauth_lookup_credcache at ffffffffc0421ebc
[sunrpc]
#4 [ffff9203ca3236d8] gss_lookup_cred at ffffffffc0353633 [auth_rpcgss]
#5 [ffff9203ca3236e8] rpcauth_lookupcred at ffffffffc0421581 [sunrpc]
#6 [ffff9203ca323740] rpcauth_refreshcred at ffffffffc04223d3 [sunrpc]
#7 [ffff9203ca3237a0] call_refresh at ffffffffc04103dc [sunrpc]
#8 [ffff9203ca3237b8] __rpc_execute at ffffffffc041e1c9 [sunrpc]
#9 [ffff9203ca323820] rpc_execute at ffffffffc0420a48 [sunrpc]
The scenario is like this. Let's say there are two upcalls for
services A and B, A -> B in pipe->in_downcall, B -> A in pipe->pipe.
When rpc.gssd reads pipe to get the upcall msg corresponding to
service B from pipe->pipe and then writes the response, in
gss_pipe_downcall the msg corresponding to service A will be picked
because only uid is used to find the msg and it is before the one for
B in pipe->in_downcall. And the process waiting for the msg
corresponding to service A will be woken up.
Actual scheduing of that process might be after rpc.gssd processes the
next msg. In rpc_pipe_generic_upcall it clears msg->errno (for A).
The process is scheduled to see gss_msg->ctx == NULL and
gss_msg->msg.errno == 0, therefore it cannot break the loop in
gss_create_upcall and is never woken up after that.
This patch adds a simple check to ensure that a msg which is not
sent to rpc.gssd yet is not chosen as the matching upcall upon
receiving a downcall.
Signed-off-by: minoura makoto <minoura@valinux.co.jp>
Signed-off-by: Hiroshi Shimamoto <h-shimamoto@nec.com>
Tested-by: Hiroshi Shimamoto <h-shimamoto@nec.com>
Cc: Trond Myklebust <trondmy@hammerspace.com>
Fixes: 9130b8dbc6ac ("SUNRPC: allow for upcalls for same uid but different gss service")
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
diff --git a/include/linux/sunrpc/rpc_pipe_fs.h b/include/linux/sunrpc/rpc_pipe_fs.h
index cd188a527d16..3b35b6f6533a 100644
--- a/include/linux/sunrpc/rpc_pipe_fs.h
+++ b/include/linux/sunrpc/rpc_pipe_fs.h
@@ -92,6 +92,11 @@ extern ssize_t rpc_pipe_generic_upcall(struct file *, struct rpc_pipe_msg *,
char __user *, size_t);
extern int rpc_queue_upcall(struct rpc_pipe *, struct rpc_pipe_msg *);
+/* returns true if the msg is in-flight, i.e., already eaten by the peer */
+static inline bool rpc_msg_is_inflight(const struct rpc_pipe_msg *msg) {
+ return (msg->copied != 0 && list_empty(&msg->list));
+}
+
struct rpc_clnt;
extern struct dentry *rpc_create_client_dir(struct dentry *, const char *, struct rpc_clnt *);
extern int rpc_remove_client_dir(struct rpc_clnt *);
diff --git a/net/sunrpc/auth_gss/auth_gss.c b/net/sunrpc/auth_gss/auth_gss.c
index 7bb247c51e2f..2d7b1e03110a 100644
--- a/net/sunrpc/auth_gss/auth_gss.c
+++ b/net/sunrpc/auth_gss/auth_gss.c
@@ -302,7 +302,7 @@ __gss_find_upcall(struct rpc_pipe *pipe, kuid_t uid, const struct gss_auth *auth
list_for_each_entry(pos, &pipe->in_downcall, list) {
if (!uid_eq(pos->uid, uid))
continue;
- if (auth && pos->auth->service != auth->service)
+ if (pos->auth->service != auth->service)
continue;
refcount_inc(&pos->count);
return pos;
@@ -686,6 +686,21 @@ gss_create_upcall(struct gss_auth *gss_auth, struct gss_cred *gss_cred)
return err;
}
+static struct gss_upcall_msg *
+gss_find_downcall(struct rpc_pipe *pipe, kuid_t uid)
+{
+ struct gss_upcall_msg *pos;
+ list_for_each_entry(pos, &pipe->in_downcall, list) {
+ if (!uid_eq(pos->uid, uid))
+ continue;
+ if (!rpc_msg_is_inflight(&pos->msg))
+ continue;
+ refcount_inc(&pos->count);
+ return pos;
+ }
+ return NULL;
+}
+
#define MSG_BUF_MAXSIZE 1024
static ssize_t
@@ -732,7 +747,7 @@ gss_pipe_downcall(struct file *filp, const char __user *src, size_t mlen)
err = -ENOENT;
/* Find a matching upcall */
spin_lock(&pipe->lock);
- gss_msg = __gss_find_upcall(pipe, uid, NULL);
+ gss_msg = gss_find_downcall(pipe, uid);
if (gss_msg == NULL) {
spin_unlock(&pipe->lock);
goto err_put_ctx;
]
|
| 82/2 |
2026/09/05 00:06 |
llm |
expert |
0m
Model:
Tokens:
input: 31999
output: 23
thoughts: 0
|
| 83/2 |
2026/09/05 00:06 |
tool |
codesearch-definition-source |
0m
Args:
Results: map[SourceCode: 281: static ssize_t
282: rpc_pipe_read(struct file *filp, char __user *buf, size_t len, loff_t *offset)
283: {
284: struct inode *inode = file_inode(filp);
285: struct rpc_pipe *pipe;
286: struct rpc_pipe_msg *msg;
287: int res = 0;
288:
289: inode_lock(inode);
290: pipe = RPC_I(inode)->pipe;
291: if (pipe == NULL) {
292: res = -EPIPE;
293: goto out_unlock;
294: }
295: msg = filp->private_data;
296: if (msg == NULL) {
297: spin_lock(&pipe->lock);
298: if (!list_empty(&pipe->pipe)) {
299: msg = list_entry(pipe->pipe.next,
300: struct rpc_pipe_msg,
301: list);
302: list_move(&msg->list, &pipe->in_upcall);
303: pipe->pipelen -= msg->len;
304: filp->private_data = msg;
305: msg->copied = 0;
306: }
307: spin_unlock(&pipe->lock);
308: if (msg == NULL)
309: goto out_unlock;
310: }
311: /* NOTE: it is up to the callback to update msg->copied */
312: res = pipe->ops->upcall(filp, msg, buf, len);
313: if (res < 0 || msg->len == msg->copied) {
314: filp->private_data = NULL;
315: spin_lock(&pipe->lock);
316: list_del_init(&msg->list);
317: spin_unlock(&pipe->lock);
318: pipe->ops->destroy_msg(msg);
319: }
320: out_unlock:
321: inode_unlock(inode);
322: return res;
323: }
SourceFile:net/sunrpc/rpc_pipe.c]
|
| 84/2 |
2026/09/05 00:06 |
llm |
expert |
0m
Model:
Tokens:
input: 32690
output: 26
thoughts: 0
|
| 85/2 |
2026/09/05 00:06 |
tool |
codesearch-definition-source |
0m
Args: map[Name:__cld_pipe_upcall]
Results: map[SourceCode: 657: static int
658: __cld_pipe_upcall(struct rpc_pipe *pipe, void *cmsg, struct nfsd_net *nn)
659: {
660: int ret;
661: struct rpc_pipe_msg msg;
662: struct cld_upcall *cup = container_of(cmsg, struct cld_upcall, cu_u);
663:
664: memset(&msg, 0, sizeof(msg));
665: msg.data = cmsg;
666: msg.len = nn->client_tracking_ops->msglen;
667:
668: ret = rpc_queue_upcall(pipe, &msg);
669: if (ret < 0) {
670: goto out;
671: }
672:
673: wait_for_completion(&cup->cu_done);
674:
675: if (msg.errno < 0)
676: ret = msg.errno;
677: out:
678: return ret;
679: }
SourceFile:fs/nfsd/nfs4recover.c]
|
| 86/2 |
2026/09/05 00:06 |
llm |
expert |
0m
Model:
Tokens:
input: 33078
output: 24
thoughts: 0
|
| 87/2 |
2026/09/05 00:06 |
tool |
codesearch-definition-source |
0m
Args: map[Name:rpc_queue_upcall]
Results: map[SourceCode: 124: /**
125: * rpc_queue_upcall - queue an upcall message to userspace
126: * @pipe: upcall pipe on which to queue given message
127: * @msg: message to queue
128: *
129: * Call with an @inode created by rpc_mkpipe() to queue an upcall.
130: * A userspace process may then later read the upcall by performing a
131: * read on an open file for this inode. It is up to the caller to
132: * initialize the fields of @msg (other than @msg->list) appropriately.
133: */
134: int
135: rpc_queue_upcall(struct rpc_pipe *pipe, struct rpc_pipe_msg *msg)
136: {
137: int res = -EPIPE;
138: struct dentry *dentry;
139:
140: spin_lock(&pipe->lock);
141: if (pipe->nreaders) {
142: list_add_tail(&msg->list, &pipe->pipe);
143: pipe->pipelen += msg->len;
144: res = 0;
145: } else if (pipe->flags & RPC_PIPE_WAIT_FOR_OPEN) {
146: if (list_empty(&pipe->pipe))
147: queue_delayed_work(rpciod_workqueue,
148: &pipe->queue_timeout,
149: RPC_UPCALL_TIMEOUT);
150: list_add_tail(&msg->list, &pipe->pipe);
151: pipe->pipelen += msg->len;
152: res = 0;
153: }
154: dentry = dget(pipe->dentry);
155: spin_unlock(&pipe->lock);
156: if (dentry) {
157: wake_up(&RPC_I(d_inode(dentry))->waitq);
158: dput(dentry);
159: }
160: return res;
161: }
SourceFile:net/sunrpc/rpc_pipe.c]
|
| 88/2 |
2026/09/05 00:06 |
llm |
expert |
0m
Model:
Tokens:
input: 33737
output: 66
thoughts: 0
|
| 89/2 |
2026/09/05 00:06 |
tool |
set-results |
0m
Args: map[DenialOfService:true Exploitable:true FilesystemTrigger:false NetworkTrigger:true PeripheralTrigger:false RemoteTrigger:false Unprivileged:false UserNamespace:false VMGuestTrigger:false VMHostTrigger:false]
Results: map[DenialOfService:true Exploitable:true FilesystemTrigger:false NetworkTrigger:true PeripheralTrigger:false RemoteTrigger:false Unprivileged:false UserNamespace:false VMGuestTrigger:false VMHostTrigger:false]
|
| 90/2 |
2026/09/05 00:06 |
llm |
expert |
2m
Model:
Tokens:
input: 33867
output: 789
thoughts: 19024
Thoughts: **Analysis of the vmalloc-out-of-bounds in `rpc_queue_upcall` (nfsd/cld pipe)**
Okay, here's my breakdown of this bug. This is a classic stack use-after-free, or a vmalloc-out-of-bounds read in some kernel configurations, that arises from how the NFS client tracking daemon (`nfsdcld`) interacts with the kernel's NFS server (`nfsd`) through the `cld` pipe (`/var/lib/nfs/rpc_pipefs/nfsd/cld`).
The core of the problem lies in the `__cld_pipe_upcall` function. It allocates a message (`msg`) on the stack, enqueues it onto the pipe, and then waits for a completion (`cup->cu_done`). The expectation is that `nfsdcld` will *read* this message from the pipe, process it, and then *write a reply* back to the pipe. This reply triggers the `cld_pipe_downcall` function, which completes the `cu_done` completion variable. This allows the waiting thread to continue.
The vulnerability comes into play when the reply is written *before* the initial upcall is read. This can happen if some malicious process writes to the pipe or `nfsdcld` incorrectly writes to the pipe based on a race condition. In this scenario, `cld_pipe_downcall` is called, and the `cu_done` completion variable is completed, allowing the thread to continue. The issue? `cld_pipe_downcall` *doesn't* remove the `msg` from the internal lists `pipe->pipe` or `pipe->in_upcall`. So, the stack frame of `msg` is freed, however the message is still in memory. Then, at some later point, when other operations are executed, like adding new messages to `pipe->pipe` or reading `pipe->pipe`, the kernel attempts to access the freed stack, which is now corrupted, leading to the vmalloc-out-of-bounds read and the crash reported by KASAN.
Crucially, this is *not* a vulnerability that is easily exploited. Access to the `cld` pipe is *restricted* to the root user (permissions `0600`). The exploit requires writing to that local pipe to the correct XID, something unprivileged users cannot accomplish. So, while the bug is a serious memory corruption issue, itβs limited to local root access, or a misbehaving root process, like a buggy `nfsdcld`. A remote attacker cannot directly trigger this as the remote attack vector is not linked to the local pipe write.
|
| 91/1 |
2026/09/05 00:09 |
action |
format-explanation |
0m
Results: map[Explanation:**Bug Analysis:**
The bug is a stack-use-after-free (reported as `vmalloc-out-of-bounds` due to
`CONFIG_VMAP_STACK`) in the SunRPC pipe code, specifically when handling NFSv4
client tracking upcalls (`cld_pipe_upcall`).
1. **The Vulnerability Mechanism:**
In `__cld_pipe_upcall()`, an `rpc_pipe_msg` struct is allocated on the stack.
It is then queued to the `rpc_pipe` via `rpc_queue_upcall()`, which adds it
to the `pipe->pipe` list. The function then waits for the upcall to be
processed using `wait_for_completion(&cup->cu_done)`.
Normally, the user-space daemon (`nfsdcld`) reads the upcall from the pipe.
The `read()` operation (`rpc_pipe_read()`) removes the `msg` from the pipe's
lists once fully read. Later, the daemon writes a reply to the pipe, which
invokes `cld_pipe_downcall()`. This downcall completes the `cu_done`
completion, waking up `__cld_pipe_upcall()` which then safely returns.
However, if a process writes a reply to the pipe *before* the upcall is fully
read (or guesses the `xid` and writes a preemptive reply),
`cld_pipe_downcall()` will complete `cu_done` immediately.
`__cld_pipe_upcall()` wakes up and returns, destroying its stack frame.
Crucially, `cld_pipe_downcall()` does not remove the `msg` from the
`pipe->pipe` list. This leaves a dangling pointer to the freed stack frame on
the list. A subsequent upcall will traverse this corrupted list in
`list_add_tail()`, leading to the out-of-bounds access and crash.
2. **Exploitability:**
Memory safety issues involving linked list corruption and
stack-use-after-free are generally exploitable for arbitrary code execution
or privilege escalation. However, the context of this bug heavily restricts
its threat model.
3. **Access and Privileges:**
To trigger this bug, an attacker must be able to write to the `nfsdcld` pipe
(typically located at `/var/lib/nfs/rpc_pipefs/nfsd/cld`).
- This pipe is created with `0600` permissions (`S_IRUSR | S_IWUSR`) and is
owned by root.
- The `rpc_pipefs` filesystem does not support `FS_USERNS_MOUNT`, meaning it
cannot be mounted inside an unprivileged user namespace.
- Therefore, only a local root user (or a compromised `nfsdcld` daemon) can
write to this pipe and trigger the bug. Syzkaller (which runs as root in its
test environment) easily triggers this by writing random data to the pipe.
4. **Remote/Network Trigger:**
While NFS is a network service and a remote client can induce the server to
generate upcalls, the remote client cannot write to the local `rpc_pipefs`
pipe. The bug strictly requires a local write to the pipe to cause the
premature completion. Thus, it cannot be triggered over the network.
**Conclusion:**
The bug is a valid memory corruption issue (Stack UAF) that causes a Denial of
Service and is theoretically exploitable. However, because it strictly requires
local root privileges to write to the restricted `rpc_pipefs` pipe, it does not
cross any security boundaries. It is inaccessible to unprivileged users, user
namespaces, or remote attackers.]
|