Skip to content

Commit

Permalink
Merge pull request #3466 from alivenets/fix-no-new-privs
Browse files Browse the repository at this point in the history
attach: set no_new_privs flag after LSM label
  • Loading branch information
Christian Brauner committed Jun 30, 2020
2 parents 7c8b10e + 6ce8e67 commit f88d8e6
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions src/lxc/attach.c
Expand Up @@ -770,17 +770,6 @@ static int attach_child_main(struct attach_clone_payload *payload)
else
new_gid = ns_root_gid;

if ((init_ctx->container && init_ctx->container->lxc_conf &&
init_ctx->container->lxc_conf->no_new_privs) ||
(options->attach_flags & LXC_ATTACH_NO_NEW_PRIVS)) {
ret = prctl(PR_SET_NO_NEW_PRIVS, prctl_arg(1), prctl_arg(0),
prctl_arg(0), prctl_arg(0));
if (ret < 0)
goto on_error;

TRACE("Set PR_SET_NO_NEW_PRIVS");
}

if (needs_lsm) {
bool on_exec;

Expand All @@ -795,6 +784,17 @@ static int attach_child_main(struct attach_clone_payload *payload)
TRACE("Set %s LSM label to \"%s\"", lsm_name(), init_ctx->lsm_label);
}

if ((init_ctx->container && init_ctx->container->lxc_conf &&
init_ctx->container->lxc_conf->no_new_privs) ||
(options->attach_flags & LXC_ATTACH_NO_NEW_PRIVS)) {
ret = prctl(PR_SET_NO_NEW_PRIVS, prctl_arg(1), prctl_arg(0),
prctl_arg(0), prctl_arg(0));
if (ret < 0)
goto on_error;

TRACE("Set PR_SET_NO_NEW_PRIVS");
}

if (init_ctx->container && init_ctx->container->lxc_conf &&
init_ctx->container->lxc_conf->seccomp.seccomp) {
struct lxc_conf *conf = init_ctx->container->lxc_conf;
Expand Down

0 comments on commit f88d8e6

Please sign in to comment.