<div dir="ltr">Hi Andrei,<div><br></div><div>I have resent the whole series.</div><div><br></div><div>Best,</div><div>Harsha</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Sep 20, 2019 at 10:37 AM Andrei Vagin <<a href="mailto:avagin@gmail.com">avagin@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On Sun, Sep 15, 2019 at 10:27:04AM +0530, Harshavardhan Unnibhavi wrote:<br>
> Hi Andrei,<br>
> <br>
> This is actually a continuation of the series of patches that I have<br>
> started from here:<br>
> <a href="https://lists.openvz.org/pipermail/criu/2019-June/044144.html" rel="noreferrer" target="_blank">https://lists.openvz.org/pipermail/criu/2019-June/044144.html</a>. I think<br>
> I made a mistake and sent it as a patch series instead of a standalone<br>
> patch.<br>
> <br>
> Should I just send it as a single patch or send the three patches<br>
> together or leave it as is?<br>
<br>
Could you resend the whole series?<br>
<br>
> <br>
> Best,<br>
> Harsha<br>
> <br>
> <br>
> On Sun, Sep 15, 2019 at 10:19 AM Andrei Vagin <<a href="mailto:avagin@gmail.com" target="_blank">avagin@gmail.com</a>> wrote:<br>
> ><br>
> > I see only the third patch of this series. Where are two others and a<br>
> > cover letter?<br>
> ><br>
> > On Thu, Sep 05, 2019 at 07:25:59PM +0530, Harshavardhan Unnibhavi wrote:<br>
> > > This commit restores anonymized images containing their file paths<br>
> > > maximized.<br>
> > ><br>
> > > This commit introduces the following:<br>
> > > - anon option for the restore action.<br>
> > ><br>
> > > This commit modifies the following:<br>
> > > - pretend anonymized files in question are opened.<br>
> > ><br>
> > > Resolve Issue #360.<br>
> > ><br>
> > > Signed-off-by: Harshavardhan Unnibhavi <<a href="mailto:hvubfoss@gmail.com" target="_blank">hvubfoss@gmail.com</a>><br>
> > > ---<br>
> > > criu/config.c | 5 +++++<br>
> > > criu/cr-restore.c | 5 +++++<br>
> > > criu/files-reg.c | 12 ++++++++++--<br>
> > > criu/files.c | 4 ++--<br>
> > > criu/include/cr_options.h | 1 +<br>
> > > criu/include/restorer.h | 1 +<br>
> > > criu/pie/restorer.c | 4 ++--<br>
> > > 7 files changed, 26 insertions(+), 6 deletions(-)<br>
> > ><br>
> > > diff --git a/criu/config.c b/criu/config.c<br>
> > > index 3a54afd4..d36150e0 100644<br>
> > > --- a/criu/config.c<br>
> > > +++ b/criu/config.c<br>
> > > @@ -276,6 +276,7 @@ void init_opts(void)<br>
> > > opts.empty_ns = 0;<br>
> > > opts.status_fd = -1;<br>
> > > opts.log_level = DEFAULT_LOGLEVEL;<br>
> > > + opts.anonymize = false;<br>
> > > }<br>
> > ><br>
> > > bool deprecated_ok(char *what)<br>
> > > @@ -455,6 +456,7 @@ int parse_options(int argc, char **argv, bool *usage_error,<br>
> > > { "root", required_argument, 0, 'r' },<br>
> > > { USK_EXT_PARAM, optional_argument, 0, 'x' },<br>
> > > { "help", no_argument, 0, 'h' },<br>
> > > + { "anon", no_argument, 0, 'a' },<br>
> > > BOOL_OPT(SK_EST_PARAM, &opts.tcp_established_ok),<br>
> > > { "close", required_argument, 0, 1043 },<br>
> > > BOOL_OPT("log-pid", &opts.log_file_per_pid),<br>
> > > @@ -574,6 +576,9 @@ int parse_options(int argc, char **argv, bool *usage_error,<br>
> > > continue;<br>
> > ><br>
> > > switch (opt) {<br>
> > > + case 'a':<br>
> > > + opts.anonymize = true;<br>
> > > + break;<br>
> > > case 's':<br>
> > > opts.final_state = TASK_STOPPED;<br>
> > > break;<br>
> > > diff --git a/criu/cr-restore.c b/criu/cr-restore.c<br>
> > > index de0b2cb4..05896ab0 100644<br>
> > > --- a/criu/cr-restore.c<br>
> > > +++ b/criu/cr-restore.c<br>
> > > @@ -882,6 +882,9 @@ static int restore_one_alive_task(int pid, CoreEntry *core)<br>
> > ><br>
> > > memzero(ta, args_len);<br>
> > ><br>
> > > + if(opts.anonymize)<br>
> > > + ta->anonymize = true;<br>
> > > +<br>
> > > if (prepare_fds(current))<br>
> > > return -1;<br>
> > ><br>
> > > @@ -2268,6 +2271,8 @@ skip_ns_bouncing:<br>
> > > goto out_kill;<br>
> > ><br>
> > > pr_info("Restore finished successfully. Resuming tasks.\n");<br>
> > > + if(opts.anonymize)<br>
> > > + return 0;<br>
> > > __restore_switch_stage(CR_STATE_COMPLETE);<br>
> > ><br>
> > > if (ret == 0)<br>
> > > diff --git a/criu/files-reg.c b/criu/files-reg.c<br>
> > > index 1b51d108..a3a2396d 100644<br>
> > > --- a/criu/files-reg.c<br>
> > > +++ b/criu/files-reg.c<br>
> > > @@ -1745,14 +1745,14 @@ ext:<br>
> > > return -1;<br>
> > > }<br>
> > ><br>
> > > - if (rfi->rfe->has_size && (st.st_size != rfi->rfe->size)) {<br>
> > > + if (rfi->rfe->has_size && (st.st_size != rfi->rfe->size) && (!opts.anonymize)) {<br>
> > > pr_err("File %s has bad size %"PRIu64" (expect %"PRIu64")\n",<br>
> > > rfi->path, st.st_size,<br>
> > > rfi->rfe->size);<br>
> > > return -1;<br>
> > > }<br>
> > ><br>
> > > - if (rfi->rfe->has_mode && (st.st_mode != rfi->rfe->mode)) {<br>
> > > + if (rfi->rfe->has_mode && (st.st_mode != rfi->rfe->mode) && (!opts.anonymize)) {<br>
> > > pr_err("File %s has bad mode 0%o (expect 0%o)\n",<br>
> > > rfi->path, (int)st.st_mode,<br>
> > > rfi->rfe->mode);<br>
> > > @@ -1793,6 +1793,14 @@ int do_open_reg_noseek_flags(int ns_root_fd, struct reg_file_info *rfi, void *ar<br>
> > > flags &= ~O_TMPFILE;<br>
> > ><br>
> > > fd = openat(ns_root_fd, rfi->path, flags);<br>
> > > + if(opts.anonymize){<br>
> > > + fd = openat(ns_root_fd, "/dev/zero", flags);<br>
> > > + if(fd < 0){<br>
> > > + pr_perror("Unable to create a fake file descriptor");<br>
> > > + return fd;<br>
> > > + }<br>
> > > + pr_info("Restoring anonymized file paths.\n");<br>
> > > + }<br>
> > > if (fd < 0) {<br>
> > > pr_perror("Can't open file %s on restore", rfi->path);<br>
> > > return fd;<br>
> > > diff --git a/criu/files.c b/criu/files.c<br>
> > > index ffdaa459..a7e76247 100644<br>
> > > --- a/criu/files.c<br>
> > > +++ b/criu/files.c<br>
> > > @@ -1313,7 +1313,7 @@ static int fchroot(int fd)<br>
> > > * it using fchdir()<br>
> > > */<br>
> > ><br>
> > > - if (fchdir(fd) < 0) {<br>
> > > + if (fchdir(fd) < 0 && !(opts.anonymize)) {<br>
> > > pr_perror("Can't chdir to proc");<br>
> > > return -1;<br>
> > > }<br>
> > > @@ -1356,7 +1356,7 @@ int restore_fs(struct pstree_item *me)<br>
> > > }<br>
> > ><br>
> > > ret = fchdir(dd_cwd);<br>
> > > - if (ret < 0) {<br>
> > > + if (ret < 0 && !(opts.anonymize)) {<br>
> > > pr_perror("Can't change cwd");<br>
> > > goto out;<br>
> > > }<br>
> > > diff --git a/criu/include/cr_options.h b/criu/include/cr_options.h<br>
> > > index c519c740..75539625 100644<br>
> > > --- a/criu/include/cr_options.h<br>
> > > +++ b/criu/include/cr_options.h<br>
> > > @@ -111,6 +111,7 @@ struct cr_options {<br>
> > > int enable_external_masters;<br>
> > > bool aufs; /* auto-detected, not via cli */<br>
> > > bool overlayfs;<br>
> > > + bool anonymize;<br>
> > > #ifdef CONFIG_BINFMT_MISC_VIRTUALIZED<br>
> > > bool has_binfmt_misc; /* auto-detected */<br>
> > > #endif<br>
> > > diff --git a/criu/include/restorer.h b/criu/include/restorer.h<br>
> > > index b93807f5..203b1153 100644<br>
> > > --- a/criu/include/restorer.h<br>
> > > +++ b/criu/include/restorer.h<br>
> > > @@ -136,6 +136,7 @@ struct task_restore_args {<br>
> > ><br>
> > > int uffd;<br>
> > > bool has_thp_enabled;<br>
> > > + bool anonymize;<br>
> > ><br>
> > > /* threads restoration */<br>
> > > int nr_threads; /* number of threads */<br>
> > > diff --git a/criu/pie/restorer.c b/criu/pie/restorer.c<br>
> > > index 390c0e1a..87c8ed4a 100644<br>
> > > --- a/criu/pie/restorer.c<br>
> > > +++ b/criu/pie/restorer.c<br>
> > > @@ -1719,12 +1719,12 @@ long __export_restore_task(struct task_restore_args *args)<br>
> > > */<br>
> > > ret |= restore_self_exe_late(args);<br>
> > > } else {<br>
> > > - if (ret)<br>
> > > + if (ret && !(args->anonymize))<br>
> > > pr_err("sys_prctl(PR_SET_MM, PR_SET_MM_MAP) failed with %d\n", (int)ret);<br>
> > > sys_close(args->fd_exe_link);<br>
> > > }<br>
> > ><br>
> > > - if (ret)<br>
> > > + if (ret && !(args->anonymize))<br>
> > > goto core_restore_end;<br>
> > ><br>
> > > /* SELinux (1) process context needs to be set before creating threads. */<br>
> > > --<br>
> > > 2.17.1<br>
> > ><br>
> > > _______________________________________________<br>
> > > CRIU mailing list<br>
> > > <a href="mailto:CRIU@openvz.org" target="_blank">CRIU@openvz.org</a><br>
> > > <a href="https://lists.openvz.org/mailman/listinfo/criu" rel="noreferrer" target="_blank">https://lists.openvz.org/mailman/listinfo/criu</a><br>
</blockquote></div>