Thread View: linux.kernel.netdev
3 messages
3 total messages
Started by David Westen
Fri, 27 Nov 2026 03:48
[PATCH net] net: wwan: iosm: return the callback result of synchronous tasks
Author: David Westen
Date: Fri, 27 Nov 2026 03:48
Date: Fri, 27 Nov 2026 03:48
51 lines
12237 bytes
12237 bytes
ipc_task_queue_send_task() is documented to return the callback's
result, but returns 0 whenever the callback succeeds.
ipc_protocol_msg_send() uses that result as the message ring slot that
points to its on-stack response, so a timeout clears slot 0 and leaves
the real slot pointing to the returned stack frame. A late reply then
calls complete() on it:
BUG: unable to handle page fault for address: fffffffffffffff8
RIP: 0010:complete+0x9c/0x2b0
Call Trace:
<IRQ>
ipc_protocol_msg_process
ipc_imem_tq_irq_cb
ipc_task_queue_handler
Return the callback result. The other callers see the same values as
before.
Reproduced on an XMM7360 by forcing pipe open and close timeouts.
Fixes: 3b575260cb86 ("net: iosm: bottom half")
Signed-off-by: David Westen <davidlwesten@gmail.com>
---
Notes:
The bug was found in an AI-assisted review of the driver. The
investigation, the test changes, the patch and this changelog were done
with an AI coding assistant (Claude Opus 5.5). I ran the tests and
reviewed the result.
drivers/net/wwan/iosm/iosm_ipc_task_queue.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/drivers/net/wwan/iosm/iosm_ipc_task_queue.c b/drivers/net/wwan/iosm/iosm_ipc_task_queue.c
index 7cb2f6a506d9..069075481825 100644
--- a/drivers/net/wwan/iosm/iosm_ipc_task_queue.c
+++ b/drivers/net/wwan/iosm/iosm_ipc_task_queue.c
@@ -162,10 +162,8 @@ int ipc_task_queue_send_task(struct iosm_imem *imem,
copy, size, is_copy);
if (is_copy)
kfree(copy);
- goto out;
}
- ret = 0;
out:
return ret;
}
--
2.56.0
Re: [PATCH net] net: wwan: iosm: return the callback result of synchronous tasks
Author: netdev-bot+sashiko
Date: Sat, 28 Nov 2026 03:49
Date: Sat, 28 Nov 2026 03:49
146 lines
12904 bytes
12904 bytes
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.
Critical: 0 ยท High: 1 ยท Medium: 1 ยท Low: 0
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [High] The fix still leaves a way for a late device reply to call
complete() on a returned stack frame.
- [Medium] The patch now passes the callback result through unchanged,
and ipc_protocol_msg_send() uses it as the rsp_ring index.
--
net: wwan: iosm: return the callback result of synchronous tasks
This patch makes ipc_task_queue_send_task() return the callback result
instead of 0 when the task was queued and completed. ipc_protocol_msg_send()
uses that value as the rsp_ring index. With this change, a timeout clears
the slot that actually points at its on-stack response.
> diff --git a/drivers/net/wwan/iosm/iosm_ipc_task_queue.c b/drivers/net/wwan/iosm/iosm_ipc_task_queue.c
> index 7cb2f6a506d9f..069075481825e 100644
> --- a/drivers/net/wwan/iosm/iosm_ipc_task_queue.c
> +++ b/drivers/net/wwan/iosm/iosm_ipc_task_queue.c
> @@ -162,10 +162,8 @@ int ipc_task_queue_send_task(struct iosm_imem *imem,
> copy, size, is_copy);
> if (is_copy)
> kfree(copy);
> - goto out;
> }
>
> - ret = 0;
> out:
> return ret;
> }
[Severity: High]
The index is now correct. Can a late reply still call complete() on a
returned stack frame if the remove task itself fails to queue?
The timeout path in ipc_protocol_msg_send() ignores the return value of
the remove call:
drivers/net/wwan/iosm/iosm_ipc_protocol.c:ipc_protocol_msg_send() {
...
case 0:
ipc_task_queue_send_task(ipc_protocol->imem,
ipc_protocol_tq_msg_remove, index,
NULL, 0, true);
dev_err(ipc_protocol->dev, "msg timeout");
...
return 0;
}
If the 256-entry task ring is full, ipc_task_queue_add_task() takes the
"queue is full" branch. It then returns -EIO without ever running
ipc_protocol_tq_msg_remove():
if (nextpos != ipc_task->q_rpos) {
...
}
...
} else {
dev_err(ipc_imem->ipc_task->dev, "queue is full");
}
In that case rsp_ring[index] still points at the on-stack struct ipc_rsp
response after ipc_protocol_msg_send() has returned 0. When the device
answers later, ipc_protocol_msg_process() does:
if (rsp_ring[i]) {
rsp_ring[i]->status =
le32_to_cpu(msg->common.completion_status);
complete(&rsp_ring[i]->completion);
rsp_ring[i] = NULL;
}
That looks like the same oops shown in the commit message, which says:
so a timeout clears slot 0 and leaves the real slot pointing to the
returned stack frame. A late reply then calls complete() on it
Should the failed enqueue be handled too? Some options would be retrying,
clearing the slot under a lock the tasklet also takes, or not returning
while rsp_ring[index] can still reference the stack.
[Severity: Medium]
Now that the exact callback result is used as an rsp_ring index, is the
read of that result in ipc_task_queue_add_task() safe?
drivers/net/wwan/iosm/iosm_ipc_task_queue.c:ipc_task_queue_add_task() {
...
if (wait) {
wait_for_completion(&completion);
result = ipc_task->args[pos].response;
}
...
}
This reads args[pos] without q_lock and without checking that the slot
still belongs to this caller.
ipc_task_queue_handler() calls complete(), clears the entry and moves
q_rpos past pos right away:
if (args->completion)
complete(args->completion);
...
q_rpos = (q_rpos + 1) % IPC_THREAD_QUEUE_SIZE;
ipc_task->q_rpos = q_rpos;
So slot pos can be reused before the woken waiter runs. If the ring
wraps, a new producer writes args[pos].response = -1 under q_lock. The
tasklet may then store another callback's result in that slot.
One way this could happen: the queue is nearly full and the tasklet runs
on the waiter's CPU. The tasklet keeps looping in softirq while
IRQ-context producers refill slot pos, and the waiter cannot read its
result in the meantime. Whether this shows up on real systems depends on
load and timing.
If the waiter reads -1, ipc_protocol_msg_send() returns an error even
though the message was sent and rsp_ring[real_index] = &response.
If it reads another task's result, the timeout path clears the wrong
slot.
Either way, a later device reply would call complete() on a returned
stack frame.
The comment in ipc_task_queue_handler() relies on timing ("queue will not
rotate again to ipc_task same element within such short time") rather
than on synchronization.
Would it be more robust to keep the response in caller-owned storage, for
example next to the on-stack completion, instead of re-reading the shared
ring slot?
--
Sashiko AI review ยท https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261127034849.11770-1-davidlwesten%40gmail.com
Re: [PATCH net] net: wwan: iosm: return the callback result of synchronous tasks
Author: "David Westen"
Date: Sat, 28 Nov 2026 16:32
Date: Sat, 28 Nov 2026 16:32
25 lines
11898 bytes
11898 bytes
On Sat, Nov 28, 2026 at 03:49:14AM +0000, netdev-bot+sashiko@kernel.org wrote: > [Severity: High] > The index is now correct. Can a late reply still call complete() on a > returned stack frame if the remove task itself fails to queue? Yes, but this isn't new. Before this patch, a timeout cleared slot 0 if the remove task was queued and nothing if it wasn't, so unless the message was in slot 0, a late reply could reach the stack frame either way. This patch fixes the queued case. The queue-full case is a separate bug, where the return value of the remove task is ignored, and is unchanged here. > [Severity: Medium] > Now that the exact callback result is used as an rsp_ring index, is the > read of that result in ipc_task_queue_add_task() safe? No, but this patch doesn't make it worse. A waiter that reads -1 already returned an error while rsp_ring[index] still pointed at its response. Before this patch, any other value led to slot 0 being cleared on a timeout, which was already wrong. Thanks, David
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads