2 * Decoder of seccomp filter programs.
4 * Copyright (c) 2015-2018 Dmitry V. Levin <ldv@altlinux.org>
7 * SPDX-License-Identifier: LGPL-2.1-or-later
12 #include "bpf_filter.h"
14 #include <linux/filter.h>
15 #ifdef HAVE_LINUX_SECCOMP_H
16 # include <linux/seccomp.h>
18 #ifndef SECCOMP_RET_ACTION_FULL
19 # define SECCOMP_RET_ACTION_FULL 0xffff0000U
21 #include "xlat/seccomp_ret_action.h"
24 print_seccomp_filter_k(const struct bpf_filter_block *const fp)
26 if (BPF_CLASS(fp->code) == BPF_RET) {
27 unsigned int action = SECCOMP_RET_ACTION_FULL & fp->k;
28 unsigned int data = fp->k & ~action;
30 printxval(seccomp_ret_action, action, "SECCOMP_RET_???");
32 tprintf("|%#x", data);
41 print_seccomp_fprog(struct tcb *const tcp, const kernel_ulong_t addr,
42 const unsigned short len)
44 print_bpf_fprog(tcp, addr, len, print_seccomp_filter_k);
48 decode_seccomp_fprog(struct tcb *const tcp, const kernel_ulong_t addr)
50 decode_bpf_fprog(tcp, addr, print_seccomp_filter_k);