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=1796403970; b=ZU81pdp0zLBNrwnPHaftpCTQS9Rr0NOqMYs7ePkb2TSFDKi9tHZxZI+9ytACVeEVSDsK i5OntW/tpcYTGISq14fZC8vKdoTYVnATlR3XhuGfWbYdeoY90/8YOD0xUtzAJ7Gcd8EXc Xx/36uxhEirJdNRZKTH8feSmjBNx7n8G6gBEboJ3B2ASbH0Zwjgi8QGbn3F1VYtaLg/TB WDZ6JhsDNJ4wHYnkaWO0y5N7esTcHKjdhL+paOOYGzvFW/Fq38tpJYhG8xFiZlMTAMkQZ eGDeW5XbnaRmBnxuk+JH2c6pvSZUO61ZqEEOjI5CoUQiPoI6FTX0Jc5iY5k4AI1ueDQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796403970; 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=JxBP8lyezxfXqN5G22GSjDYoWb/zm61wExer2UsqfSA=; b=zzj/YqR4cnMfXeKByh+4CxjAqU3nKsSrLiW73ibUhQEIAtyxTXompJx/Fkh7Dwq8UKmO +4B6N+l3O00YpPIfoswU54Qh8UAWYvWldFAcxaGtJ2ksjo9Bx03CFEuHmo1SmSGBHaDgc CGW+VXxmBmPcEWmQNotIZN2JLx/kB6YJv4pZrHhY83H5qaBR27cNlczIVDCyyZsrMb3ox wMSMLjdXqRWVf80Du0eQrIRPw8DWxBWgi9ek2/kxmrMDtgrrtxUP3op5WUEi3CM/wCrFm PGIhi97EG52QrNIwIR7Nd/dNFtxE9qrPVo2qBncZSzwk/14AGL9RYrdtzq3cW4X+UKA== 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=iWn0252s; 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)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 718B8606A680; Fri, 4 Dec 2026 17:06:10 +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=iWn0252s Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3FD091F0093B; Fri, 4 Dec 2026 17:06:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796403970; bh=JxBP8lyezxfXqN5G22GSjDYoWb/zm61wExer2UsqfSA=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=iWn0252svpd19KfKJtpQvaaZ3PLlc9/k5liz9g557+fHcdGQLAWM29e0cKAZVRI46 jELLsumjFoydJg/XW9nreNwj6Ws33OfT82Pqx8QaW4XUp2blbH9ps+jdij4I9jlFyE RnAWr7f059r0oOGgDjYZIOCOlA8ZbDMbCyOn+SPblVc2hgnmQLJcs2cFYpopH0mWCc uEk3yrd8EGUFeOgA/D6JkB80CpIzCpXRsjV9A5MMYiwnktGzm/CU1O22agLV5ei6bx yR5t22SHGBHinBsi8ks+AczKsLqyH/LT/kU39Crih6UiMn/B3YdckXnQbBq590zmxm ZolB6F6vBbiUQ== Subject: Re: [PATCH net-next 2/3] net: wwan: qcom_bam_dmux: use DMA transfer size for RX packets From: netdev-bot+sashiko@kernel.org To: vishnu.santhosh@oss.qualcomm.com Cc: vkoul@kernel.org, Frank.Li@kernel.org, stephan@gerhold.net, 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, linux-arm-msm@vger.kernel.org, dmaengine@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, deepak.singh@oss.qualcomm.com Date: Fri, 04 Dec 2026 17:06:08 +0000 Message-ID: <179640396883.3146.15360849304828602379@kernel.org> In-Reply-To: <20261203-qcom-bam-dmux-qmap-v1-2-abc2e80a03af@oss.qualcomm.com> References: <20261203-qcom-bam-dmux-qmap-v1-2-abc2e80a03af@oss.qualcomm.com> X-sashiko-severity: Low Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Mailing-List: dmaengine@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 more severe issue(s) in other patches of this series. This mail is only an FYI, in case you want to address the nit picks below when you respin. Low priority / nit picks for your consideration: - [Low] Undisclosed hard dependency on the bam_dma residue patch, plus a requested Fixes: tag. - [Low] The 0xffff length derivation ignores hdr->pad. Pre-existing issues: - [Low] Zero-length DATA packet handling in bam_dmux_cmd_data(). -- net: wwan: qcom_bam_dmux: use DMA transfer size for RX packets The RX DMA callback now uses the dmaengine result variant, so the driver knows how many bytes were received. It drops failed or too-short transfers. For DATA frames whose header length is 0xffff, it takes the payload length from the DMA transfer size. The old check against the buffer size is replaced with a check against the received size. > diff --git a/drivers/net/wwan/qcom_bam_dmux.c b/drivers/net/wwan/qcom_bam_dmux.c > index e1cc3038a724e..a7d05b1b8b123 100644 > --- a/drivers/net/wwan/qcom_bam_dmux.c > +++ b/drivers/net/wwan/qcom_bam_dmux.c [ ... ] > @@ -500,21 +502,23 @@ static bool bam_dmux_skb_dma_queue_rx(struct bam_dmux_skb_dma *skb_dma, gfp_t gf > bam_dmux_skb_dma_submit_rx(skb_dma); > } > > -static void bam_dmux_cmd_data(struct bam_dmux_skb_dma *skb_dma) > +static void bam_dmux_cmd_data(struct bam_dmux_skb_dma *skb_dma, > + unsigned int rx_len) > { > struct bam_dmux *dmux = skb_dma->dmux; > struct sk_buff *skb = skb_dma->skb; > struct bam_dmux_hdr *hdr = (struct bam_dmux_hdr *)skb->data; > struct net_device *netdev = dmux->netdevs[hdr->ch]; > + unsigned int avail = rx_len - sizeof(*hdr); [ ... ] > - if (hdr->len > BAM_DMUX_MAX_DATA_SIZE) { > - dev_err(dmux->dev, "Data larger than buffer? (%u > %u)\n", > - hdr->len, (u16)BAM_DMUX_MAX_DATA_SIZE); > + if (hdr->len > avail) { > + dev_err(dmux->dev, "Data larger than received? (%u > %u)\n", > + hdr->len, avail); > return; > } [Severity: Low] This issue is pre-existing and was not introduced by this patch. Now that this check is being changed, though, what happens when hdr->len is 0? The check passes because 0 > avail is false. The rest of bam_dmux_cmd_data() then does: skb_pull(skb, sizeof(*hdr)); skb_trim(skb, hdr->len); skb->dev = netdev; /* Only Raw-IP/QMAP is supported by this driver */ switch (skb->data[0] & 0xf0) { After skb_trim(skb, 0), skb->len is 0. So skb->data[0] is a byte that was not received in this transfer. It is either stale data from a recycled RX buffer or uninitialised memory from __netdev_alloc_skb(). The zero-length skb is then passed to netif_receive_skb(). On the baseline the modem could already send len 0 directly. This patch adds a second route to the same state. A 0xffff DATA frame whose transfer is exactly sizeof(struct bam_dmux_hdr) bytes passes the new check in bam_dmux_rx_callback(), which only rejects rx_len < sizeof(*hdr). The rewrite then computes hdr->len = 0. Downstream consumers appear to drop such packets: rmnet_map_validate_packet_len() rejects short skbs, and ip_rcv()/ipv6_rcv() fail pskb_may_pull(). The effect is therefore limited to reading one stale byte, which KMSAN could flag. Would it make sense to reject hdr->len == 0 here as well? [ ... ] > @@ -574,15 +578,29 @@ static void bam_dmux_cmd_close(struct bam_dmux *dmux, struct bam_dmux_hdr *hdr) > netif_device_detach(netdev); > } > > -static void bam_dmux_rx_callback(void *data) > +static void bam_dmux_rx_callback(void *data, > + const struct dmaengine_result *result) > { > struct bam_dmux_skb_dma *skb_dma = data; > struct bam_dmux *dmux = skb_dma->dmux; > struct sk_buff *skb = skb_dma->skb; > struct bam_dmux_hdr *hdr = (struct bam_dmux_hdr *)skb->data; > + unsigned int rx_len; > > bam_dmux_skb_dma_unmap(skb_dma, DMA_FROM_DEVICE); > > + if (result->result != DMA_TRANS_NOERROR || result->residue > skb->len) { > + dev_err(dmux->dev, "RX DMA failed: %d (residue %u)\n", > + result->result, result->residue); > + goto out; > + } > + > + rx_len = skb->len - result->residue; [Severity: Low] This calculation is only correct if bam_dma fills in residue. That comes from the earlier patch in the series, "dmaengine: qcom: bam_dma: report residue for completed RX transfers", which adds bam_update_rx_result(). Without that patch, dmaengine_desc_callback_invoke() passes its dummy result to the callback: struct dmaengine_result dummy_result = { .result = DMA_TRANS_NOERROR, .residue = 0 }; Every RX buffer would then look like a full 2048-byte transfer. A 0xffff DATA frame would be delivered as 2040 bytes, including bytes the modem never wrote in that transfer. The client has no way to tell that the provider did not report a residue. Within the series the order is correct. 0xffff frames are also only expected after the QMAP-enable patch, so a Fixes: tag does not seem needed. Could the commit message state the dependency on the bam_dma patch, so the dmaengine and net patches land together or in the right order? > + if (rx_len < sizeof(*hdr)) { > + dev_err(dmux->dev, "RX shorter than header: %u\n", rx_len); > + goto out; > + } > + > if (hdr->magic != BAM_DMUX_HDR_MAGIC) { > dev_err(dmux->dev, "Invalid magic in header: %#x\n", hdr->magic); > goto out; > @@ -593,9 +611,13 @@ static void bam_dmux_rx_callback(void *data) > goto out; > } > > + /* The remote side may leave it to us to use the DMA transfer size */ > + if (hdr->cmd == BAM_DMUX_CMD_DATA && hdr->len == BAM_DMUX_LEN_FROM_DMA) > + hdr->len = rx_len - sizeof(*hdr); [Severity: Low] Should hdr->pad be accounted for here? The driver's own TX path in bam_dmux_tx_prepare_skb() defines the wire format as header + payload + pad. There, hdr->len excludes the padding: hdr->pad = pad; hdr->ch = bndev->ch; hdr->len = skb->len - sizeof(*hdr); if (pad) skb_put_zero(skb, pad); If the modem sets a non-zero hdr->pad on 0xffff frames, the pad bytes end up in the payload. bam_dmux_cmd_data() keeps them through skb_trim(skb, hdr->len), so skb->len can be up to 4 bytes too long when it reaches netif_receive_skb(). The visible impact looks small. rmnet_map_validate_packet_len() stops cleanly on short trailing data, and ip_rcv()/ipv6_rcv() trim to the IP total length. It is also not clear from the tree whether the firmware sets pad in 0xffff mode. If pad is subtracted, hdr->pad comes from the remote side. It would need to be checked against rx_len - sizeof(*hdr) to avoid an unsigned underflow. > switch (hdr->cmd) { > case BAM_DMUX_CMD_DATA: > - bam_dmux_cmd_data(skb_dma); > + bam_dmux_cmd_data(skb_dma, rx_len); > break; [ ... ] -- Sashiko AI review ยท https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261203-qcom-bam-dmux-qmap-v1-0-abc2e80a03af%40oss.qualcomm.com