mirror of
https://github.com/checkpoint-restore/criu
synced 2025-08-22 01:51:51 +00:00
namespace: skip cleaning up the uid/gid map in error cases
free_userns_maps is called to clean up uid/gid map when the dump finishes. If we try to clean up these maps in error cases, it can lead to double free panic. So just skip cleaning up these maps and let free_userns_maps do its job. Signed-off-by: Bui Quang Minh <minhquangbui99@gmail.com>
This commit is contained in:
parent
d18912fc88
commit
25f7185202
@ -1009,36 +1009,31 @@ int dump_user_ns(pid_t pid, int ns_id)
|
|||||||
|
|
||||||
ret = parse_id_map(pid, "uid_map", &e->uid_map);
|
ret = parse_id_map(pid, "uid_map", &e->uid_map);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
goto err;
|
/*
|
||||||
|
* The uid_map and gid_map is clean up in free_userns_maps
|
||||||
|
* later, so we don't need to clean these up in error cases.
|
||||||
|
*/
|
||||||
|
return -1;
|
||||||
|
|
||||||
e->n_uid_map = ret;
|
e->n_uid_map = ret;
|
||||||
|
|
||||||
ret = parse_id_map(pid, "gid_map", &e->gid_map);
|
ret = parse_id_map(pid, "gid_map", &e->gid_map);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
goto err;
|
return -1;
|
||||||
e->n_gid_map = ret;
|
e->n_gid_map = ret;
|
||||||
|
|
||||||
if (check_user_ns(pid))
|
if (check_user_ns(pid))
|
||||||
goto err;
|
return -1;
|
||||||
|
|
||||||
img = open_image(CR_FD_USERNS, O_DUMP, ns_id);
|
img = open_image(CR_FD_USERNS, O_DUMP, ns_id);
|
||||||
if (!img)
|
if (!img)
|
||||||
goto err;
|
return -1;
|
||||||
ret = pb_write_one(img, e, PB_USERNS);
|
ret = pb_write_one(img, e, PB_USERNS);
|
||||||
close_image(img);
|
close_image(img);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
goto err;
|
return -1;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
err:
|
|
||||||
if (e->uid_map) {
|
|
||||||
xfree(e->uid_map[0]);
|
|
||||||
xfree(e->uid_map);
|
|
||||||
}
|
|
||||||
if (e->gid_map) {
|
|
||||||
xfree(e->gid_map[0]);
|
|
||||||
xfree(e->gid_map);
|
|
||||||
}
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void free_userns_maps(void)
|
void free_userns_maps(void)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user