From: sashiko-bot@kernel.org
To: "Praveen Talari" <praveen.talari@oss.qualcomm.com>
Cc: linux-serial@vger.kernel.org
Subject: Re: [PATCH v2] serial: qcom-geni: Drop unsafe rx_buf realloc from setup_fifos()
Date: Mon, 24 Aug 2026 14:44:12 +0000 [thread overview]
Message-ID: <20260824144412.75F681F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260824-drop-unsafe-rx-buf-realloc-from-setup-fifos-v2-1-9a1c8f711e98@oss.qualcomm.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
Pre-existing issues:
- [High] Preexisting invalid DMA unmap in probe error path.
- [High] Missing bounds check on hardware-reported RX length leads to out-of-bounds read and kernel memory leak.
--
--- Patch [1]: [PATCH v2] serial: qcom-geni: Drop unsafe rx_buf realloc from setup_fifos() ---
commit 03f147201f8b1d9aa9d2d010a8177ebcd9b90c6e
Author: Praveen Talari <praveen.talari@oss.qualcomm.com>
serial: qcom-geni: Drop unsafe rx_buf realloc from setup_fifos()
The RX buffer is allocated once during probe using a fixed DMA_RX_BUF_SIZE
and is DMA-mapped for the lifetime of the port. However, setup_fifos()
attempts to reallocate rx_buf whenever the reported RX FIFO depth changes.
This commit drops this unsafe reallocation.
Link: https://patch.msgid.link/20260824-drop-unsafe-rx-buf-realloc-from-setup-fifos-v1-1-52d231c840e1@oss.qualcomm.com
> diff --git a/drivers/tty/serial/qcom_geni_serial.c b/drivers/tty/serial/qcom_geni_serial.c
> index 3633723acef8d..75b2e0b77d059 100644
> --- a/drivers/tty/serial/qcom_geni_serial.c
> +++ b/drivers/tty/serial/qcom_geni_serial.c
[ ... ]
drivers/tty/serial/qcom_geni_serial.c:qcom_geni_serial_probe() {
...
port->rx_dma_addr = dma_map_single(pdev->dev.parent, port->rx_buf,
DMA_RX_BUF_SIZE, DMA_FROM_DEVICE);
if (dma_mapping_error(pdev->dev.parent, port->rx_dma_addr)) {
ret = -EIO;
dev_err(&pdev->dev, "Failed to map RX DMA buffer: %d\n", ret);
goto error;
}
...
error:
if (port->rx_dma_addr) {
dma_unmap_single(pdev->dev.parent, port->rx_dma_addr,
DMA_RX_BUF_SIZE, DMA_FROM_DEVICE);
port->rx_dma_addr = 0;
}
...
}
[Severity: High]
This is a pre-existing issue, but does this error path incorrectly unmap an
invalid DMA address?
If dma_map_single() fails, it returns a mapping error (typically ~0ULL).
The code leaves this error value in port->rx_dma_addr and jumps to the error
label. Because port->rx_dma_addr evaluates to true, the cleanup block calls
dma_unmap_single() on this invalid address.
On systems with IOMMU or DMA debugging enabled, could this cause kernel warnings
or memory corruption when the IOMMU translation tables are accessed with an
invalid IOVA?
drivers/tty/serial/qcom_geni_serial.c:qcom_geni_serial_handle_rx_dma() {
...
rx_in = readl(uport->membase + SE_DMA_RX_LEN_IN);
if (!rx_in)
dev_warn_ratelimited(uport->dev, "serial engine reports 0 RX bytes in!\n");
else if (!drop) {
trace_geni_serial_rx_data(uport->dev, port->rx_buf, rx_in);
handle_rx_uart(uport, rx_in);
}
...
}
[Severity: High]
This is a pre-existing issue, but is rx_in used without being bounded by
DMA_RX_BUF_SIZE?
The length is read directly from the SE_DMA_RX_LEN_IN register and passed to
handle_rx_uart() without verifying that it does not exceed the size of the DMA
buffer.
If the hardware device reports an incorrect length, could this lead to an
out-of-bounds read when copying from port->rx_buf and leak adjacent kernel
memory?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260824-drop-unsafe-rx-buf-realloc-from-setup-fifos-v2-1-9a1c8f711e98@oss.qualcomm.com?part=1
prev parent reply other threads:[~2026-08-24 14:44 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-24 14:30 [PATCH v2] serial: qcom-geni: Drop unsafe rx_buf realloc from setup_fifos() Praveen Talari
2026-08-24 14:44 ` sashiko-bot [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260824144412.75F681F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-serial@vger.kernel.org \
--cc=praveen.talari@oss.qualcomm.com \
--cc=sashiko-reviews@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox