Article View: linux.kernel.netdev
Article #27522Re: [PATCH net v2] net: qrtr: smd: hold packets that arrive before probe has finished
From: netdev-bot+sashiko
Date: Sat, 05 Dec 2026 21:54
Date: Sat, 05 Dec 2026 21:54
208 lines
14431 bytes
14431 bytes
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.
Critical: 0 ยท High: 0 (1) ยท Medium: 1 ยท Low: 1
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).
- [Medium] On SMD, this patch adds a way to lose a packet permanently,
and that packet can be the remote's HELLO.
- [Low] The posted/dropped counts that qcom_smd_qrtr_post_held() reports
are wrong.
Pre-existing issues:
- [High] This problem wasn't introduced by this patch, but there is a
NULL dereference or use-after-free in the unbind window.
--
net: qrtr: smd: hold packets that arrive before probe has finished
Packets can arrive on the IPCRTR channel before qcom_smd_qrtr_probe() has
set the driver data. This patch keeps those packets in a skb queue managed
by devres, with a cap of 32. Once the endpoint is registered, probe posts
the held packets and then publishes the driver data, both under one global
spinlock.
> diff --git a/net/qrtr/smd.c b/net/qrtr/smd.c
> index 8b30b8275a2d9..f7b1fa340b790 100644
> --- a/net/qrtr/smd.c
> +++ b/net/qrtr/smd.c
[ ... ]
> @@ -36,6 +56,100 @@ static int qcom_smd_qrtr_callback(struct rpmsg_device *rpdev,
> return rc;
> }
>
> +static int qcom_smd_qrtr_hold(struct rpmsg_device *rpdev, void *data, int len)
> +{
[ ... ]
> + skb = alloc_skb(len, GFP_ATOMIC);
> + if (!skb) {
> + rc = -ENOMEM;
> + goto out;
> + }
> + skb_put_data(skb, data, len);
> + __skb_queue_tail(held, skb);
> +
> +out:
> + spin_unlock_irqrestore(&qrtr_smd_held_lock, flags);
> +
> + return rc;
> +}
> +
> +/* Post the packets held during probe, then publish @qdev so the callback
> + * posts directly. Both happen under the lock, so held packets are posted
> + * before any packet that arrives later.
> + */
> +static void qcom_smd_qrtr_post_held(struct rpmsg_device *rpdev,
> + struct qrtr_smd_dev *qdev,
> + unsigned int *posted, unsigned int *dropped)
> +{
[ ... ]
> + held = devres_find(&rpdev->dev, qcom_smd_qrtr_held_release, NULL, NULL);
> + if (held) {
> + while ((skb = __skb_dequeue(held))) {
> + rc = qcom_smd_qrtr_post(qdev, skb->data, skb->len);
> + if (rc) {
> + kfree_skb(skb);
> + (*dropped)++;
[Severity: Medium]
On SMD, can this lose a held packet for good? That packet could be the
remote's HELLO.
Before this patch, a packet that arrived before probe finished got
-EAGAIN. qcom_smd_channel_recv_single() in drivers/rpmsg/qcom_smd.c then
left it in the FIFO:
ret = ept->cb(ept->rpdev, ptr, len, ept->priv, RPMSG_ADDR_ANY);
if (ret < 0)
return ret;
/* Only forward the tail if the client consumed the data */
qcom_smd_channel_advance(channel, len);
SMD would read the packet again later. The same happened when
qrtr_endpoint_post() itself failed with -ENOMEM.
Now qcom_smd_qrtr_hold() copies the packet and returns 0, so SMD moves
the tail past it.
In this loop, qrtr_endpoint_post() allocates with
__netdev_alloc_skb(NULL, len, GFP_ATOMIC | __GFP_NOWARN) while
qrtr_smd_held_lock is held with IRQs off. If that allocation fails, it
returns -ENOMEM, the skb is freed here, and nothing retries it.
The commit message says a held packet that can't be passed on "is dropped
with a warning". Before this patch, though, the SMD transport could not
lose a packet this way, and the commit message itself says that losing the
HELLO crashes the modem.
Could the SMD retry behaviour be kept for this case?
> + } else {
> + consume_skb(skb);
> + (*posted)++;
[Severity: Low]
Are these posted/dropped counts accurate? qcom_smd_qrtr_post() turns
every -EINVAL from qrtr_endpoint_post() into 0:
rc = qrtr_endpoint_post(&qdev->ep, data, len);
if (rc == -EINVAL) {
dev_err(qdev->dev, "invalid ipcrouter packet\n");
/* return 0 to let smd drop the packet */
rc = 0;
}
qrtr_endpoint_post() returns -EINVAL from its err: path after freeing the
skb. It takes that path for a malformed header, when no socket is bound to
the destination port, and when sock_queue_rcv_skb() fails:
ipc = qrtr_port_lookup(cb->dst_port);
if (!ipc)
goto err;
...
err:
kfree_skb(skb);
return -EINVAL;
This loop counts those discarded packets as posted. The new dev_warn() in
qcom_smd_qrtr_probe() therefore counts only -ENOMEM drops, and the dev_dbg()
summary can report a lost HELLO as posted.
The "return 0 to let smd drop the packet" comment also no longer fits this
caller, because nothing is returned to SMD for held packets.
> + }
> + }
> + }
> +
> + dev_set_drvdata(&rpdev->dev, qdev);
> +
> + spin_unlock_irqrestore(&qrtr_smd_held_lock, flags);
> +}
> +
> +/* from smd to qrtr */
> +static int qcom_smd_qrtr_callback(struct rpmsg_device *rpdev,
> + void *data, int len, void *priv, u32 addr)
> +{
> + struct qrtr_smd_dev *qdev = dev_get_drvdata(&rpdev->dev);
> +
> + if (!qdev)
> + return qcom_smd_qrtr_hold(rpdev, data, len);
> +
> + return qcom_smd_qrtr_post(qdev, data, len);
> +}
[Severity: High]
This is a pre-existing issue, not one introduced by this patch. Can this
callback run against a released qrtr node during unbind?
rpmsg_dev_remove() calls the driver's remove() before it destroys the
endpoint:
if (rpdrv->remove)
rpdrv->remove(rpdev);
if (rpdev->ept)
rpmsg_destroy_ept(rpdev->ept);
qcom_smd_qrtr_remove() unregisters the endpoint before it clears the
driver data:
qrtr_endpoint_unregister(&qdev->ep);
dev_set_drvdata(&rpdev->dev, NULL);
qrtr_endpoint_unregister() ends with qrtr_node_release(node), which can
free the node, and then sets ep->node = NULL. A packet that arrives in
this window still sees a non-NULL qdev here and goes through:
qcom_smd_qrtr_callback()
qcom_smd_qrtr_post()
qrtr_endpoint_post()
qrtr_node_assign(ep->node, ...)
radix_tree_insert(&qrtr_nodes, nid, node);
With a NULL node, this oopses on node->nid. With a freed node, a dangling
pointer ends up in the global qrtr_nodes radix tree.
The notes below the commit message mention this ordering problem and
promise a separate fix. Could that fix use the new qrtr_smd_held_lock to
order clearing the driver data against the callback, before
qrtr_endpoint_unregister() is called?
--
Sashiko AI review ยท https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261204210624.535124-1-gabin278%40gmail.com
Technical Details
Message-ID:
<179650769062.3148.8280707500727880191@kernel.org>Path:
mbox-mo1.pugleaf.net!news-wdc.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-378151-linux-kernel-netdev=dewy.ruReferences:
<20261204210624.535124-1-gabin278@gmail.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-wdc.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-378151-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net v2] net: qrtr: smd: hold packets that arrive before probe has finished Date: Sat, 05 Dec 2026 21:54:50 +0000 Organization: Usenet Network Message-ID: <179650769062.3148.8280707500727880191@kernel.org> References: <20261204210624.535124-1-gabin278@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="3127628"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:C8sykvmjcuBFnFnrgzEty/bIbPM= sha256:698Z2++8IPdjLrktn9j0/bTbLxO52hlFWJ+PYmA0CBo= sha1:1xzJtuEA3tHeLVvvhZqWvpveh2E= sha256:GPUHErxeJSFigB3iPMCUTihKuwlbYmRBAbkNSJZ5z6k= List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id D8603117EC4; Sun, 6 Dec 2026 00:55:13 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.539 X-Spam-Status: No, score=-3.539 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.14, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key) header.d=kernel.org X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Ot26GyOmmipM; Sun, 6 Dec 2026 00:55:10 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-378151-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mail.dewy.ru (Postfix) with ESMTPS id 375BA117DCB; Sun, 6 Dec 2026 00:54:58 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sea.lore.kernel.org (Postfix) with ESMTP id A24F02F044; Sat, 5 Dec 2026 21:54:53 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796507692; b=dVEqfFuau9KL+c9AXuSY92l04iPD2A25d9BI/5xKNJ184HYq3LPigr9f45qHAAJo8FNj FDW9gcUp6zwd7KvvPdJGqsqCglJLePNsiI/9YkUHLYPoM0kSWOQ2vDLy2J5urYvwUhi4c sZUHnLhOUynrFbX6VUThx99MpNut0s1l/PP7aplYCzU3tdIixGMkQfN98y4C3DsyTx/ZL khCT/v6N0XImXtpw+ptMhBIHPKxKLKmUfLW0xXHzFLvTphq1fJHN8YFuKBFm5GzJHcLk4 J8zyAWoh8rmVilW5euUpOBTtFxUJ3JQDkpo2qbHgcmYHj8bs0OFFYUNE/LjVTTYgCYg== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796507692; h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc: Date:Message-ID:In-Reply-To:References:X-sashiko-severity: Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id: List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner: Precedence:MIME-Version; bh=SMwxIJ4qcml5aZMsuA7ffL7Eb5o2IN4AQzek4247jr8=; b=UGozEUFnbqfbbLXg9TSnVhrt/lW4oxy4aJ7l4Q2l9kRRfY4w4LFt4FKMySpch52Z300n SwY1G/VKdDwIov/5KDaiQB0VNlS25ewvJ2Vzf3VCG57It7EokK8ShWKhvqvclOH4vpM/9 yWHCPYvI+eU+ctGGXSft6MXR5WhoM1GpQbcjLjbly/OORwapCpTN5rXL574ia36GClVno uA/6Tu/2Tkn/dWpCINkWgpt7zyvTCoKC74Yr0aJSXCPy1w4TK7cRCPLhncg1lh9DUeURN ctGz7/AJ2VgQJ0mT6aw4FeOOS1VQpZwVqU6sSE5YTKtpE+H3tm3xaHAGIIVZIyKkOVA== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=f+qvWwnO; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D12C6606A338; Sat, 5 Dec 2026 21:54:52 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=f+qvWwnO X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796507692; b=1rOMMJl05rIOculUqZl0R40JLWIFhav32CHGb0kKsI5tlnI4FUjhIGnyqzNtLSSjvbfC YaFf7OcPk0+w1VaH//a9pAIGsRRzoJz3Ewa5b9ia3Zx+nruWyZwv7PRFsHaDPII6tKcI3 CDGOyRDhP4yfpXNFBPExEtWxIhCwIj2rS9L9qxCyH/NSlmPOEvJvLSjsZ3qlUkukRUnC4 V9zh8jY8UOvIF+c1MtGONIslLBU4hj3q9o/rBexHTNX1F2omgUKNPmVVwy3lw3zzBUOIG YrwcGVrlAKoHhG81vBGpBtJmy/9x7CQ1CrorUUriwuXDXbAsrmW1Y95a9suAh1+8qKA== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796507692; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=SMwxIJ4qcml5aZMsuA7ffL7Eb5o2IN4AQzek4247jr8=; b=DfEdk8ckRXlCKieXm+p3tr0fLQZQn7A0cB81yVs2I5tvczG6Ymig0ltp2RD+s2c7f8Xl MNyujZB+WThXrewNsMuAsZecaSIfaca7ftE64bUB3C3qub4IR+1Yuoc2q9snzivdwkp1d ykM0PVqwuIhErCPWNA87Y5TpcSgy5EywdytvMht4itMLTZ9+PyZxhM/x0yScjuRrJOFsa LuAMquDsKuK8ybfPohp90GZT8ZNDhPCI07uU96XBOpbJSTnaGIcPiIVjByjCWyoQEK6bz 1ofUN15ypiVOx4Q4pkC37DOJrV3LlFM63aR8gSCQQdm8sITA6vjurFsiA5nqsqsKfHQ== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=f+qvWwnO; arc=none smtp.remote-ip=100.103.45.18 X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EFB0C606A31F; Sat, 5 Dec 2026 21:54:51 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2270E1F00A07; Sat, 5 Dec 2026 21:54:51 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796507691; bh=SMwxIJ4qcml5aZMsuA7ffL7Eb5o2IN4AQzek4247jr8=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=f+qvWwnOo2IpnrKp+qM6Y4m6unPCW4WMm3dfMQbmYe7t8HUMtRMO7x8InwlIIvk6R tE+PnvOvgzvLQShZEtVsb6xoP7k1MaNNpg33g7iflClVxwy4caoJWS8q6VV53iG6fQ A6IAqP84VcJbv79nBHnz5ogta2qMUJc6JSJOwsxlpRqFFbzHFejm+qLz+f6DiThZPA rQvim7sIg0rCvKcITV2XY4eZqGFP74ISMLZWGQWUVha94gS+KpAfGrhAaEYCEDl1LS ZlD6kUWkqAlbshefWrRrpWfUvLBQOHQckMWbMp6hkRrZJH/dvImL5sWtgU1SEDz+us JxgMqgQi8U3Gw== X-Cc: mani@kernel.org, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, willemb@google.com, horms@kernel.org, andersson@kernel.org, netdev@vger.kernel.org, linux-arm-msm@vger.kernel.org X-In-Reply-To: <20261204210624.535124-1-gabin278@gmail.com> X-sashiko-severity: Medium X-Mailing-List: netdev@vger.kernel.org X-List-Post: <mailto:netdev@vger.kernel.org> X-List-Help: <mailto:netdev+help@vger.kernel.org> X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-List-Owner: <mailto:netdev+owner@vger.kernel.org> X-Precedence: list