mirror of
https://github.com/checkpoint-restore/criu
synced 2025-08-30 13:58:34 +00:00
PROT_WRITE isn't need for a mapping of a file with MAP_SHARED
A file destriptor is opened for read-only and mmap with PROT_WRITE fails. We don't need PROT_WRITE for this case, because a file contains up to date data. lr-x------ 1 root root 64 Dec 1 19:10 20 -> /usr/lib64/gconv/gconv-modules.cache pos: 0 flags: 0100000 41155 mmap(0x7f2c3d6cf000, 28672, PROT_READ|PROT_WRITE, MAP_SHARED|MAP_FIXED, 20, 0 <unfinished ...> 41155 <... mmap resumed> ) = -1 EACCES (Permission denied) Signed-off-by: Andrey Vagin <avagin@openvz.org> Acked-by: Pavel Emelyanov <xemul@parallels.com> Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
This commit is contained in:
committed by
Cyrill Gorcunov
parent
fa28f40aaa
commit
cbb6b2da3d
10
restorer.c
10
restorer.c
@@ -216,6 +216,8 @@ self_len_end:
|
|||||||
*/
|
*/
|
||||||
sys_lseek(args->fd_core, GET_FILE_OFF_AFTER(struct core_entry), SEEK_SET);
|
sys_lseek(args->fd_core, GET_FILE_OFF_AFTER(struct core_entry), SEEK_SET);
|
||||||
while (1) {
|
while (1) {
|
||||||
|
int prot;
|
||||||
|
|
||||||
ret = sys_read(args->fd_core, vma_entry, sizeof(*vma_entry));
|
ret = sys_read(args->fd_core, vma_entry, sizeof(*vma_entry));
|
||||||
if (!ret)
|
if (!ret)
|
||||||
break;
|
break;
|
||||||
@@ -242,6 +244,12 @@ self_len_end:
|
|||||||
vma_entry->flags &= ~MAP_ANONYMOUS;
|
vma_entry->flags &= ~MAP_ANONYMOUS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
prot = vma_entry->prot;
|
||||||
|
|
||||||
|
/* A mapping of file with MAP_SHARED is up to date */
|
||||||
|
if (vma_entry->fd == -1 || !(vma_entry->flags & MAP_SHARED))
|
||||||
|
prot |= PROT_WRITE;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Should map memory here. Note we map them as
|
* Should map memory here. Note we map them as
|
||||||
* writable since we're going to restore page
|
* writable since we're going to restore page
|
||||||
@@ -249,7 +257,7 @@ self_len_end:
|
|||||||
*/
|
*/
|
||||||
va = sys_mmap((void *)vma_entry->start,
|
va = sys_mmap((void *)vma_entry->start,
|
||||||
vma_entry_len(vma_entry),
|
vma_entry_len(vma_entry),
|
||||||
vma_entry->prot | PROT_WRITE,
|
prot,
|
||||||
vma_entry->flags | MAP_FIXED,
|
vma_entry->flags | MAP_FIXED,
|
||||||
vma_entry->fd,
|
vma_entry->fd,
|
||||||
vma_entry->pgoff);
|
vma_entry->pgoff);
|
||||||
|
Reference in New Issue
Block a user