[CRIU] [PATCH] criu: correctly handle mixed-permission mapped files

Pavel Emelyanov xemul at parallels.com
Wed Apr 2 05:07:14 PDT 2014


On 04/02/2014 12:25 AM, 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 means
> that 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 with O_RDONLY
> during restore, and mmap(PROT_WRITE) will fail with EACCES.

Good catch, thanks! :)

> To fix this, allow multiple RegFileEntry messages with the same id;
> later RegFileEntry messages update flags in existing file_descs.

Maybe it's much easier just to ignore the flags for filemap rfe-s (dump them
as zeros) and tune the get_filemap_fd() so that it passes correct flag (the
one required to map a vma) into do_openreg_noseek?

It would also be nice if we have this test in zdtm/ suite to prevent accidental
breakage of this functionality in the future.

> Signed-off-by: Jamie Liu <jamieliu at google.com>

Thanks,
Pavel


More information about the CRIU mailing list