| 1 |
.TH "seccomp_syscall_resolve_name" 3 "8 May 2014" "[email protected]" "libseccomp Documentation" |
| 2 |
.\" ////////////////////////////////////////////////////////////////////////// |
| 3 |
.SH NAME |
| 4 |
.\" ////////////////////////////////////////////////////////////////////////// |
| 5 |
seccomp_syscall_resolve_name \- Resolve a syscall name |
| 6 |
.\" ////////////////////////////////////////////////////////////////////////// |
| 7 |
.SH SYNOPSIS |
| 8 |
.\" ////////////////////////////////////////////////////////////////////////// |
| 9 |
.nf |
| 10 |
.B #include <seccomp.h> |
| 11 |
.sp |
| 12 |
.BI "int seccomp_syscall_resolve_name(const char *" name ");" |
| 13 |
.BI "int seccomp_syscall_resolve_name_arch(uint32_t " arch_token "," |
| 14 |
.BI " const char *" name ");" |
| 15 |
.BI "int seccomp_syscall_resolve_name_rewrite(uint32_t " arch_token "," |
| 16 |
.BI " const char *" name ");" |
| 17 |
.BI "char *seccomp_syscall_resolve_num_arch(uint32_t " arch_token ", int " num ");" |
| 18 |
.sp |
| 19 |
Link with \fI\-lseccomp\fP. |
| 20 |
.fi |
| 21 |
.\" ////////////////////////////////////////////////////////////////////////// |
| 22 |
.SH DESCRIPTION |
| 23 |
.\" ////////////////////////////////////////////////////////////////////////// |
| 24 |
.P |
| 25 |
The |
| 26 |
.BR seccomp_syscall_resolve_name() , |
| 27 |
.BR seccomp_syscall_resolve_name_arch() , |
| 28 |
and |
| 29 |
.BR seccomp_syscall_resolve_name_rewrite() |
| 30 |
functions resolve the commonly used syscall name to the syscall number used by |
| 31 |
the kernel and the rest of the libseccomp API, with |
| 32 |
.BR seccomp_syscall_resolve_name_rewrite() |
| 33 |
rewriting the syscall number for architectures that modify the syscall. Syscall |
| 34 |
rewriting typically happens in case of a multiplexed syscall, like |
| 35 |
.BR socketcall (2) |
| 36 |
or |
| 37 |
.BR ipc (2) |
| 38 |
on x86. |
| 39 |
.BR seccomp_syscall_resolve_num_arch() |
| 40 |
function resolves the syscall number used by the kernel to the commonly used |
| 41 |
syscall name. |
| 42 |
.P |
| 43 |
The caller is responsible for freeing the returned string from |
| 44 |
.BR seccomp_syscall_resolve_num_arch() . |
| 45 |
.\" ////////////////////////////////////////////////////////////////////////// |
| 46 |
.SH RETURN VALUE |
| 47 |
.\" ////////////////////////////////////////////////////////////////////////// |
| 48 |
.P |
| 49 |
In the case of |
| 50 |
.BR seccomp_syscall_resolve_name() , |
| 51 |
.BR seccomp_syscall_resolve_name_arch() , |
| 52 |
and |
| 53 |
.BR seccomp_syscall_resolve_name_rewrite() |
| 54 |
the associated syscall number is returned, with the negative pseudo syscall |
| 55 |
number being returned in cases where the given syscall does not exist for the |
| 56 |
architecture. The value |
| 57 |
.BR __NR_SCMP_ERROR |
| 58 |
is returned in case of error. In all cases, the return value is suitable for |
| 59 |
use in any libseccomp API function which requires the syscall number, examples include |
| 60 |
.BR seccomp_rule_add () |
| 61 |
and |
| 62 |
.BR seccomp_rule_add_exact (). |
| 63 |
.P |
| 64 |
In the case of |
| 65 |
.BR seccomp_syscall_resolve_num_arch() |
| 66 |
the associated syscall name is returned and it remains the callers |
| 67 |
responsibility to free the returned string via |
| 68 |
.BR free (3). |
| 69 |
.\" ////////////////////////////////////////////////////////////////////////// |
| 70 |
.SH EXAMPLES |
| 71 |
.\" ////////////////////////////////////////////////////////////////////////// |
| 72 |
.nf |
| 73 |
#include <seccomp.h> |
| 74 |
|
| 75 |
int main(int argc, char *argv[]) |
| 76 |
{ |
| 77 |
int rc = \-1; |
| 78 |
scmp_filter_ctx ctx; |
| 79 |
|
| 80 |
ctx = seccomp_init(SCMP_ACT_KILL); |
| 81 |
if (ctx == NULL) |
| 82 |
goto out; |
| 83 |
|
| 84 |
/* ... */ |
| 85 |
|
| 86 |
rc = seccomp_rule_add(ctx, SCMP_ACT_ALLOW, |
| 87 |
seccomp_syscall_resolve_name("open"), 0); |
| 88 |
if (rc < 0) |
| 89 |
goto out; |
| 90 |
|
| 91 |
/* ... */ |
| 92 |
|
| 93 |
rc = seccomp_load(ctx); |
| 94 |
if (rc < 0) |
| 95 |
goto out; |
| 96 |
|
| 97 |
/* ... */ |
| 98 |
|
| 99 |
out: |
| 100 |
seccomp_release(ctx); |
| 101 |
return \-rc; |
| 102 |
} |
| 103 |
.fi |
| 104 |
.\" ////////////////////////////////////////////////////////////////////////// |
| 105 |
.SH NOTES |
| 106 |
.\" ////////////////////////////////////////////////////////////////////////// |
| 107 |
.P |
| 108 |
In case of bare syscalls implemented on top of a multiplexed syscall, |
| 109 |
.BR seccomp_syscall_resolve_name() |
| 110 |
and |
| 111 |
.BR seccomp_syscall_resolve_name_arch() |
| 112 |
can be used to verify if a bare syscall is implemented for a specific |
| 113 |
architecture, while |
| 114 |
.BR seccomp_syscall_resolve_name_rewrite() |
| 115 |
can be used to determine the underlying multiplexed syscall. |
| 116 |
.P |
| 117 |
While the seccomp filter can be generated independent of the kernel, kernel |
| 118 |
support is required to load and enforce the seccomp filter generated by |
| 119 |
libseccomp. |
| 120 |
.P |
| 121 |
The libseccomp project site, with more information and the source code |
| 122 |
repository, can be found at https://github.com/seccomp/libseccomp. This tool, |
| 123 |
as well as the libseccomp library, is currently under development, please |
| 124 |
report any bugs at the project site or directly to the author. |
| 125 |
.\" ////////////////////////////////////////////////////////////////////////// |
| 126 |
.SH AUTHOR |
| 127 |
.\" ////////////////////////////////////////////////////////////////////////// |
| 128 |
Paul Moore <[email protected]> |
| 129 |
.\" ////////////////////////////////////////////////////////////////////////// |
| 130 |
.SH SEE ALSO |
| 131 |
.\" ////////////////////////////////////////////////////////////////////////// |
| 132 |
.BR seccomp_rule_add (3), |
| 133 |
.BR seccomp_rule_add_exact (3) |