#ifdef HAVE_LINUX_SECCOMP_H
# include <linux/seccomp.h>
#endif
-
-#ifndef SECCOMP_SET_MODE_STRICT
-# define SECCOMP_SET_MODE_STRICT 1
-#endif
-#ifndef SECCOMP_SET_MODE_FILTER
-# define SECCOMP_SET_MODE_FILTER 1
-#endif
#include "xlat/seccomp_ops.h"
-
-#ifndef SECCOMP_FILTER_FLAG_TSYNC
-# define SECCOMP_FILTER_FLAG_TSYNC 1
-#endif
#include "xlat/seccomp_filter_flags.h"
#ifdef HAVE_LINUX_FILTER_H
decode_fprog(struct tcb *tcp, unsigned short len, unsigned long addr)
{
if (!len || abbrev(tcp)) {
- tprintf("{len = %u, filter = %#lx}", len, addr);
+ tprintf("{len = %u, filter = ", len);
+ printaddr(addr);
+ tprints("}");
} else {
unsigned int i = 0;
}
}
+#include "seccomp_fprog.h"
+
void
print_seccomp_filter(struct tcb *tcp, unsigned long addr)
{
- if (addr) {
-#if SUPPORTED_PERSONALITIES > 1 && SIZEOF_LONG > 4
- if (current_wordsize == 4) {
- struct {
- unsigned short len;
- uint32_t filter;
- } fprog;
- if (umove(tcp, addr, &fprog) < 0)
- tprintf("%#lx", addr);
- else
- decode_fprog(tcp, fprog.len, fprog.filter);
- } else {
-#endif
- struct {
- unsigned short len;
- unsigned long filter;
- } fprog;
- if (umove(tcp, addr, &fprog) < 0)
- tprintf("%#lx", addr);
- else
- decode_fprog(tcp, fprog.len, fprog.filter);
-#if SUPPORTED_PERSONALITIES > 1 && SIZEOF_LONG > 4
- }
-#endif
- } else {
- tprints("NULL");
- }
+ struct seccomp_fprog fprog;
+
+ if (fetch_seccomp_fprog(tcp, addr, &fprog))
+ decode_fprog(tcp, fprog.len, fprog.filter);
}
static void
decode_seccomp_set_mode_strict(unsigned int flags, unsigned long addr)
{
tprintf("%u, ", flags);
- if (addr)
- tprintf("%#lx", addr);
- else
- tprints("NULL");
+ printaddr(addr);
}
-int
-sys_seccomp(struct tcb *tcp)
+SYS_FUNC(seccomp)
{
- if (entering(tcp)) {
- unsigned int op = tcp->u_arg[0];
+ unsigned int op = tcp->u_arg[0];
- printxval(seccomp_ops, op, "SECCOMP_SET_MODE_???");
- tprints(", ");
+ printxval(seccomp_ops, op, "SECCOMP_SET_MODE_???");
+ tprints(", ");
- if (op == SECCOMP_SET_MODE_FILTER) {
- printflags(seccomp_filter_flags, tcp->u_arg[1],
- "SECCOMP_FILTER_FLAG_???");
- tprints(", ");
- print_seccomp_filter(tcp, tcp->u_arg[2]);
- } else {
- decode_seccomp_set_mode_strict(tcp->u_arg[1],
- tcp->u_arg[2]);
- }
+ if (op == SECCOMP_SET_MODE_FILTER) {
+ printflags(seccomp_filter_flags, tcp->u_arg[1],
+ "SECCOMP_FILTER_FLAG_???");
+ tprints(", ");
+ print_seccomp_filter(tcp, tcp->u_arg[2]);
+ } else {
+ decode_seccomp_set_mode_strict(tcp->u_arg[1],
+ tcp->u_arg[2]);
}
- return 0;
+
+ return RVAL_DECODED;
}