[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen master] tools/libs/call: linux: touch newly allocated pages after madvise lockdown
commit b0074ce6a10fd7d6734c4bbb6d6e04910db92152 Author: Ian Campbell <ian.campbell@xxxxxxxxxx> AuthorDate: Mon Dec 14 16:46:26 2015 +0000 Commit: Ian Campbell <ian.campbell@xxxxxxxxxx> CommitDate: Fri Jan 22 12:24:21 2016 +0000 tools/libs/call: linux: touch newly allocated pages after madvise lockdown This avoids a potential issue with a fork after allocation but before madvise. Signed-off-by: Ian Campbell <ian.campbell@xxxxxxxxxx> Acked-by: Wei Liu <wei.liu2@xxxxxxxxxx> --- tools/libs/call/linux.c | 14 +++++++++++++- 1 files changed, 13 insertions(+), 1 deletions(-) diff --git a/tools/libs/call/linux.c b/tools/libs/call/linux.c index 3641e41..651f380 100644 --- a/tools/libs/call/linux.c +++ b/tools/libs/call/linux.c @@ -88,7 +88,7 @@ void *osdep_alloc_pages(xencall_handle *xcall, size_t npages) { size_t size = npages * PAGE_SIZE; void *p; - int rc, saved_errno; + int rc, i, saved_errno; /* Address returned by mmap is page aligned. */ p = mmap(NULL, size, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_LOCKED, -1, 0); @@ -107,6 +107,18 @@ void *osdep_alloc_pages(xencall_handle *xcall, size_t npages) goto out; } + /* + * Touch each page in turn to force them to be un-CoWed, in case a + * fork happened in another thread at an inopportune moment + * above. The madvise() will prevent any subsequent fork calls from + * causing the same problem. + */ + for ( i = 0; i < npages ; i++ ) + { + char *c = (char *)p + (i*PAGE_SIZE); + *c = 0; + } + return p; out: -- generated by git-patchbot for /home/xen/git/xen.git#master _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxx http://lists.xensource.com/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |