Projects STRLCPY criu Commits f8da250b
🤬
  • cr-dump: properly apply rseq fixup for all threads

    Previously fixup was done before threads' registers were dumped so it
    didn't actually work. This commit splits rseq fixup into thread leader
    fixup and other threads fixup and applies them after the entities are
    seized.
    
    Signed-off-by: Michal Clapinski <[email protected]>
  • Loading...
  • Michal Clapinski committed with Andrei Vagin 1 year ago
    f8da250b
    1 parent 78c4e2c0
  • ■ ■ ■ ■ ■ ■
    criu/cr-dump.c
    skipped 879 lines
    880 880   return addr >= rseq_cs->start_ip && addr < rseq_cs->start_ip + rseq_cs->post_commit_offset;
    881 881  }
    882 882   
    883  -static int fixup_thread_rseq(struct pstree_item *item, int i)
     883 +static int fixup_thread_rseq(const struct pstree_item *item, int i)
    884 884  {
    885 885   CoreEntry *core = item->core[i];
    886 886   struct criu_rseq_cs *rseq_cs = &dmpi(item)->thread_rseq_cs[i];
    887 887   pid_t tid = item->threads[i].real;
     888 + 
     889 + if (!kdat.has_ptrace_get_rseq_conf)
     890 + return 0;
    888 891   
    889 892   /* equivalent to (struct rseq)->rseq_cs is NULL */
    890 893   if (!rseq_cs->start_ip)
    skipped 69 lines
    960 963   
    961 964   core->thread_core->creds->lsm_profile = dmpi(item)->thread_lsms[id]->profile;
    962 965   core->thread_core->creds->lsm_sockcreate = dmpi(item)->thread_lsms[0]->sockcreate;
     966 + 
     967 + ret = fixup_thread_rseq(item, id);
     968 + if (ret) {
     969 + pr_err("Can't fixup rseq for pid %d\n", pid);
     970 + goto err;
     971 + }
    963 972   
    964 973   img = open_image(CR_FD_CORE, O_DUMP, tid->ns[0].virt);
    965 974   if (!img)
    skipped 281 lines
    1247 1256   return -1;
    1248 1257  }
    1249 1258   
    1250  -static int fixup_task_rseq(pid_t pid, struct pstree_item *item)
    1251  -{
    1252  - int ret = 0;
    1253  - int i;
    1254  - 
    1255  - if (!kdat.has_ptrace_get_rseq_conf)
    1256  - return 0;
    1257  - 
    1258  - for (i = 0; i < item->nr_threads; i++) {
    1259  - if (fixup_thread_rseq(item, i)) {
    1260  - ret = -1;
    1261  - goto exit;
    1262  - }
    1263  - }
    1264  - 
    1265  -exit:
    1266  - xfree(dmpi(item)->thread_rseq_cs);
    1267  - dmpi(item)->thread_rseq_cs = NULL;
    1268  - return ret;
    1269  -}
    1270  - 
    1271 1259  static struct proc_pid_stat pps_buf;
    1272 1260   
    1273 1261  static int dump_task_threads(struct parasite_ctl *parasite_ctl, const struct pstree_item *item)
    1274 1262  {
    1275  - int i;
     1263 + int i, ret = 0;
    1276 1264   
    1277 1265   for (i = 0; i < item->nr_threads; i++) {
    1278 1266   /* Leader is already dumped */
    skipped 1 lines
    1280 1268   item->threads[i].ns[0].virt = vpid(item);
    1281 1269   continue;
    1282 1270   }
    1283  - if (dump_task_thread(parasite_ctl, item, i))
    1284  - return -1;
     1271 + ret = dump_task_thread(parasite_ctl, item, i);
     1272 + if (ret)
     1273 + break;
    1285 1274   }
    1286 1275   
    1287  - return 0;
     1276 + xfree(dmpi(item)->thread_rseq_cs);
     1277 + dmpi(item)->thread_rseq_cs = NULL;
     1278 + return ret;
    1288 1279  }
    1289 1280   
    1290 1281  /*
    skipped 317 lines
    1608 1599   goto err;
    1609 1600   }
    1610 1601   
    1611  - ret = fixup_task_rseq(pid, item);
     1602 + ret = fixup_thread_rseq(item, 0);
    1612 1603   if (ret) {
    1613 1604   pr_err("Fixup rseq for %d failed %d\n", pid, ret);
    1614 1605   goto err;
    skipped 684 lines
Please wait...
Page is in error, reload to recover