Skip to content

Commit 2fa67a4

Browse files
yonghuahwenlingz
authored andcommitted
HV: clear memory region used by UOS before it exit
this patch fixes such an information leaking issue: in case that after a UOS is destroyed, its memroy will be reclaimed and maybe re-allocated for a new UOS, then the previous UOS sensitive data in memory may be leaked to the new UOS. Tracked-On: #1825 Signed-off-by: Yonghua Huang <yonghua.huang@intel.com> Signed-off-by: Tianhua Sun <tianhuax.s.sun@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
1 parent 8fa1621 commit 2fa67a4

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

devicemodel/core/vmmapi.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,20 @@ vm_setup_memory(struct vmctx *ctx, size_t memsize)
298298
void
299299
vm_unsetup_memory(struct vmctx *ctx)
300300
{
301+
/*
302+
* For security reason, clean the VM's memory region
303+
* to avoid secret information leaking in below case:
304+
* After a UOS is destroyed, the memory will be reclaimed,
305+
* then if the new UOS starts, that memory region may be
306+
* allocated the new UOS, the previous UOS sensitive data
307+
* may be leaked to the new UOS if the memory is not cleared.
308+
*
309+
*/
310+
bzero((void *)ctx->baseaddr, ctx->lowmem);
311+
if (ctx->highmem > 0) {
312+
bzero((void *)(ctx->baseaddr + 4 * GB), ctx->highmem);
313+
}
314+
301315
hugetlb_unsetup_memory(ctx);
302316
}
303317

0 commit comments

Comments
 (0)