Skip to content

Commit

Permalink
attach: explicitly close seccomp notifier fd
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
  • Loading branch information
Christian Brauner committed Feb 26, 2021
1 parent fd910d7 commit 5231575
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/lxc/attach.c
Expand Up @@ -1208,6 +1208,7 @@ __noreturn static void do_attach(struct attach_payload *ap)
ret = lxc_seccomp_send_notifier_fd(&conf->seccomp, ap->ipc_socket);
if (ret < 0)
goto on_error;
lxc_seccomp_close_notifier_fd(&conf->seccomp);
}

if (!lxc_switch_uid_gid(ctx->target_ns_uid, ctx->target_ns_gid))
Expand Down
12 changes: 12 additions & 0 deletions src/lxc/lxcseccomp.h
Expand Up @@ -91,6 +91,14 @@ __hidden extern int lxc_seccomp_send_notifier_fd(struct lxc_seccomp *seccomp, in
__hidden extern int lxc_seccomp_recv_notifier_fd(struct lxc_seccomp *seccomp, int socket_fd);
__hidden extern int lxc_seccomp_add_notifier(const char *name, const char *lxcpath,
struct lxc_seccomp *seccomp);
static inline void lxc_seccomp_close_notifier_fd(struct lxc_seccomp *seccomp)
{
#if HAVE_DECL_SECCOMP_NOTIFY_FD
if (seccomp->notifier.wants_supervision)
close_prot_errno_disarm(seccomp->notifier.notify_fd);
#endif
}

static inline int lxc_seccomp_get_notify_fd(struct lxc_seccomp *seccomp)
{
#if HAVE_DECL_SECCOMP_NOTIFY_FD
Expand Down Expand Up @@ -162,5 +170,9 @@ static inline int lxc_seccomp_get_notify_fd(struct lxc_seccomp *seccomp)
return -EBADF;
}

static inline void lxc_seccomp_close_notifier_fd(struct lxc_seccomp *seccomp)
{
}

#endif /* HAVE_SECCOMP */
#endif /* __LXC_LXCSECCOMP_H */
1 change: 0 additions & 1 deletion src/lxc/seccomp.c
Expand Up @@ -1638,7 +1638,6 @@ int lxc_seccomp_recv_notifier_fd(struct lxc_seccomp *seccomp, int socket_fd)
int lxc_seccomp_add_notifier(const char *name, const char *lxcpath,
struct lxc_seccomp *seccomp)
{

#if HAVE_DECL_SECCOMP_NOTIFY_FD
if (seccomp->notifier.wants_supervision) {
int ret;
Expand Down

0 comments on commit 5231575

Please sign in to comment.