<div dir="ltr"><div>Resent the mail for the former letter contains html text.<br></div><div><br></div><div>Regards,</div><div><br></div><div>Zheng Wang</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Zheng Hacker <<a href="mailto:hackerzheng666@gmail.com">hackerzheng666@gmail.com</a>> 于2022年9月5日周一 12:47写道:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr">Hello everyone,<div><br><div>I'm Zheng Wang. I found a potential double-free bug in drivers/gpu/drm/i915/gvt/gtt.c. I haven't been replied for a long time. So I decided to send it to more relavent supporters and developers to help to solve the problem.</div></div><div><br></div><div>Best regards,</div><div>Zheng Wang.</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">xmzyshypnc <<a href="mailto:1002992920@qq.com">1002992920@qq.com</a>> 于2022年9月4日周日 20:32写道:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">There is a double-free security bug in split_2MB_gtt_entry.<br>
<br>
Here is a calling chain : ppgtt_populate_spt->ppgtt_populate_shadow_entry->split_2MB_gtt_entry. If intel_gvt_dma_map_guest_page failed, it will call ppgtt_invalidate_spt, which will finally call ppgtt_free_spt and kfree(spt). But the caller does not notice that, and it will call ppgtt_free_spt again in error path.<br>
<br>
Fix this by returning the result of ppgtt_invalidate_spt to split_2MB_gtt_entry.<br>
<br>
Signed-off-by: Zheng Wang <<a href="mailto:1002992920@qq.com">1002992920@qq.com</a>><br>
---<br>
drivers/gpu/drm/i915/gvt/gtt.c | 2 +-<br>
1 file changed, 1 insertion(+), 1 deletion(-)<br>
<br>
diff --git a/drivers/gpu/drm/i915/gvt/gtt.c b/drivers/gpu/drm/i915/gvt/gtt.c<br>
index ce0eb03709c3..9f14fded8c0c 100644<br>
--- a/drivers/gpu/drm/i915/gvt/gtt.c<br>
+++ b/drivers/gpu/drm/i915/gvt/gtt.c<br>
@@ -1215,7 +1215,7 @@ static int split_2MB_gtt_entry(struct intel_vgpu *vgpu,<br>
ret = intel_gvt_dma_map_guest_page(vgpu, start_gfn + sub_index,<br>
PAGE_SIZE, &dma_addr);<br>
if (ret) {<br>
- ppgtt_invalidate_spt(spt);<br>
+ ret = ppgtt_invalidate_spt(spt);<br>
return ret;<br>
}<br>
sub_se.val64 = se->val64;<br>
-- <br>
2.25.1<br>
<br>
</blockquote></div></div>
</blockquote></div></div>