Thank you for your contribution! Sashiko AI review found no new issues
in this patch, but noticed 1 related pre-existing issue it does not
introduce:
- [Critical] misc: fastrpc: use-after-free due to dangling dma_mask in
  fastrpc_rpmsg_probe() [1]
--

commit 45628114d33912de02c404c2680ce4e7336df5df
Author: Anandu Krishnan E <[email protected]>

misc: fastrpc: add HPASS domain

This commit adds HPASS_DOMAIN_ID for the High Performance Audio Subsystem
(HPASS), maps the "hpass" devicetree label to it, and enables reserved
remote heap memory and device registration for the domain.

> diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c
> index 9e760f68bcaf2..c515097c3d3ba 100644
> --- a/drivers/misc/fastrpc.c
> +++ b/drivers/misc/fastrpc.c

[ ... ]

> @@ -2761,6 +2765,7 @@ static int fastrpc_rpmsg_probe(struct rpmsg_device 
> *rpdev)
>       case ADSP_DOMAIN_ID:
>       case MDSP_DOMAIN_ID:
>       case SDSP_DOMAIN_ID:
> +     case HPASS_DOMAIN_ID:
>               /* Unsigned PD offloading is only supported on CDSP and GDSP */
>               data->unsigned_support = false;
>               err = fastrpc_device_register(rdev, data, secure_dsp, domain);

[Severity: Critical]
This problem wasn't introduced by this patch, but can fastrpc_rpmsg_probe()
leave a dangling rdev->dma_mask pointer [1]?

drivers/misc/fastrpc.c:fastrpc_rpmsg_probe() {
    ...
        rdev->dma_mask = &data->dma_mask;
        dma_set_mask_and_coherent(rdev, DMA_BIT_MASK(32));
    ...
        err = fastrpc_cb_devices_create(rpdev);
        if (err)
                goto err_deregister_fdev;
    ...
err_free_data:
        kfree(data);
        return err;
}

fastrpc_rpmsg_probe() points rdev->dma_mask at data->dma_mask inside the
heap-allocated fastrpc_channel_ctx.  If fastrpc_cb_devices_create() fails
or the driver is later unbound via fastrpc_rpmsg_remove() ->
fastrpc_channel_ctx_put(), data is freed while rpdev->dev lives on with
rdev->dma_mask still pointing into the freed object, causing a
use-after-free on any subsequent probe or DMA API access on the device.

[1] https://sashiko.dev/#/bug/linux-3d83ea49-16e6-4a33-9f74-77e4b19335b8

-- 
Sashiko AI review ยท 
https://sashiko.dev/#/patchset/20261125-fastrpc-hpass-support-v1-0-cb1d46b29...@oss.qualcomm.com?part=2

Reply via email to