misc: mic: fix a DMA pool free failure

In _scif_prog_signal(), a DMA pool is allocated if the MIC Coprocessor is
not X100, i.e., the boolean variable 'x100' is false. This DMA pool will be
freed eventually through the callback function scif_prog_signal_cb() with
the parameter of 'status', which actually points to the start of DMA pool.
Specifically, in scif_prog_signal_cb(), the 'ep' field and the
'src_dma_addr' field of 'status' are used to free the DMA pool by invoking
dma_pool_free(). Given that 'status' points to the start address of the DMA
pool, both 'status->ep' and 'status->src_dma_addr' are in the DMA pool. And
so, the device has the permission to access them. Even worse, a malicious
device can modify them. As a result, dma_pool_free() will not succeed.

To avoid the above issue, this patch introduces a new data structure, i.e.,
scif_cb_arg, to store the arguments required by the call back function. A
variable 'cb_arg' is allocated in _scif_prog_signal() to pass the
arguments. 'cb_arg' will be freed after dma_pool_free() in
scif_prog_signal_cb().

Signed-off-by: Wenwen Wang <wang6495@umn.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Wenwen Wang
2018-12-04 09:16:41 -06:00
committed by Greg Kroah-Hartman
parent b9d93594c7
commit 15b3048aee
2 changed files with 30 additions and 5 deletions

View File

@@ -205,6 +205,19 @@ struct scif_status {
struct scif_endpt *ep;
};
/*
* struct scif_cb_arg - Stores the argument of the callback func
*
* @src_dma_addr: Source buffer DMA address
* @status: DMA status
* @ep: SCIF endpoint
*/
struct scif_cb_arg {
dma_addr_t src_dma_addr;
struct scif_status *status;
struct scif_endpt *ep;
};
/*
* struct scif_window - Registration Window for Self and Remote
*