Projects STRLCPY criu Commits bd0f209c
🤬
  • pstree: improve id intersection detection in prepare_pstree_for_shell_job

    First, let's move lookup_create_item-s to the end so that on pgid
    replacement we don't have false positive pstree_pid_by_virt check
    founding item created by sid replacement. (note: we need those
    lookup_create_item-s for the sake of free pid selection mechanism)
    
    Second, let's add checks for sid/pgid in images intersecting with
    current_sid/pgid, as this would also bring problems on restore.
    
    Signed-off-by: Pavel Tikhomirov <[email protected]>
  • Loading...
  • Pavel Tikhomirov committed with Andrei Vagin 1 year ago
    bd0f209c
    1 parent 66fd45d5
  • ■ ■ ■ ■ ■ ■
    criu/pstree.c
    skipped 380 lines
    381 381   }
    382 382   
    383 383   for_each_pstree_item(pi) {
     384 + if (pi->sid == current_sid) {
     385 + pr_err("Current sid %d intersects with sid of (%d) in images\n", current_sid, vpid(pi));
     386 + return -1;
     387 + }
    384 388   if (pi->sid == old_sid)
    385 389   pi->sid = current_sid;
    386 390   
     391 + if (pi->pgid == current_sid) {
     392 + pr_err("Current sid %d intersects with pgid of (%d) in images\n", current_sid,
     393 + vpid(pi));
     394 + return -1;
     395 + }
    387 396   if (pi->pgid == old_sid)
    388 397   pi->pgid = current_sid;
    389 398   }
    390  - 
    391  - if (lookup_create_item(current_sid) == NULL)
    392  - return -1;
    393 399   }
    394 400   
    395 401   /* root_item is a group leader */
    396 402   if (root_item->pgid == vpid(root_item))
    397  - return 0;
     403 + goto add_fake_session_leader;
    398 404   
    399 405   old_gid = root_item->pgid;
    400 406   if (old_gid != current_gid) {
    skipped 6 lines
    407 413   }
    408 414   
    409 415   for_each_pstree_item(pi) {
     416 + if (current_gid != current_sid && pi->pgid == current_gid) {
     417 + pr_err("Current gid %d intersects with pgid of (%d) in images\n", current_gid,
     418 + vpid(pi));
     419 + return -1;
     420 + }
    410 421   if (pi->pgid == old_gid)
    411 422   pi->pgid = current_gid;
    412 423   }
    413  - 
    414  - if (lookup_create_item(current_gid) == NULL)
    415  - return -1;
    416 424   }
    417 425   
     426 + if (old_gid != current_gid && !lookup_create_item(current_gid))
     427 + return -1;
     428 +add_fake_session_leader:
     429 + if (old_sid != current_sid && !lookup_create_item(current_sid))
     430 + return -1;
    418 431   return 0;
    419 432  }
    420 433   
    skipped 693 lines
Please wait...
Page is in error, reload to recover