summaryrefslogtreecommitdiffstats
path: root/jail/seccomp-inject.h
blob: a4618fb530d2d899d0db05c73daf268d9f0e0a24 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/*
 * Copyright (C) 2026 Daniel Golle <daniel@makrotopia.org>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License version 2.1
 * as published by the Free Software Foundation
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 */
#ifndef _JAIL_SECCOMP_INJECT_H_
#define _JAIL_SECCOMP_INJECT_H_

#include <sys/types.h>
#include <linux/filter.h>

struct seccomp_bp {
	unsigned long addr;
	unsigned char saved[16];
	unsigned char len;
	unsigned char armed;
};

#ifdef SECCOMP_SUPPORT
int seccomp_inject(pid_t pid, struct sock_fprog *prog);
int seccomp_run_to_entry(pid_t pid);
int seccomp_run_to_main(pid_t pid);
int seccomp_run_to_main_from_entry(pid_t pid);
int seccomp_read_syscall(pid_t pid, long *nr, long *args);
int seccomp_marker_addrs(pid_t pid, unsigned long *at_entry, unsigned long *lsm, int *main_argidx);
int seccomp_bp_arm(pid_t pid, unsigned long addr, struct seccomp_bp *bp);
int seccomp_bp_match(pid_t pid, struct seccomp_bp **bps, int n);
int seccomp_force_errno(pid_t pid, int err);
int seccomp_force_errno_exit(pid_t pid, int err);
#else
static inline int seccomp_inject(pid_t pid, struct sock_fprog *prog) {
	return -1;
}
static inline int seccomp_run_to_entry(pid_t pid) {
	return -1;
}
static inline int seccomp_run_to_main(pid_t pid) {
	return -1;
}
static inline int seccomp_run_to_main_from_entry(pid_t pid) {
	return -1;
}
static inline int seccomp_read_syscall(pid_t pid, long *nr, long *args) {
	return -1;
}
static inline int seccomp_marker_addrs(pid_t pid, unsigned long *at_entry, unsigned long *lsm, int *main_argidx) {
	return -1;
}
static inline int seccomp_bp_arm(pid_t pid, unsigned long addr, struct seccomp_bp *bp) {
	return -1;
}
static inline int seccomp_bp_match(pid_t pid, struct seccomp_bp **bps, int n) {
	return -1;
}
static inline int seccomp_force_errno(pid_t pid, int err) {
	return -1;
}
static inline int seccomp_force_errno_exit(pid_t pid, int err) {
	return -1;
}
#endif

#endif