dmaengine: virt-dma: Fix access after free in vcna_complete()
PATCH 1/1 dmaengine: virt-dma: Fix access after free in vcna_complete()
vchan_vdesc_fini() is freeing up 'vd' so the access to vd->tx_result is via already freed up memory.
Move the vchan_vdesc_fini() after invoking the callback to avoid this.
--- drivers/dma/virt-dma.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/dma/virt-dma.c +1 -2
@@ -104,9 +104,8 @@ static void vchan_complete(unsigned long arg)dmaengine_desc_get_callback (&vd->tx, &cb);list_del (&vd->node); -vchan_vdesc_fini (vd); -dmaengine_desc_callback_invoke (&cb, &vd->tx_result); +vchan_vdesc_fini (vd); } }
Signature · 4 lines
Peter Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
Quoted 7 lines · Peter Ujfalusi
[External]
vchan_vdesc_fini()is freeing up 'vd' so the access tovd->tx_resultis via already freed up memory.Move the
vchan_vdesc_fini()after invoking the callback to avoid this.
Quoted 22 lines
Fixes 09d5b702b0f97 ("dmaengine: virt-dma: store result on dmadescriptor")
Signed-off-by Peter Ujfalusi <[email protected]>--- drivers/dma/virt-dma.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)drivers/dma/virt-dma.c +1
-2@@ -104,9 +104,8 @@ static void vchan_complete(unsigned long arg)dmaengine_desc_get_callback (&vd->tx, &cb);list_del (&vd->node); -vchan_vdesc_fini (vd); -dmaengine_desc_callback_invoke (&cb, &vd->tx_result); +vchan_vdesc_fini (vd); } }
Quoted 7 lines · Peter Ujfalusi
[External]
vchan_vdesc_fini()is freeing up 'vd' so the access tovd->tx_resultis via already freed up memory.Move the
vchan_vdesc_fini()after invoking the callback to avoid this.
Apologies for seeing this too late: typo in title vcna_complete() -> vchan_complete()
Quoted 22 lines
Fixes 09d5b702b0f97 ("dmaengine: virt-dma: store result on dmadescriptor")
Signed-off-by Peter Ujfalusi <[email protected]>--- drivers/dma/virt-dma.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)drivers/dma/virt-dma.c +1
-2@@ -104,9 +104,8 @@ static void vchan_complete(unsigned long arg)dmaengine_desc_get_callback (&vd->tx, &cb);list_del (&vd->node); -vchan_vdesc_fini (vd); -dmaengine_desc_callback_invoke (&cb, &vd->tx_result); +vchan_vdesc_fini (vd); } }
Quoted 11 lines · Alexandru
Quoted 7 lines · Peter Ujfalusi
[External]
vchan_vdesc_fini()is freeing up 'vd' so the access tovd->tx_resultis via already freed up memory.Move the
vchan_vdesc_fini()after invoking the callback to avoid this.Apologies for seeing this too late: typo in title
vcna_complete()->vchan_complete()
Yep, I also noticed after sending it, I hope Vinod is kind enough and fix it up when applying ;)
- Péter
Quoted 14 lines
Quoted 14 lines
Fixes 09d5b702b0f97 ("dmaengine: virt-dma: store result on dmadescriptor")
Signed-off-by Peter Ujfalusi <[email protected]>--- drivers/dma/virt-dma.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)drivers/dma/virt-dma.c +0
-0@@ -104,9 +104,8 @@ static void vchan_complete(unsigned long arg)dmaengine_desc_get_callback (&vd->tx, &cb);
Quoted 8 lines
drivers/dma/virt-dma.c static void vchan_complete(unsigned long arg) · line 111
Quoted 8 lines
drivers/dma/virt-dma.c +1
-2list_del (&vd->node); -vchan_vdesc_fini (vd); -dmaengine_desc_callback_invoke (&cb, &vd->tx_result); +vchan_vdesc_fini (vd); } }
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
Vinod Koul
maintainerQuoted 9 lines · Peter Ujfalusi
Quoted 6 lines · Alexandru
Quoted 5 lines · Peter Ujfalusi
[External]
vchan_vdesc_fini()is freeing up 'vd' so the access tovd->tx_resultis via already freed up memory.
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
Move the
vchan_vdesc_fini()after invoking the callback to avoid this.Apologies for seeing this too late: typo in title
vcna_complete()->vchan_complete()Yep, I also noticed after sending it, I hope Vinod is kind enough and fix it up when applying ;)
In case it wasnt clear, yeah trivial changes while applying are no hassle :)
Signature · 1 line
~Vinod
Quoted 4 lines · Peter Ujfalusi
vchan_vdesc_fini()is freeing up 'vd' so the access tovd->tx_resultis via already freed up memory.Move the
vchan_vdesc_fini()after invoking the callback to avoid this.
Applied, thanks
Signature · 1 line
~Vinod