[CRIU] [PATCH] proc_parse: fix vma file open mode recognition

Andrew Vagin avagin at virtuozzo.com
Sun Jul 10 11:47:01 PDT 2016


On Sun, Jul 10, 2016 at 10:10:33AM -0700, Andrew Vagin wrote:
> On Sun, Jul 10, 2016 at 08:33:34AM -0700, Andrew Vagin wrote:
> > On Thu, Jul 07, 2016 at 11:43:59AM +0200, Stanislav Kinsburskiy wrote:
> > > 
> > > 
> > > 07.07.2016 03:10, Andrew Vagin пишет:
> > > > On Thu, Jun 30, 2016 at 07:24:45PM +0300, Stanislav Kinsburskiy wrote:
> > > > > The correct place to get fd open flags for file mappings is
> > > > > /proc/<pid>/map_files.
> > > > > An attempt tp speculate on "shared" and "maywrite" bits doesn't garantee,
> > > > > that file will be opened with correct permissions on restore.
> > > > > Here is an example:
> > > > > 
> > > > > Process mapping (read/write):
> > > > > 
> > > > > # cat /proc/481943/maps | grep 7f7108077000-7f7108078000
> > > > > 7f7108077000-7f7108078000 rw-p 00001000 00:35 7 <snip>
> > > > > 
> > > > > 1) Before suspend:
> > > > > 
> > > > > # ls -l /proc/481427/map_files/7f7108077000-7f7108078000
> > > > > lrw------- <snip> /proc/481427/map_files/7f7108077000-7f7108078000 -> <snip>
> > > > > 
> > > > > 2) After restore:
> > > > > 
> > > > > # ls -l /proc/481943/map_files/7f7108077000-7f7108078000
> > > > > lr-------- <snip> /proc/481943/map_files/7f7108077000-7f7108078000 -> <snip>
> > > > > 
> > > > > Write bit is lost.
> > > > Could you add this check into zdtm.py?
> > > > 
> > > 
> > > I'm sorry, but I have no idea where and how to do this.
> > >
> > 
> > I'm sorry, but we accept patches only with tests;).
> > 
> > You need to add this check into get_visible_state() and
> > check_visible_state().
> 
> I think it should be something like this:
> 
> diff --git a/test/zdtm.py b/test/zdtm.py
> index 7072b62..23559fd 100755
> --- a/test/zdtm.py
> +++ b/test/zdtm.py
> @@ -899,6 +899,12 @@ def get_visible_state(test):
>                 last = 0
>                 for mp in open("/proc/%s/root/proc/%s/maps" % (test.getpid(), pid)):
>                         m = map(lambda x: int('0x' + x, 0), mp.split()[0].split('-'))
> +
> +                        f = "/proc/%s/root/proc/%s/map_files/%s" % (test.getpid(), pid, mp.split()[0])
> +                        if os.access(f, os.F_OK):
> +                                st = os.stat(f)
> +                                m.append(st.st_mode)
> +
>                         if cmaps[last][1] == m[0]:
>                                 cmaps[last][1] = m[1]
>                         else:
                                cmaps.append(m)
                                last += 1
-               maps[pid] = set(map(lambda x: '%x-%x' % (x[0], x[1]), cmaps))
+               maps[pid] = set(map(lambda x: '%x-%x %s' % (x[0], x[1], x[2:]), cmaps))

But even with this fix it doesn't catch your problem and I can't reproduce it by hand.
> 
> but zdtm.py doesn't detect any errors with this patch,
> so you need to fix it to detect your issue.
> _______________________________________________
> CRIU mailing list
> CRIU at openvz.org
> https://lists.openvz.org/mailman/listinfo/criu


More information about the CRIU mailing list