1 /* SPDX-License-Identifier: LGPL-2.1+ */
3 #ifndef __LXC_LXCSECCOMP_H
4 #define __LXC_LXCSECCOMP_H
11 #include <linux/seccomp.h>
14 #if HAVE_DECL_SECCOMP_NOTIFY_FD
15 #include <sys/socket.h>
22 #include "memory_utils.h"
25 struct lxc_epoll_descr
;
28 #ifndef SECCOMP_FILTER_FLAG_NEW_LISTENER
29 #define SECCOMP_FILTER_FLAG_NEW_LISTENER (1UL << 3)
35 #if HAVE_DECL_SECCOMP_NOTIFY_FD
37 #if !HAVE_STRUCT_SECCOMP_NOTIF_SIZES
38 struct seccomp_notif_sizes
{
40 __u16 seccomp_notif_resp
;
45 struct seccomp_notify_proxy_msg
{
49 struct seccomp_notif_sizes sizes
;
51 /* followed by: seccomp_notif, seccomp_notif_resp, cookie */
54 struct seccomp_notify
{
55 bool wants_supervision
;
58 struct sockaddr_un proxy_addr
;
59 struct seccomp_notif_sizes sizes
;
60 struct seccomp_notif
*req_buf
;
61 struct seccomp_notif_resp
*rsp_buf
;
65 #define HAVE_SECCOMP_NOTIFY 1
67 #endif /* HAVE_DECL_SECCOMP_NOTIFY_FD */
71 #if HAVE_SCMP_FILTER_CTX
72 unsigned int allow_nesting
;
73 scmp_filter_ctx seccomp_ctx
;
74 #endif /* HAVE_SCMP_FILTER_CTX */
76 #if HAVE_DECL_SECCOMP_NOTIFY_FD
77 struct seccomp_notify notifier
;
78 #endif /* HAVE_DECL_SECCOMP_NOTIFY_FD */
81 __hidden
extern int lxc_seccomp_load(struct lxc_conf
*conf
);
82 __hidden
extern int lxc_read_seccomp_config(struct lxc_conf
*conf
);
83 __hidden
extern void lxc_seccomp_free(struct lxc_seccomp
*seccomp
);
84 __hidden
extern int seccomp_notify_handler(int fd
, uint32_t events
, void *data
,
85 struct lxc_epoll_descr
*descr
);
86 __hidden
extern void seccomp_conf_init(struct lxc_conf
*conf
);
87 __hidden
extern int lxc_seccomp_setup_proxy(struct lxc_seccomp
*seccomp
,
88 struct lxc_epoll_descr
*descr
,
89 struct lxc_handler
*handler
);
90 __hidden
extern int lxc_seccomp_send_notifier_fd(struct lxc_seccomp
*seccomp
, int socket_fd
);
91 __hidden
extern int lxc_seccomp_recv_notifier_fd(struct lxc_seccomp
*seccomp
, int socket_fd
);
92 __hidden
extern int lxc_seccomp_add_notifier(const char *name
, const char *lxcpath
,
93 struct lxc_seccomp
*seccomp
);
94 static inline int lxc_seccomp_get_notify_fd(struct lxc_seccomp
*seccomp
)
96 #if HAVE_DECL_SECCOMP_NOTIFY_FD
97 return seccomp
->notifier
.notify_fd
;
104 #else /* HAVE_SECCOMP */
110 static inline int lxc_seccomp_load(struct lxc_conf
*conf
)
115 static inline int lxc_read_seccomp_config(struct lxc_conf
*conf
)
120 static inline void lxc_seccomp_free(struct lxc_seccomp
*seccomp
)
122 free_disarm(seccomp
->seccomp
);
125 static inline int seccomp_notify_handler(int fd
, uint32_t events
, void *data
,
126 struct lxc_epoll_descr
*descr
)
131 static inline void seccomp_conf_init(struct lxc_conf
*conf
)
135 static inline int lxc_seccomp_setup_proxy(struct lxc_seccomp
*seccomp
,
136 struct lxc_epoll_descr
*descr
,
137 struct lxc_handler
*handler
)
142 static inline int lxc_seccomp_send_notifier_fd(struct lxc_seccomp
*seccomp
,
148 static inline int lxc_seccomp_recv_notifier_fd(struct lxc_seccomp
*seccomp
,
154 static inline int lxc_seccomp_add_notifier(const char *name
, const char *lxcpath
,
155 struct lxc_seccomp
*seccomp
)
160 static inline int lxc_seccomp_get_notify_fd(struct lxc_seccomp
*seccomp
)
165 #endif /* HAVE_SECCOMP */
166 #endif /* __LXC_LXCSECCOMP_H */