[CRIU] [crtools-bot for Kinsbursky Stanislav ] restorer: Don't close SYSV IPC vma fd

Cyrill Gorcunov gorcunov at openvz.org
Fri Feb 17 06:55:32 EST 2012


The commit is pushed to "master" and will appear on git://github.com/cyrillos/crtools.git
------>
commit 389bd830f16203b7ac23b6eaf933b8a83b3ab1fd
Author: Kinsbursky Stanislav <skinsbursky at openvz.org>
Date:   Fri Feb 17 15:51:51 2012 +0400

    restorer: Don't close SYSV IPC vma fd
    
    It's not a fd to open and map, but SYSV IPC id instead.
    So don't close it - this may lead to unpredictable results
    (in case of SYSV IPC id will match fd, opened by processes).
    
    Signed-off-by: Stanislav Kinsbursky <skinsbursky at openvz.org>
    Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
 restorer.c |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/restorer.c b/restorer.c
index 78c5e54..d62d144 100644
--- a/restorer.c
+++ b/restorer.c
@@ -291,6 +291,7 @@ static u64 restore_mapping(const struct vma_entry *vma_entry)
 {
 	int prot	= vma_entry->prot;
 	int flags	= vma_entry->flags | MAP_FIXED;
+	u64 addr;
 
 	if (vma_entry_is(vma_entry, VMA_AREA_SYSVIPC))
 		return sys_shmat(vma_entry->fd, (void *)vma_entry->start,
@@ -316,11 +317,16 @@ static u64 restore_mapping(const struct vma_entry *vma_entry)
 	 * writable since we're going to restore page
 	 * contents.
 	 */
-	return sys_mmap((void *)vma_entry->start,
+	addr = sys_mmap((void *)vma_entry->start,
 			vma_entry_len(vma_entry),
 			prot, flags,
 			vma_entry->fd,
 			vma_entry->pgoff);
+
+	if (vma_entry->fd != -1)
+		sys_close(vma_entry->fd);
+
+	return addr;
 }
 
 /*


More information about the CRIU mailing list