[CRIU] [PATCH v4] criu: fix filemap open permissions

Pavel Emelyanov xemul at parallels.com
Fri Apr 4 09:36:21 PDT 2014


On 04/04/2014 12:04 PM, Jamie Liu wrote:
> An mmaped file is opened O_RDONLY or O_RDWR depending on the permissions
> on the first vma dump_task_mm() encounters mapping that file. This
> causes two problems:
> 
> 1. If a file has multiple MAP_SHARED mappings, some of which are
>    read-only and some of which are read-write, and the first encountered
>    mapping happens to be read-only, the file will be opened O_RDONLY
>    during restore, and mmap(PROT_WRITE) will fail with EACCES, causing
>    the restore to fail.
> 
> 2. If a file is opened read-write and mapped read-only, it will be
>    opened O_RDONLY during restore, so restore will succeed, but
>    mprotect(PROT_WRITE) on the read-only mapping after restore will
>    fail.
> 
> To fix both of these, record open flags per-vma based on the presence of
> VM_MAYWRITE in smaps.
> 
> Signed-off-by: Jamie Liu <jamieliu at google.com>

Applied, thanks!


More information about the CRIU mailing list