[03/10] pstree: add id intersection bug_on to prepare_pstree_for_shell_job

Submitted by Pavel Tikhomirov on July 4, 2017, 9:08 a.m.

Details

Message ID 20170704090809.8127-4-ptikhomirov@virtuozzo.com
State New
Series "rework pgid restore for pidnses"
Headers show

Commit Message

Pavel Tikhomirov July 4, 2017, 9:08 a.m.
What if we replace ids in pstree to some new id, which we already
have in tree, that can leed to unexpected behaviour.

Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
---
 criu/pstree.c | 2 ++
 1 file changed, 2 insertions(+)

Patch hide | download patch | download mbox

diff --git a/criu/pstree.c b/criu/pstree.c
index e712dd3..b4d993f 100644
--- a/criu/pstree.c
+++ b/criu/pstree.c
@@ -488,8 +488,10 @@  static int prepare_pstree_for_shell_job(void)
 		old_gid, current_gid, old_sid, current_sid);
 
 	for_each_pstree_item(pi) {
+		BUG_ON(vpgid(pi) == current_gid);
 		if (vpgid(pi) == old_gid)
 			vpgid(pi) = current_gid;
+		BUG_ON(vsid(pi) == current_sid);
 		if (vsid(pi) == old_sid)
 			vsid(pi) = current_sid;
 	}