From: netdev-bot+sashiko@kernel.org
To: davidlwesten@gmail.com
Cc: netdev@vger.kernel.org, loic.poulain@oss.qualcomm.com,
ryazanov.s.a@gmail.com, johannes@sipsolutions.net,
andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@kernel.org,
kuba@kernel.org, pabeni@redhat.com, m.chetan.kumar@intel.com
Subject: Re: [PATCH net] net: wwan: iosm: return the callback result of synchronous tasks
Date: Sat, 28 Nov 2026 03:49:14 +0000 [thread overview]
Message-ID: <179583775492.3135.6308026077719961194@kernel.org> (raw)
In-Reply-To: <20261127034849.11770-1-davidlwesten@gmail.com>
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
prev parent reply other threads:[~2026-11-28 3:49 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-27 3:48 [PATCH net] net: wwan: iosm: return the callback result of synchronous tasks David Westen
2026-11-28 3:49 ` netdev-bot+sashiko [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=179583775492.3135.6308026077719961194@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=davidlwesten@gmail.com \
--cc=edumazet@kernel.org \
--cc=johannes@sipsolutions.net \
--cc=kuba@kernel.org \
--cc=loic.poulain@oss.qualcomm.com \
--cc=m.chetan.kumar@intel.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=ryazanov.s.a@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox