Linux RDMA and InfiniBand development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Xin Tian" <tianx@yunsilicon.com>
Cc: linux-rdma@vger.kernel.org
Subject: Re: [PATCH 04/15] yunsilicon: add event queues, interrupts and the
Date: Tue, 13 Oct 2026 11:46:07 +0000	[thread overview]
Message-ID: <sashiko-outbox-169639@kernel.org> (raw)
In-Reply-To: <20261012114359.2471317-5-tianx@yunsilicon.com>

Thank you for your contribution! Sashiko AI review found 8 potential issue(s) to consider:
- [High] net: xsc: bitwise XOR logic error in next_eqe_sw() halts event queue processing
- [High] net: xsc: skipping teardown when firmware is offline causes Use-After-Free and resource leaks
- [High] net: xsc: spoofing device->numa_node during DMA allocation causes data races
- [High] yunsilicon: vmap() on dma_alloc_coherent() memory creates illegal cache aliases
- [Medium] net: xsc: multiple memory leaks and incorrect affinity setup in cpumask management
- [Medium] net: xsc: vunmap skipped on 32-bit architectures causes vmalloc memory leak
- [Medium] net: xsc: data race on link_event_handler can lead to NULL pointer dereference
- [Medium] net: xsc: xsc_core_vector2eqn leaves irqn uninitialized when MSI-X is disabled
--

Make it readable and polite without reproducing the patch diff context.

[Severity: High]
File: ..., Function: ..., Line: ...
Your question here...

Do not use '> diff' or any direct source recitation. Respond only with the prose descriptions.commit a872f21fb08a814fac5b1a6b91049b643f0a1ed7
Author: Xin Tian <tianx@yunsilicon.com>

yunsilicon: add event queues, interrupts and the auxiliary bus

This commit adds event queues, MSI-X vector handling, and auxiliary bus
glue for the yunsilicon driver. It sets up the PCI core to request vectors,
create completion queues, and publish auxiliary devices for the ethernet and
RDMA drivers.

[Severity: High]
In drivers/net/ethernet/yunsilicon/xsc/pci/eq.c, within the next_eqe_sw()
function, the logic for advancing the consumer index performs a bitwise XOR
against !!(eq->cons_index & eq->nent) with (eqe->owner_data & XSC_EQE_OWNER).
Because XSC_EQE_OWNER is BIT(7) (128), when the hardware sets the owner bit,
this evaluates to 128 ^ 1, which equals 129. Since 129 is non-zero, it returns
NULL instead of the event queue entry. Will this cause the event queue to halt
completely after exactly one cycle? Would it be better to normalize the left
side to a boolean first?

[Severity: High]
In drivers/net/ethernet/yunsilicon/xsc/pci/eq.c, within xsc_destroy_unmap_eq(),
and in drivers/net/ethernet/yunsilicon/xsc/pci/pci_irq.c within both
xsc_free_irq_vectors() and xsc_free_irq(), the functions check if the firmware
is available and return early if it is not. By returning early, critical
cleanup operations like free_irq(), pci_free_irq_vectors(), and
xsc_buf_free() are skipped. Does skipping free_irq() leave the interrupt
handler active to dereference the subsequently freed `eq` object, causing a
Use-After-Free? Will this also leak PCI MSI-X allocations?

[Severity: Medium]
In drivers/net/ethernet/yunsilicon/xsc/pci/pci_irq.c, the function
set_comp_irq_affinity_hint() is called in a loop over the number of vectors.
Inside this loop, it unconditionally allocates xdev->xps_cpumask using
zalloc_cpumask_var(). Does this repeatedly overwrite the pointer and
permanently leak memory on every iteration when CONFIG_CPUMASK_OFFSTACK=y?
Additionally, if the allocation fails, it returns without freeing eq->mask.
Also, when setting the affinity hint, the code passes the newly allocated
and empty eq->mask to irq_set_affinity_hint() instead of the populated
xdev->xps_cpumask. Finally, if xsc_cmd_enable_msix() fails in
xsc_irq_eq_create(), the error path jumps to err_free_irq_evnt, which skips
clear_comp_irq_affinity_hints(). Will this leak all successfully allocated
cpumasks?

[Severity: Medium]
In drivers/net/ethernet/yunsilicon/xsc/pci/alloc.c, within xsc_buf_free(),
there is a check that only calls vunmap() if BITS_PER_LONG == 64. However, in
xsc_buf_alloc(), the memory is unconditionally mapped using vmap() when the
requested size exceeds the direct mapping threshold. Will guarding the vunmap()
with an architecture check permanently leak the mapping on 32-bit platforms
every time a multi-page buffer is freed?

[Severity: Medium]
In drivers/net/ethernet/yunsilicon/xsc/pci/pci_irq.c, within xsc_event_work(),
the link event handler is checked for NULL before being called. However,
xsc_irq_event_unregister() can concurrently set xdev->link_event_handler to
NULL. Can the compiler issue two separate memory loads for the check and the
call, leading to a NULL pointer dereference if the pointer is cleared between
the two operations? Should this use READ_ONCE() to load the pointer into a
local variable first?

[Severity: High]
In drivers/net/ethernet/yunsilicon/xsc/pci/alloc.c, the function
xsc_dma_zalloc_coherent_node() calls set_dev_node() to temporarily modify
the global device->numa_node field in order to force node-local DMA
allocations. While this is protected locally by dev_res->alloc_mutex, other
subsystems might call dev_to_node() concurrently. Can this data race cause
other parallel threads to read the spoofed value and allocate memory on the
wrong physical NUMA node?

[Severity: Medium]
In drivers/net/ethernet/yunsilicon/xsc/pci/pci_irq.c, the function
xsc_core_vector2eqn() returns 0 (success) early if xdev->caps.msix_enable is
false, without initializing the *irqn parameter. The caller, xsc_vector2eqn(),
passes this success along, which could lead to undefined behavior when it
uses the uninitialized local variable. Should *irqn be initialized before
returning on this path?

[Severity: High]
In drivers/net/ethernet/yunsilicon/xsc/pci/alloc.c, within xsc_buf_alloc(),
memory allocated via dma_alloc_coherent() is converted to struct page pointers
using virt_to_page() or vmalloc_to_page(), and then remapped contiguously
using vmap(..., PAGE_KERNEL). Because DMA coherent memory is not guaranteed
to be backed by standard linear map pages, and applying PAGE_KERNEL to
potentially uncached or write-combined memory creates conflicting cache
aliases, is this architecturally illegal? Does this bypass DMA API safety
constraints and risk memory corruption or kernel panics?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261012114352.2471317-1-tianx@yunsilicon.com?part=4

  reply	other threads:[~2026-10-13 11:46 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-12 11:44 [PATCH 00/15] Yunsilicon ethernet and RDMA drivers Xin Tian
2026-10-12 11:43 ` [PATCH 01/15] yunsilicon: add PCI core driver skeleton Xin Tian
2026-10-13 11:46   ` sashiko-bot
2026-10-12 11:43 ` [PATCH 02/15] yunsilicon: add the register HAL Xin Tian
2026-10-12 15:21   ` Andrew Lunn
2026-10-13 11:46   ` sashiko-bot
2026-10-12 11:43 ` [PATCH 03/15] yunsilicon: add the command queue Xin Tian
2026-10-13  3:11   ` Junxian Huang
2026-10-13 14:31     ` Leon Romanovsky
2026-10-13 11:46   ` sashiko-bot
2026-10-12 11:44 ` [PATCH 04/15] yunsilicon: add event queues, interrupts and the Xin Tian
2026-10-13 11:46   ` sashiko-bot [this message]
2026-10-12 11:44 ` [PATCH 05/15] yunsilicon: add the CQ and QP resource pools Xin Tian
2026-10-13 11:46   ` sashiko-bot
2026-10-12 11:44 ` [PATCH 06/15] yunsilicon: add ethernet netdev registration Xin Tian
2026-10-13 11:46   ` sashiko-bot
2026-10-12 11:44 ` [PATCH 07/15] yunsilicon: add ethernet TX path Xin Tian
2026-10-13 11:46   ` sashiko-bot
2026-10-12 11:44 ` [PATCH 08/15] yunsilicon: add ethernet RX path and statistics Xin Tian
2026-10-13 11:46   ` sashiko-bot
2026-10-12 11:44 ` [PATCH 09/15] yunsilicon: add RDMA device support Xin Tian
2026-10-13  6:17   ` Junxian Huang
2026-10-13 11:46   ` sashiko-bot
2026-10-12 11:44 ` [PATCH 10/15] yunsilicon: add RDMA PD/MR Xin Tian
2026-10-13 11:46   ` sashiko-bot
2026-10-12 11:44 ` [PATCH 11/15] yunsilicon: add RDMA CQ/SRQ/AH Xin Tian
2026-10-13 11:46   ` sashiko-bot
2026-10-12 11:44 ` [PATCH 12/15] yunsilicon: add RDMA QP verbs Xin Tian
2026-10-13 11:46   ` sashiko-bot
2026-10-12 11:44 ` [PATCH 13/15] yunsilicon: add the RDMA send path Xin Tian
2026-10-13 11:46   ` sashiko-bot
2026-10-12 11:44 ` [PATCH 14/15] yunsilicon: add RDMA counters and sysfs Xin Tian
2026-10-13 11:46   ` sashiko-bot
2026-10-12 11:44 ` [PATCH 15/15] MAINTAINERS: add the Yunsilicon XSC drivers Xin Tian
2026-10-13 14:34 ` [PATCH 00/15] Yunsilicon ethernet and RDMA drivers Leon Romanovsky

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=sashiko-outbox-169639@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=tianx@yunsilicon.com \
    /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