Article View: linux.kernel.netdev
Article #27043Re: [PATCH net-next 2/3] net: wwan: qcom_bam_dmux: use DMA transfer size for RX packets
From: netdev-bot+sashiko
Date: Fri, 04 Dec 2026 17:06
Date: Fri, 04 Dec 2026 17:06
188 lines
15154 bytes
15154 bytes
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
Technical Details
Message-ID:
<179640396883.3146.15360849304828602379@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!2.eu.feeder.erje.net!feeder.erje.net!feeder1-2.proxad.net!proxad.net!feeder1-1.proxad.net!193.141.40.65.MISMATCH!npeer.as286.net!npeer-ng0.as286.net!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-377507-linux-kernel-netdev=dewy.ruReferences:
<20261203-qcom-bam-dmux-qmap-v1-2-abc2e80a03af@oss.qualcomm.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!2.eu.feeder.erje.net!feeder.erje.net!feeder1-2.proxad.net!proxad.net!feeder1-1.proxad.net!193.141.40.65.MISMATCH!npeer.as286.net!npeer-ng0.as286.net!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-377507-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net-next 2/3] net: wwan: qcom_bam_dmux: use DMA transfer size for RX packets Date: Fri, 04 Dec 2026 17:06:08 +0000 Organization: Usenet Network Message-ID: <179640396883.3146.15360849304828602379@kernel.org> References: <20261203-qcom-bam-dmux-qmap-v1-2-abc2e80a03af@oss.qualcomm.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="2814033"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:Qnd/W93yV4z15O7A/SbPchuZUxE= sha256:c/6LCohtKDMT6feqJ4TPxzm21zb5Z/W/4xFVbai8CUI= sha1:82zLSTHJ3UBrZli+DVWqnFkCZNw= sha256:gurE/3e9Rb5LDNWgg3iEGRroRGesGOUCaENszI9aPX4= 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 4A670117C7E; Fri, 4 Dec 2026 20:06:33 +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 4sfA7-32pdYI; Fri, 4 Dec 2026 20:06:30 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-377507-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 99E1F117C7A; Fri, 4 Dec 2026 20:06:19 +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 5F54142A1C; Fri, 4 Dec 2026 17:06:12 +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=1796403971; b=xIsHszOSw1ZqWDS9x+GaVORtUoydyA2AiPBxihNi8R/MJhjC/Qeama+FeK1J2HfPPaSd WzI7iQjWih3KFPGYaS2Lbb5DMaInpXaFSfBrYH4a5lnvCakC8FxgFpwflyG4I0fOtP/OB tQ2D0kxuxmycrqQ7ThxHuzXtY0kF4rfJHEX0B/ZKpon3Jnz30OQIs2YB5wJnS3Rk1XMDe MZow3V9jtd6SDS6uJ+tmC/5fuFfPWReOUl6B8Oky7St8Dk4VNb5jMLsKCMDpbsvWcYspr sQu3wFK+m43Q8PN0Tou6gjGBsCLTZUDuOnj5ll9on3fxz0BHnf6ZzlVgeyCckYMekFA== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796403971; 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=JxBP8lyezxfXqN5G22GSjDYoWb/zm61wExer2UsqfSA=; b=jMUSpifZzvGBpNvEl8EYhdgM0Y6JcOjAFUI6+wHOhzUBGPLk/BakqxI66J48Y4ZkNEau tEI+HwH9j6+PRckc9FWeknTa8xwPVged6i598EUniWsWQusCSWGeoEVCOMTH/m0mQv/wW Nw82jC50Zo2/QlgSsJioirCqLaciCwK9E6ZLGtsaSBuhZkLWtdXyImR5IfFACGKp2GZAP 1ykIL4cWodEMcbJVQbi9Q7mfMge0kqh0PA/NZE2GxOdSjWK2AKeK3c4Rr42whhWWWvM86 Me+JThVdxlAZtz1VIPMp9RfvSxAAcLYZcblne7FkHvy5vV0wXtS6cK5HaGHdzTEXx7w== 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=iWn0252s; 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 4FC1F606A33A; Fri, 4 Dec 2026 17:06:11 +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=iWn0252s 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=1796403970; b=ZU81pdp0zLBNrwnPHaftpCTQS9Rr0NOqMYs7ePkb2TSFDKi9tHZxZI+9ytACVeEVSDsK i5OntW/tpcYTGISq14fZC8vKdoTYVnATlR3XhuGfWbYdeoY90/8YOD0xUtzAJ7Gcd8EXc Xx/36uxhEirJdNRZKTH8feSmjBNx7n8G6gBEboJ3B2ASbH0Zwjgi8QGbn3F1VYtaLg/TB WDZ6JhsDNJ4wHYnkaWO0y5N7esTcHKjdhL+paOOYGzvFW/Fq38tpJYhG8xFiZlMTAMkQZ eGDeW5XbnaRmBnxuk+JH2c6pvSZUO61ZqEEOjI5CoUQiPoI6FTX0Jc5iY5k4AI1ueDQ== X-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== 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=iWn0252s; 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 718B8606A680; Fri, 4 Dec 2026 17:06:10 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3FD091F0093B; Fri, 4 Dec 2026 17:06:09 +0000 (UTC) X-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== X-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 X-In-Reply-To: <20261203-qcom-bam-dmux-qmap-v1-2-abc2e80a03af@oss.qualcomm.com> X-sashiko-severity: Low 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