Article View: linux.kernel.netdev
Article #27051Re: [PATCH net] net: qrtr: smd: hold packets that arrive before probe has finished
From: netdev-bot+sashiko
Date: Fri, 04 Dec 2026 17:46
Date: Fri, 04 Dec 2026 17:46
165 lines
13405 bytes
13405 bytes
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.
Critical: 0 ยท High: 0 ยท Medium: 2 ยท 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).
- [Medium] On SMD, a packet held during probe can now be lost, and
nothing logs it.
- [Medium] While drvdata is NULL, the remote can fill the held queue
without limit.
--
net: qrtr: smd: hold packets that arrive before probe has finished
This patch changes qrtr-smd so that packets arriving before probe has set
the driver data are held in a devres-backed sk_buff_head. Once the QRTR
endpoint is registered, the held packets are posted and drvdata is
published under a global spinlock. The goal is to stop losing the remote's
HELLO on GLINK, which ignores the callback's return value.
> diff --git a/net/qrtr/smd.c b/net/qrtr/smd.c
> index 8b30b8275a2d9..e9e984db1e961 100644
> --- a/net/qrtr/smd.c
> +++ b/net/qrtr/smd.c
[ ... ]
> @@ -36,6 +49,91 @@ 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);
[Severity: Medium]
Is there a limit on how much the remote can queue here while drvdata is
NULL?
Each packet gets a GFP_ATOMIC copy, which is added to the held queue
without any check on qlen or total bytes, and the function then returns 0.
qcom_smd_channel_recv_single() only skips qcom_smd_channel_advance() when
the callback returns a negative value. So SMD keeps reading from the FIFO.
What used to be back-pressure in shared memory turns into kernel
allocations.
The window includes qrtr_endpoint_register(), which does GFP_KERNEL
allocations and takes qrtr_node_lock. Under memory pressure the window can
get longer.
The window also seems to open again on unbind. rpmsg_dev_remove() calls
rpdrv->remove() before rpmsg_destroy_ept(), and qcom_smd_qrtr_remove()
does:
dev_set_drvdata(&rpdev->dev, NULL);
Packets that arrive between those two calls are copied, only to be freed
by devres_release_all().
Later, qcom_smd_qrtr_post_held() drains the whole queue through
qrtr_endpoint_post(). That is one more GFP_ATOMIC allocation per packet,
plus sock_queue_rcv_skb() and the wakeups. All of it runs inside
spin_lock_irqsave() on the global qrtr_smd_held_lock, which every qrtr-smd
device shares.
Does the time with IRQs off on the probing CPU then grow with the number
of packets the remote queued?
Would it help to cap the held queue, returning -EAGAIN on SMD when the cap
is reached? The queue could also be spliced out under the lock, so that
the posting happens with IRQs enabled.
> +
> +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 unsigned int qcom_smd_qrtr_post_held(struct rpmsg_device *rpdev,
> + struct qrtr_smd_dev *qdev)
> +{
> + struct sk_buff_head *held;
> + unsigned int count = 0;
> + struct sk_buff *skb;
> + unsigned long flags;
> +
> + spin_lock_irqsave(&qrtr_smd_held_lock, flags);
> +
> + held = devres_find(&rpdev->dev, qcom_smd_qrtr_held_release, NULL, NULL);
> + if (held) {
> + while ((skb = __skb_dequeue(held))) {
> + qcom_smd_qrtr_post(qdev, skb->data, skb->len);
> + consume_skb(skb);
> + count++;
> + }
> + }
[Severity: Medium]
Can a held packet be lost here with nothing logged? The return value of
qcom_smd_qrtr_post() is ignored, and the skb is consumed and counted
whatever happens.
qrtr_endpoint_post() can return -ENOMEM:
skb = __netdev_alloc_skb(NULL, len, GFP_ATOMIC | __GFP_NOWARN);
if (!skb)
return -ENOMEM;
Before this patch, a packet that arrived on SMD while drvdata was NULL got
-EAGAIN. qcom_smd_channel_recv_single() then left it in the RX FIFO to be
delivered again:
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);
Now qcom_smd_qrtr_hold() copies the packet and returns 0. SMD advances the
tail, and the devres queue holds the only copy. If the GFP_ATOMIC
allocation fails during this drain, the packet is gone for good. That
packet is often the remote's HELLO. The "held packets: %u" debug line
still counts it as passed on.
The commit message doesn't mention that SMD moves from keeping the packet
in the FIFO for a retry to copying and holding it. Is that change
intended?
Could rc be checked here, so the code at least warns or keeps the packet?
Another option would be to keep returning -EAGAIN on SMD.
> +
> + dev_set_drvdata(&rpdev->dev, qdev);
> +
> + spin_unlock_irqrestore(&qrtr_smd_held_lock, flags);
> +
> + return count;
> +}
[ ... ]
--
Sashiko AI review ยท https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261203170532.3598521-1-gabin278%40gmail.com
Technical Details
Message-ID:
<179640638895.3146.13536976927342826919@kernel.org>Path:
mbox-mo1.pugleaf.net!feed-us-txt.newsdeef.eu!feed-us-ny.newsdeef.eu!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-377516-linux-kernel-netdev=dewy.ruReferences:
<20261203170532.3598521-1-gabin278@gmail.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!feed-us-txt.newsdeef.eu!feed-us-ny.newsdeef.eu!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-377516-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net] net: qrtr: smd: hold packets that arrive before probe has finished Date: Fri, 04 Dec 2026 17:46:28 +0000 Organization: Usenet Network Message-ID: <179640638895.3146.13536976927342826919@kernel.org> References: <20261203170532.3598521-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="2821632"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:LmlvUiyyvy34wVy8kACgCBDKPLg= sha256:evrZbefBViEuUuPgBnfjb2plFn8jlarBdAH6wF4scgk= sha1:efz08DsbDN5Rh/MYzvTtddn+eog= sha256:UA4T0xtu4sMsV3d55unDGSKkTCV2Mt92tmtoK8YLYHE= 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 329C8117C80; Fri, 4 Dec 2026 20:47:08 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.541 X-Spam-Status: No, score=-3.541 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.142, 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 IAwsxjXeoxnj; Fri, 4 Dec 2026 20:47:00 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-377516-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 52F65117C76; Fri, 4 Dec 2026 20:46:46 +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 E787767205; Fri, 4 Dec 2026 17:46:34 +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=1796406391; b=4BqgKrS9EyJ6ImQH1PTNJRh9DvyOImHtTqim+XuHyDK9DBcjzgGYBRiIxh2u1hJa5H5C TU3WSvEaOV1iCq4QgRlGdB2hEqDRwiNZa1qQYvsgqsqXPvpuqbhfHCM0ojm1c3d8Lfq18 1utNpCokrppbfoUn1VPtWPI+6cwW0jWlV/t912QCXLcNXVKuIimonOHU7ubQy6M1Nsdyl Fvb+gihHBrjQB8GCeSXF+PD5QD2Up0vbV1wiwSdGr4d4IxuhkxlL39jQZeF5uF+/DWjMh pAO28lFdqxhq4mG3mB/JTItxOsefdX3fbvFrj13y9I4aUp3DlbkXeJiPgOgBEjcj/eQ== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796406391; 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=VYuQchBHlwHeF7HLJx+ag25mhnZ+EKER1UmWfCqLAbE=; b=EpST/lv0U26+PupTeWzt0N4TynXbCA+G/0NIXrVawhFdZjhVx4GBt6b/s2s86A/HpQW2 SAWgnvqyqCQCpWXaSF4Ko7i3rn5kV2+J1TDymMqeNJLE5w8JtLwMDCW6NaQtQVkHlEQ4k bBON70AjpS4HZj396wjiJcXqC9psjugqgAqhhnnp6TpjkAhhrrxDDbsoPvbPv3tMLCC9E dBR1vFBA+78XKwd8k3E0yLWJiRnZkY9OgbyhTNC7ltGdMqKmqjnDdXx756cHxe8l/xglU ePvBS5jzfOdzgYVvYVniUuQBqBWPQSty7C/vBUTd6kcEc4D6/rqx286LA7HQqGrb4/Q== 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=GHNmkrdb; 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 3EBE4606A6B0; Fri, 4 Dec 2026 17:46:31 +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=GHNmkrdb 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=1796406390; b=VOg2WU2PP8g6BkLflgN7BE8GPFNEAjZbqSW/1t8kpzIUIH1ln28EHCchWbAmCYiXcIH3 N95gdPLqHeXSbY2T6w1iVC44UBzglOR1MWqLzyPTBTMLgwxGUHvL9J4EER8kZH00qWcOg IBolFD6itjkTct1kCfWS7mV8xu/FAKwvrU01OSMNcW1SMUcEifrfx776+LKwa07E7Dge0 571rrknui6HFwT7YeyzwklgGk2kl443MtE19YKn7nPIUthyCmLQspy5cgYPoUH2mfGaQd JnjID0hJbVez/xfODIQqwlzyd2kyvFKUyxXRpNvLwnr22BGAxYZkn5K4Ggrfs2JGNIQ== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796406390; 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=VYuQchBHlwHeF7HLJx+ag25mhnZ+EKER1UmWfCqLAbE=; b=eEBAStQSjEpV5+PRZ0+uVQYJftPIJ21PJm/wmU4VNDs0Dx8likpNqw2NeK47QcgHnFU1 SRUj31qqoJNdQ2YqaBRvkxBorWF2Z2q4TIyNP0QgMAMrmgZoOidez9t/srAWN+b9VF5Wd AvQRBoA/16h6BfnpqphmffzkFO9E//f6Vss1EDtK2llmBc2YQm0j9Z3zbjXs0wSav6tvP JHv7TYN9+W2y/5rJvK+X6bb6GVf+nmCDTpwbNVYOojYz8HmcViioyQNPS39JFlSXiwISn TOPT0fDSduTtvJhTdPgTJj1ZWcr10WE6+0X9PrlxSB1oBdf+lFYQ2gYAKLDvF65mSBQ== 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=GHNmkrdb; 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) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5FB04606A688; Fri, 4 Dec 2026 17:46:30 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6D1ED1F00A06; Fri, 4 Dec 2026 17:46:29 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796406390; bh=VYuQchBHlwHeF7HLJx+ag25mhnZ+EKER1UmWfCqLAbE=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=GHNmkrdb+6l7gFNXdMYjMWaVSjA4Yjm+98DK+CfY8WfHuULxGn0GN9kOZiakrt2DS k+wa9vO9KWjIvYzVIYvV00sAAH6kdXnqUguZP3huMO8038YUnqjNH709jRw4SGHW1W Lxt5wcWGcx0AQ9t4N4CDVMUtAKggU8kFWhNYa9MSu9KiYXJcDUBmUQOHxiTZ4OVIOI Y7qynkMspu0fDze8RnNgWTfKpNPSApDSt9X6MCOQrG13C1Wi2ih/WJZHajLi6XsweD wlogoav8pQ0OikQ0c4MRRwtCoycV584H7r1mjZISKrAbA21M4fsxPPg16S5vLg3ngz j7/RcfroV+GRg== 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: <20261203170532.3598521-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