criu: don't abort criu in lookup_create_item()

Submitted by Andrei Vagin on July 17, 2017, 10:19 p.m.

Details

Message ID 20170717221935.5149-1-avagin@openvz.org
State Accepted
Series "criu: don't abort criu in lookup_create_item()"
Commit f6d6433c8ce6dfb9454c55d1b03ecf94952f9bc5
Headers show

Commit Message

Andrei Vagin July 17, 2017, 10:19 p.m.
From: Andrei Vagin <avagin@virtuozzo.com>

Currently lookup_create_item() calls BUG_ON(), if it meets a thread.
We don't expect to meet a thread there, but if images contain incorrect
data, we can be in this situation in open_remap_dead_process().

(gdb) bt

Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
---
 criu/pstree.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/criu/pstree.c b/criu/pstree.c
index 9ae1912..3fca758 100644
--- a/criu/pstree.c
+++ b/criu/pstree.c
@@ -612,7 +612,11 @@  struct pstree_item *lookup_create_item(pid_t *pid, int level, uint32_t ns_id)
 	node = lookup_create_pid(pid, level, NULL, ns_id);
 	if (!node)
 		return NULL;
-	BUG_ON(node->state == TASK_THREAD);
+
+	if (node->state == TASK_THREAD) {
+		pr_err("The %d node is used for a thread\n", *pid);
+		return NULL;
+	}
 
 	return node->item;
 }

Comments

Andrey Vagin July 24, 2017, 10:37 p.m.
Applied
On Tue, Jul 18, 2017 at 01:19:35AM +0300, Andrei Vagin wrote:
> From: Andrei Vagin <avagin@virtuozzo.com>
> 
> Currently lookup_create_item() calls BUG_ON(), if it meets a thread.
> We don't expect to meet a thread there, but if images contain incorrect
> data, we can be in this situation in open_remap_dead_process().
> 
> (gdb) bt
> 
> Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
> ---
>  criu/pstree.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/criu/pstree.c b/criu/pstree.c
> index 9ae1912..3fca758 100644
> --- a/criu/pstree.c
> +++ b/criu/pstree.c
> @@ -612,7 +612,11 @@ struct pstree_item *lookup_create_item(pid_t *pid, int level, uint32_t ns_id)
>  	node = lookup_create_pid(pid, level, NULL, ns_id);
>  	if (!node)
>  		return NULL;
> -	BUG_ON(node->state == TASK_THREAD);
> +
> +	if (node->state == TASK_THREAD) {
> +		pr_err("The %d node is used for a thread\n", *pid);
> +		return NULL;
> +	}
>  
>  	return node->item;
>  }
> -- 
> 2.9.4
>