Bundle libseccomp 2.3.1
[linux-seccomp.git] / libseccomp / doc / man / man3 / seccomp_attr_set.3
CommitLineData
8befd5cc
MG
1.TH "seccomp_attr_set" 3 "21 August 2014" "paul@paul-moore.com" "libseccomp Documentation"
2.\" //////////////////////////////////////////////////////////////////////////
3.SH NAME
4.\" //////////////////////////////////////////////////////////////////////////
5seccomp_attr_set, seccomp_attr_get \- Manage the seccomp filter attributes
6.\" //////////////////////////////////////////////////////////////////////////
7.SH SYNOPSIS
8.\" //////////////////////////////////////////////////////////////////////////
9.nf
10.B #include <seccomp.h>
11.sp
12.B typedef void * scmp_filter_ctx;
13.B enum scmp_filter_attr;
14.sp
15.BI "int seccomp_attr_set(scmp_filter_ctx " ctx ","
16.BI " enum scmp_filter_attr " attr ", uint32_t " value ");"
17.BI "int seccomp_attr_get(scmp_filter_ctx " ctx ","
18.BI " enum scmp_filter_attr " attr ", uint32_t *" value ");"
19.sp
20Link with \fI\-lseccomp\fP.
21.fi
22.\" //////////////////////////////////////////////////////////////////////////
23.SH DESCRIPTION
24.\" //////////////////////////////////////////////////////////////////////////
25.P
26The
27.BR seccomp_attr_set ()
28function sets the different seccomp filter attributes while the
29.BR seccomp_attr_get ()
30function fetches the filter attributes. The seccomp filter attributes are
31tunable values that affect how the library behaves when generating and loading
32the seccomp filter into the kernel. The attributes are reset to their default
33values whenever the filter is initialized or reset via
34.BR seccomp_filter_init (3)
35or
36.BR seccomp_filter_reset (3).
37.P
38The filter context
39.I ctx
40is the value returned by the call to
41.BR seccomp_init (3).
42.P
43Valid
44.I attr
45values are as follows:
46.TP
47.B SCMP_FLTATR_ACT_DEFAULT
48The default filter action as specified in the call to
49.BR seccomp_filter_init (3)
50or
51.BR seccomp_filter_reset (3).
52This attribute is read-only.
53.TP
54.B SCMP_FLTATR_ACT_BADARCH
55The filter action taken when the loaded filter does not match the architecture
56of the executing application. Defaults to the
57.B SCMP_ACT_KILL
58action.
59.TP
60.B SCMP_FLTATR_CTL_NNP
61A flag to specify if the NO_NEW_PRIVS functionality should be enabled before
62loading the seccomp filter into the kernel. If set to off (
63.I value
64== 0) then loading the seccomp filter into the kernel will fail if CAP_SYS_ADMIN
65is not set. Defaults to on (
66.I value
67== 1).
68.TP
69.B SCMP_FLTATR_CTL_TSYNC
70A flag to specify if the kernel should attempt to synchronize the filters
71across all threads on
72.BR seccomp_load (3).
73If the kernel is unable to synchronize all of the thread then the load
74operation will fail. This flag is only available on Linux Kernel 3.17 or
75greater; attempting to enable this flag on earlier kernels will result in an
76error being returned. Defaults to off (
77.I value
78== 0).
79.\" //////////////////////////////////////////////////////////////////////////
80.SH RETURN VALUE
81.\" //////////////////////////////////////////////////////////////////////////
82Returns zero on success, negative errno values on failure.
83.\" //////////////////////////////////////////////////////////////////////////
84.SH EXAMPLES
85.\" //////////////////////////////////////////////////////////////////////////
86.nf
87#include <seccomp.h>
88
89int main(int argc, char *argv[])
90{
91 int rc = \-1;
92 scmp_filter_ctx ctx;
93
94 ctx = seccomp_init(SCMP_ACT_ALLOW);
95 if (ctx == NULL)
96 goto out;
97
98 /* ... */
99
100 rc = seccomp_attr_set(ctx, SCMP_FLTATR_ACT_BADARCH, SCMP_ACT_TRAP);
101 if (rc < 0)
102 goto out;
103
104 /* ... */
105
106out:
107 seccomp_release(ctx);
108 return \-rc;
109}
110.fi
111.\" //////////////////////////////////////////////////////////////////////////
112.SH NOTES
113.\" //////////////////////////////////////////////////////////////////////////
114.P
115While the seccomp filter can be generated independent of the kernel, kernel
116support is required to load and enforce the seccomp filter generated by
117libseccomp.
118.P
119The libseccomp project site, with more information and the source code
120repository, can be found at https://github.com/seccomp/libseccomp. This tool,
121as well as the libseccomp library, is currently under development, please
122report any bugs at the project site or directly to the author.
123.\" //////////////////////////////////////////////////////////////////////////
124.SH AUTHOR
125.\" //////////////////////////////////////////////////////////////////////////
126Paul Moore <paul@paul-moore.com>
127.\" //////////////////////////////////////////////////////////////////////////
128.SH SEE ALSO
129.\" //////////////////////////////////////////////////////////////////////////
130.BR seccomp_init (3),
131.BR seccomp_reset (3),
132.BR seccomp_load (3)
This page took 0.015778 seconds and 4 git commands to generate.