mirror of
https://git.proxmox.com/git/mirror_lxc
synced 2025-08-16 12:29:40 +00:00
lxc: avoid memory corruption on ppc and s390 V4
conf object is on stack and is used in forked process. Signed-off-by: Michel Normand <normand@fr.ibm.com> Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
This commit is contained in:
parent
4eec6850fc
commit
7b379ab3a5
@ -815,18 +815,28 @@ out:
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int lxc_conf_init(struct lxc_conf *conf)
|
struct lxc_conf *lxc_conf_init(void)
|
||||||
{
|
{
|
||||||
conf->rootfs = NULL;
|
struct lxc_conf *new;
|
||||||
conf->fstab = NULL;
|
|
||||||
conf->utsname = NULL;
|
new = malloc(sizeof(*new));
|
||||||
conf->tty = 0;
|
if (!new) {
|
||||||
conf->pts = 0;
|
ERROR("lxc_conf_init : %m");
|
||||||
conf->console[0] = '\0';
|
return NULL;
|
||||||
lxc_list_init(&conf->cgroup);
|
}
|
||||||
lxc_list_init(&conf->network);
|
memset(new, 0, sizeof(*new));
|
||||||
lxc_list_init(&conf->mount_list);
|
|
||||||
return 0;
|
new->rootfs = NULL;
|
||||||
|
new->fstab = NULL;
|
||||||
|
new->utsname = NULL;
|
||||||
|
new->tty = 0;
|
||||||
|
new->pts = 0;
|
||||||
|
new->console[0] = '\0';
|
||||||
|
lxc_list_init(&new->cgroup);
|
||||||
|
lxc_list_init(&new->network);
|
||||||
|
lxc_list_init(&new->mount_list);
|
||||||
|
|
||||||
|
return new;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int instanciate_veth(struct lxc_netdev *netdev)
|
static int instanciate_veth(struct lxc_netdev *netdev)
|
||||||
|
@ -171,7 +171,7 @@ struct lxc_conf {
|
|||||||
/*
|
/*
|
||||||
* Initialize the lxc configuration structure
|
* Initialize the lxc configuration structure
|
||||||
*/
|
*/
|
||||||
extern int lxc_conf_init(struct lxc_conf *conf);
|
extern struct lxc_conf *lxc_conf_init(void);
|
||||||
|
|
||||||
extern int lxc_create_network(struct lxc_list *networks);
|
extern int lxc_create_network(struct lxc_list *networks);
|
||||||
extern int lxc_assign_network(struct lxc_list *networks, pid_t pid);
|
extern int lxc_assign_network(struct lxc_list *networks, pid_t pid);
|
||||||
|
@ -84,7 +84,7 @@ int main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
static char **args;
|
static char **args;
|
||||||
char *rcfile;
|
char *rcfile;
|
||||||
struct lxc_conf conf;
|
struct lxc_conf *conf;
|
||||||
|
|
||||||
if (lxc_arguments_parse(&my_args, argc, argv))
|
if (lxc_arguments_parse(&my_args, argc, argv))
|
||||||
return -1;
|
return -1;
|
||||||
@ -113,16 +113,17 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lxc_conf_init(&conf)) {
|
conf = lxc_conf_init();
|
||||||
ERROR("failed to initialze configuration");
|
if (!conf) {
|
||||||
|
ERROR("failed to initialize configuration");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rcfile && lxc_config_read(rcfile, &conf)) {
|
if (rcfile && lxc_config_read(rcfile, conf)) {
|
||||||
ERROR("failed to read configuration file");
|
ERROR("failed to read configuration file");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return lxc_start(my_args.name, args, &conf);
|
return lxc_start(my_args.name, args, conf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -133,7 +133,7 @@ int main(int argc, char *argv[])
|
|||||||
};
|
};
|
||||||
|
|
||||||
char *rcfile = NULL;
|
char *rcfile = NULL;
|
||||||
struct lxc_conf conf;
|
struct lxc_conf *conf;
|
||||||
|
|
||||||
if (lxc_arguments_parse(&my_args, argc, argv))
|
if (lxc_arguments_parse(&my_args, argc, argv))
|
||||||
return err;
|
return err;
|
||||||
@ -163,12 +163,13 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lxc_conf_init(&conf)) {
|
conf = lxc_conf_init();
|
||||||
ERROR("failed to initialze configuration");
|
if (!conf) {
|
||||||
|
ERROR("failed to initialize configuration");
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rcfile && lxc_config_read(rcfile, &conf)) {
|
if (rcfile && lxc_config_read(rcfile, conf)) {
|
||||||
ERROR("failed to read configuration file");
|
ERROR("failed to read configuration file");
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
@ -204,7 +205,7 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
save_tty(&tios);
|
save_tty(&tios);
|
||||||
|
|
||||||
err = lxc_start(my_args.name, args, &conf);
|
err = lxc_start(my_args.name, args, conf);
|
||||||
|
|
||||||
restore_tty(&tios);
|
restore_tty(&tios);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user