From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 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== 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== 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 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) 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 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6D1ED1F00A06; Fri, 4 Dec 2026 17:46:29 +0000 (UTC) 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== Subject: Re: [PATCH net] net: qrtr: smd: hold packets that arrive before probe has finished From: netdev-bot+sashiko@kernel.org To: gabin278@gmail.com 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 Date: Fri, 04 Dec 2026 17:46:28 +0000 Message-ID: <179640638895.3146.13536976927342826919@kernel.org> In-Reply-To: <20261203170532.3598521-1-gabin278@gmail.com> References: <20261203170532.3598521-1-gabin278@gmail.com> X-sashiko-severity: Medium Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 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