The following pull request was submitted through Github. It can be accessed and reviewed at: https://github.com/lxc/lxc/pull/2321
This e-mail was sent by the LXC bot, direct replies will not reach the author unless they happen to be subscribed to this list. === Description (from pull-request) === In function userns_exec_full() @ conf.c, there is the following pointer that is used in a double-linked list, struct lxc_list *idmap = NULL; This pointer is malloc()-ed, and then additional objects are added to the list using lxc_list_add_tail(). At the end of the function, the dynamically allocated memory is freed with lxc_free_idmap(idmap); lxc_free_idmap(idmap) does not free memory of the initial memory allocation for "idmap", therefore there is a memory leak. The function lxc_free_idmap() is used in another place as well, and at that place it does not free() the initial pointer (correct behaviour). Therefore, there is a need for a free() in the function userns_exec_full() @ conf.c.
From 798c373c75a7b266cddb42610661f2eef5b37b5c Mon Sep 17 00:00:00 2001 From: Simos Xenitellis <[email protected]> Date: Tue, 15 May 2018 01:39:27 +0300 Subject: [PATCH 1/2] Fixed resource leak in suggest_default_idmap() @ conf.c coverity: #1425802 coverity: #1425844 --- src/lxc/conf.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/lxc/conf.c b/src/lxc/conf.c index e854b8b03..22edd8cb7 100644 --- a/src/lxc/conf.c +++ b/src/lxc/conf.c @@ -4497,6 +4497,8 @@ void suggest_default_idmap(void) if (!urange || !grange) { ERROR("You do not have subuids or subgids allocated"); ERROR("Unprivileged containers require subuids and subgids"); + free(gname); + free(uname); return; } From ed4375f568d3527e321c628df9b04cf34bf1d34a Mon Sep 17 00:00:00 2001 From: Simos Xenitellis <[email protected]> Date: Tue, 15 May 2018 01:47:16 +0300 Subject: [PATCH 2/2] Fixed resource leak in userns_exec_full() @ conf.c coverity: #1425836 --- src/lxc/conf.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/lxc/conf.c b/src/lxc/conf.c index 22edd8cb7..df07be8a0 100644 --- a/src/lxc/conf.c +++ b/src/lxc/conf.c @@ -4082,8 +4082,10 @@ struct lxc_list *get_minimal_idmap(struct lxc_conf *conf) return idmap; on_error: - if (idmap) + if (idmap) { lxc_free_idmap(idmap); + free(id_map); + } if (container_root_uid) free(container_root_uid); if (container_root_gid)
_______________________________________________ lxc-devel mailing list [email protected] http://lists.linuxcontainers.org/listinfo/lxc-devel
