lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CABdmKX1PVDy3TtrvNb_pnM89AHzWLBg3itbhp5RFgVt5Q-KQ0A@mail.gmail.com>
Date: Thu, 29 Jan 2026 10:43:53 -0800
From: "T.J. Mercier" <tjmercier@...gle.com>
To: Shanker Donthineni <sdonthineni@...dia.com>
Cc: Marek Szyprowski <m.szyprowski@...sung.com>, Maxime Ripard <mripard@...nel.org>, 
	Robin Murphy <robin.murphy@....com>, Sumit Semwal <sumit.semwal@...aro.org>, iommu@...ts.linux.dev, 
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH] dma: contiguous: Check return value of dma_contiguous_reserve_area()

On Thu, Jan 29, 2026 at 10:14 AM Shanker Donthineni
<sdonthineni@...dia.com> wrote:
>
> Commit 8f1fc1bf1a3d ("dma: contiguous: Reserve default CMA heap")
> introduced a bug where dma_heap_cma_register_heap() is called with
> a NULL pointer when dma_contiguous_reserve_area() fails to reserve
> the CMA area.
>
> When dma_contiguous_reserve_area() fails, dma_contiguous_default_area
> remains NULL (initialized as a global variable), but the code doesn't
> check the return value and proceeds to call dma_heap_cma_register_heap()
> with this NULL pointer.
>
> Later during boot, add_cma_heaps() iterates through the dma_areas[]
> array and attempts to register heaps. When it encounters the NULL
> pointer stored by the earlier call, it crashes in __add_cma_heap()
> -> dma_heap_add() when trying to dereference the NULL CMA pointer.
>
> The crash manifests as:
>   Unable to handle kernel NULL pointer dereference at virtual address
>   0000000000000038
>   ...
>   Call trace:
>    dma_heap_add+0x40/0x2b0
>    __add_cma_heap+0x80/0xe0
>    add_cma_heaps+0x64/0xb0
>    do_one_initcall+0x60/0x318
>    kernel_init_freeable+0x260/0x2f0
>    kernel_init+0x2c/0x168
>    ret_from_fork+0x10/0x20
>
> Fix this by checking the return value of dma_contiguous_reserve_area()
> and only calling dma_heap_cma_register_heap() when the reservation
> succeeds.
>
> Fixes: 8f1fc1bf1a3d ("dma: contiguous: Reserve default CMA heap")
> Signed-off-by: Shanker Donthineni <sdonthineni@...dia.com>

Might be good to add a pr_warn when dma_contiguous_reserve_area fails,
since we won't get the pr_warn for a dma_heap_cma_register_heap
failure when we return early.

Either way:
Reviewed-by: T.J. Mercier <tjmercier@...gle.com>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ