€•Œsphinx.addnodes”Œdocument”“”)�”}”(Œ rawsource”Œ”Œchildren”]”(Œ translations”Œ LanguagesNode”“”)�”}”(hhh]”(hŒ pending_xref”“”)�”}”(hhh]”Œdocutils.nodes”ŒText”“”ŒChinese (Simplified)”…”�”}”Œparent”hsbaŒ attributes”}”(Œids”]”Œclasses”]”Œnames”]”Œdupnames”]”Œbackrefs”]”Œ refdomain”Œstd”Œreftype”Œdoc”Œ reftarget”Œ0/translations/zh_CN/userspace-api/seccomp_filter”Œmodname”NŒ classname”NŒ refexplicit”ˆuŒtagname”hhh ubh)�”}”(hhh]”hŒChinese (Traditional)”…”�”}”hh2sbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ0/translations/zh_TW/userspace-api/seccomp_filter”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)�”}”(hhh]”hŒItalian”…”�”}”hhFsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ0/translations/it_IT/userspace-api/seccomp_filter”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)�”}”(hhh]”hŒJapanese”…”�”}”hhZsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ0/translations/ja_JP/userspace-api/seccomp_filter”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)�”}”(hhh]”hŒKorean”…”�”}”hhnsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ0/translations/ko_KR/userspace-api/seccomp_filter”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)�”}”(hhh]”hŒPortuguese (Brazilian)”…”�”}”hh‚sbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ0/translations/pt_BR/userspace-api/seccomp_filter”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)�”}”(hhh]”hŒSpanish”…”�”}”hh–sbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ0/translations/sp_SP/userspace-api/seccomp_filter”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubeh}”(h]”h ]”h"]”h$]”h&]”Œcurrent_language”ŒEnglish”uh1h hhŒ _document”hŒsource”NŒline”NubhŒsection”“”)�”}”(hhh]”(hŒtitle”“”)�”}”(hŒ+Seccomp BPF (SECure COMPuting with filters)”h]”hŒ+Seccomp BPF (SECure COMPuting with filters)”…”�”}”(hh¼h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhh·h²hh³ŒJ/var/lib/git/docbuild/linux/Documentation/userspace-api/seccomp_filter.rst”h´Kubh¶)�”}”(hhh]”(h»)�”}”(hŒ Introduction”h]”hŒ Introduction”…”�”}”(hhÎh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhhËh²hh³hÊh´KubhŒ paragraph”“”)�”}”(hXÄA large number of system calls are exposed to every userland process with many of them going unused for the entire lifetime of the process. As system calls change and mature, bugs are found and eradicated. A certain subset of userland applications benefit by having a reduced set of available system calls. The resulting set reduces the total kernel surface exposed to the application. System call filtering is meant for use with those applications.”h]”hXÄA large number of system calls are exposed to every userland process with many of them going unused for the entire lifetime of the process. As system calls change and mature, bugs are found and eradicated. A certain subset of userland applications benefit by having a reduced set of available system calls. The resulting set reduces the total kernel surface exposed to the application. System call filtering is meant for use with those applications.”…”�”}”(hhÞh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´KhhËh²hubhÝ)�”}”(hXßSeccomp filtering provides a means for a process to specify a filter for incoming system calls. The filter is expressed as a Berkeley Packet Filter (BPF) program, as with socket filters, except that the data operated on is related to the system call being made: system call number and the system call arguments. This allows for expressive filtering of system calls using a filter program language with a long history of being exposed to userland and a straightforward data set.”h]”hXßSeccomp filtering provides a means for a process to specify a filter for incoming system calls. The filter is expressed as a Berkeley Packet Filter (BPF) program, as with socket filters, except that the data operated on is related to the system call being made: system call number and the system call arguments. This allows for expressive filtering of system calls using a filter program language with a long history of being exposed to userland and a straightforward data set.”…”�”}”(hhìh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´KhhËh²hubhÝ)�”}”(hX/Additionally, BPF makes it impossible for users of seccomp to fall prey to time-of-check-time-of-use (TOCTOU) attacks that are common in system call interposition frameworks. BPF programs may not dereference pointers which constrains all filters to solely evaluating the system call arguments directly.”h]”hX/Additionally, BPF makes it impossible for users of seccomp to fall prey to time-of-check-time-of-use (TOCTOU) attacks that are common in system call interposition frameworks. BPF programs may not dereference pointers which constrains all filters to solely evaluating the system call arguments directly.”…”�”}”(hhúh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´KhhËh²hubeh}”(h]”Œ introduction”ah ]”h"]”Œ introduction”ah$]”h&]”uh1hµhh·h²hh³hÊh´Kubh¶)�”}”(hhh]”(h»)�”}”(hŒ What it isn't”h]”hŒWhat it isn’t”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhjh²hh³hÊh´KubhÝ)�”}”(hXtSystem call filtering isn't a sandbox. It provides a clearly defined mechanism for minimizing the exposed kernel surface. It is meant to be a tool for sandbox developers to use. Beyond that, policy for logical behavior and information flow should be managed with a combination of other system hardening techniques and, potentially, an LSM of your choosing. Expressive, dynamic filters provide further options down this path (avoiding pathological sizes or selecting which of the multiplexed system calls in socketcall() is allowed, for instance) which could be construed, incorrectly, as a more complete sandboxing solution.”h]”hXvSystem call filtering isn’t a sandbox. It provides a clearly defined mechanism for minimizing the exposed kernel surface. It is meant to be a tool for sandbox developers to use. Beyond that, policy for logical behavior and information flow should be managed with a combination of other system hardening techniques and, potentially, an LSM of your choosing. Expressive, dynamic filters provide further options down this path (avoiding pathological sizes or selecting which of the multiplexed system calls in socketcall() is allowed, for instance) which could be construed, incorrectly, as a more complete sandboxing solution.”…”�”}”(hj!h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´K!hjh²hubeh}”(h]”Œ what-it-isn-t”ah ]”h"]”Œ what it isn't”ah$]”h&]”uh1hµhh·h²hh³hÊh´Kubh¶)�”}”(hhh]”(h»)�”}”(hŒUsage”h]”hŒUsage”…”�”}”(hj:h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhj7h²hh³hÊh´K,ubhÝ)�”}”(hŒÈAn additional seccomp mode is added and is enabled using the same prctl(2) call as the strict seccomp. If the architecture has ``CONFIG_HAVE_ARCH_SECCOMP_FILTER``, then filters may be added as below:”h]”(hŒ€An additional seccomp mode is added and is enabled using the same prctl(2) call as the strict seccomp. If the architecture has ”…”�”}”(hjHh²hh³Nh´NubhŒliteral”“”)�”}”(hŒ#``CONFIG_HAVE_ARCH_SECCOMP_FILTER``”h]”hŒCONFIG_HAVE_ARCH_SECCOMP_FILTER”…”�”}”(hjRh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jPhjHubhŒ%, then filters may be added as below:”…”�”}”(hjHh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´K.hj7h²hubhŒdefinition_list”“”)�”}”(hhh]”hŒdefinition_list_item”“”)�”}”(hX``PR_SET_SECCOMP``: Now takes an additional argument which specifies a new filter using a BPF program. The BPF program will be executed over struct seccomp_data reflecting the system call number, arguments, and other metadata. The BPF program must then return one of the acceptable values to inform the kernel which action should be taken. Usage:: prctl(PR_SET_SECCOMP, SECCOMP_MODE_FILTER, prog); The 'prog' argument is a pointer to a struct sock_fprog which will contain the filter program. If the program is invalid, the call will return -1 and set errno to ``EINVAL``. If ``fork``/``clone`` and ``execve`` are allowed by @prog, any child processes will be constrained to the same filters and system call ABI as the parent. Prior to use, the task must call ``prctl(PR_SET_NO_NEW_PRIVS, 1)`` or run with ``CAP_SYS_ADMIN`` privileges in its namespace. If these are not true, ``-EACCES`` will be returned. This requirement ensures that filter programs cannot be applied to child processes with greater privileges than the task that installed them. Additionally, if ``prctl(2)`` is allowed by the attached filter, additional filters may be layered on which will increase evaluation time, but allow for further decreasing the attack surface during execution of a process. ”h]”(hŒterm”“”)�”}”(hŒ``PR_SET_SECCOMP``:”h]”(jQ)�”}”(hŒ``PR_SET_SECCOMP``”h]”hŒPR_SET_SECCOMP”…”�”}”(hj{h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jPhjwubhŒ:”…”�”}”(hjwh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1juh³hÊh´KPhjqubhŒ definition”“”)�”}”(hhh]”(hÝ)�”}”(hX@Now takes an additional argument which specifies a new filter using a BPF program. The BPF program will be executed over struct seccomp_data reflecting the system call number, arguments, and other metadata. The BPF program must then return one of the acceptable values to inform the kernel which action should be taken.”h]”hX@Now takes an additional argument which specifies a new filter using a BPF program. The BPF program will be executed over struct seccomp_data reflecting the system call number, arguments, and other metadata. The BPF program must then return one of the acceptable values to inform the kernel which action should be taken.”…”�”}”(hj˜h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´K3hj•ubhÝ)�”}”(hŒUsage::”h]”hŒUsage:”…”�”}”(hj¦h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´K;hj•ubhŒ literal_block”“”)�”}”(hŒ1prctl(PR_SET_SECCOMP, SECCOMP_MODE_FILTER, prog);”h]”hŒ1prctl(PR_SET_SECCOMP, SECCOMP_MODE_FILTER, prog);”…”�”}”hj¶sbah}”(h]”h ]”h"]”h$]”h&]”Œ xml:space”Œpreserve”uh1j´h³hÊh´K=hj•ubhÝ)�”}”(hŒ¯The 'prog' argument is a pointer to a struct sock_fprog which will contain the filter program. If the program is invalid, the call will return -1 and set errno to ``EINVAL``.”h]”(hŒ¨The ‘prog’ argument is a pointer to a struct sock_fprog which will contain the filter program. If the program is invalid, the call will return -1 and set errno to ”…”�”}”(hjÆh²hh³Nh´NubjQ)�”}”(hŒ ``EINVAL``”h]”hŒEINVAL”…”�”}”(hjÎh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jPhjÆubhŒ.”…”�”}”(hjÆh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´K?hj•ubhÝ)�”}”(hŒ™If ``fork``/``clone`` and ``execve`` are allowed by @prog, any child processes will be constrained to the same filters and system call ABI as the parent.”h]”(hŒIf ”…”�”}”(hjæh²hh³Nh´NubjQ)�”}”(hŒ``fork``”h]”hŒfork”…”�”}”(hjîh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jPhjæubhŒ/”…”�”}”(hjæh²hh³Nh´NubjQ)�”}”(hŒ ``clone``”h]”hŒclone”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jPhjæubhŒ and ”…”�”}”(hjæh²hh³Nh´NubjQ)�”}”(hŒ ``execve``”h]”hŒexecve”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jPhjæubhŒu are allowed by @prog, any child processes will be constrained to the same filters and system call ABI as the parent.”…”�”}”(hjæh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´KChj•ubhÝ)�”}”(hXBPrior to use, the task must call ``prctl(PR_SET_NO_NEW_PRIVS, 1)`` or run with ``CAP_SYS_ADMIN`` privileges in its namespace. If these are not true, ``-EACCES`` will be returned. This requirement ensures that filter programs cannot be applied to child processes with greater privileges than the task that installed them.”h]”(hŒ!Prior to use, the task must call ”…”�”}”(hj*h²hh³Nh´NubjQ)�”}”(hŒ!``prctl(PR_SET_NO_NEW_PRIVS, 1)``”h]”hŒprctl(PR_SET_NO_NEW_PRIVS, 1)”…”�”}”(hj2h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jPhj*ubhŒ or run with ”…”�”}”(hj*h²hh³Nh´NubjQ)�”}”(hŒ``CAP_SYS_ADMIN``”h]”hŒ CAP_SYS_ADMIN”…”�”}”(hjDh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jPhj*ubhŒ6 privileges in its namespace. If these are not true, ”…”�”}”(hj*h²hh³Nh´NubjQ)�”}”(hŒ ``-EACCES``”h]”hŒ-EACCES”…”�”}”(hjVh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jPhj*ubhŒ¡ will be returned. This requirement ensures that filter programs cannot be applied to child processes with greater privileges than the task that installed them.”…”�”}”(hj*h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´KGhj•ubhÝ)�”}”(hŒÝAdditionally, if ``prctl(2)`` is allowed by the attached filter, additional filters may be layered on which will increase evaluation time, but allow for further decreasing the attack surface during execution of a process.”h]”(hŒAdditionally, if ”…”�”}”(hjnh²hh³Nh´NubjQ)�”}”(hŒ ``prctl(2)``”h]”hŒprctl(2)”…”�”}”(hjvh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jPhjnubhŒÀ is allowed by the attached filter, additional filters may be layered on which will increase evaluation time, but allow for further decreasing the attack surface during execution of a process.”…”�”}”(hjnh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´KMhj•ubeh}”(h]”h ]”h"]”h$]”h&]”uh1j“hjqubeh}”(h]”h ]”h"]”h$]”h&]”uh1joh³hÊh´KPhjlubah}”(h]”h ]”h"]”h$]”h&]”uh1jjhj7h²hh³hÊh´NubhÝ)�”}”(hŒ:The above call returns 0 on success and non-zero on error.”h]”hŒ:The above call returns 0 on success and non-zero on error.”…”�”}”(hj h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´KRhj7h²hubeh}”(h]”Œusage”ah ]”h"]”Œusage”ah$]”h&]”uh1hµhh·h²hh³hÊh´K,ubh¶)�”}”(hhh]”(h»)�”}”(hŒ Return values”h]”hŒ Return values”…”�”}”(hj¹h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhj¶h²hh³hÊh´KUubhÝ)�”}”(hXA seccomp filter may return any of the following values. If multiple filters exist, the return value for the evaluation of a given system call will always use the highest precedent value. (For example, ``SECCOMP_RET_KILL_PROCESS`` will always take precedence.)”h]”(hŒÊA seccomp filter may return any of the following values. If multiple filters exist, the return value for the evaluation of a given system call will always use the highest precedent value. (For example, ”…”�”}”(hjÇh²hh³Nh´NubjQ)�”}”(hŒ``SECCOMP_RET_KILL_PROCESS``”h]”hŒSECCOMP_RET_KILL_PROCESS”…”�”}”(hjÏh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jPhjÇubhŒ will always take precedence.)”…”�”}”(hjÇh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´KWhj¶h²hubhÝ)�”}”(hŒIn precedence order, they are:”h]”hŒIn precedence order, they are:”…”�”}”(hjçh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´K\hj¶h²hubjk)�”}”(hhh]”(jp)�”}”(hŒÉ``SECCOMP_RET_KILL_PROCESS``: Results in the entire process exiting immediately without executing the system call. The exit status of the task (``status & 0x7f``) will be ``SIGSYS``, not ``SIGKILL``. ”h]”(jv)�”}”(hŒ``SECCOMP_RET_KILL_PROCESS``:”h]”(jQ)�”}”(hŒ``SECCOMP_RET_KILL_PROCESS``”h]”hŒSECCOMP_RET_KILL_PROCESS”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jPhjüubhŒ:”…”�”}”(hjüh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1juh³hÊh´Kahjøubj”)�”}”(hhh]”hÝ)�”}”(hŒªResults in the entire process exiting immediately without executing the system call. The exit status of the task (``status & 0x7f``) will be ``SIGSYS``, not ``SIGKILL``.”h]”(hŒsResults in the entire process exiting immediately without executing the system call. The exit status of the task (”…”�”}”(hjh²hh³Nh´NubjQ)�”}”(hŒ``status & 0x7f``”h]”hŒ status & 0x7f”…”�”}”(hj#h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jPhjubhŒ ) will be ”…”�”}”(hjh²hh³Nh´NubjQ)�”}”(hŒ ``SIGSYS``”h]”hŒSIGSYS”…”�”}”(hj5h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jPhjubhŒ, not ”…”�”}”(hjh²hh³Nh´NubjQ)�”}”(hŒ ``SIGKILL``”h]”hŒSIGKILL”…”�”}”(hjGh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jPhjubhŒ.”…”�”}”(hjh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´K_hjubah}”(h]”h ]”h"]”h$]”h&]”uh1j“hjøubeh}”(h]”h ]”h"]”h$]”h&]”uh1joh³hÊh´Kahjõubjp)�”}”(hŒ¾``SECCOMP_RET_KILL_THREAD``: Results in the task exiting immediately without executing the system call. The exit status of the task (``status & 0x7f``) will be ``SIGSYS``, not ``SIGKILL``. ”h]”(jv)�”}”(hŒ``SECCOMP_RET_KILL_THREAD``:”h]”(jQ)�”}”(hŒ``SECCOMP_RET_KILL_THREAD``”h]”hŒSECCOMP_RET_KILL_THREAD”…”�”}”(hjsh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jPhjoubhŒ:”…”�”}”(hjoh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1juh³hÊh´Kfhjkubj”)�”}”(hhh]”hÝ)�”}”(hŒ Results in the task exiting immediately without executing the system call. The exit status of the task (``status & 0x7f``) will be ``SIGSYS``, not ``SIGKILL``.”h]”(hŒiResults in the task exiting immediately without executing the system call. The exit status of the task (”…”�”}”(hjŽh²hh³Nh´NubjQ)�”}”(hŒ``status & 0x7f``”h]”hŒ status & 0x7f”…”�”}”(hj–h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jPhjŽubhŒ ) will be ”…”�”}”(hjŽh²hh³Nh´NubjQ)�”}”(hŒ ``SIGSYS``”h]”hŒSIGSYS”…”�”}”(hj¨h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jPhjŽubhŒ, not ”…”�”}”(hjŽh²hh³Nh´NubjQ)�”}”(hŒ ``SIGKILL``”h]”hŒSIGKILL”…”�”}”(hjºh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jPhjŽubhŒ.”…”�”}”(hjŽh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´Kdhj‹ubah}”(h]”h ]”h"]”h$]”h&]”uh1j“hjkubeh}”(h]”h ]”h"]”h$]”h&]”uh1joh³hÊh´Kfhjõh²hubjp)�”}”(hX,``SECCOMP_RET_TRAP``: Results in the kernel sending a ``SIGSYS`` signal to the triggering task without executing the system call. ``siginfo->si_call_addr`` will show the address of the system call instruction, and ``siginfo->si_syscall`` and ``siginfo->si_arch`` will indicate which syscall was attempted. The program counter will be as though the syscall happened (i.e. it will not point to the syscall instruction). The return value register will contain an arch- dependent value -- if resuming execution, set it to something sensible. (The architecture dependency is because replacing it with ``-ENOSYS`` could overwrite some useful information.) The ``SECCOMP_RET_DATA`` portion of the return value will be passed as ``si_errno``. ``SIGSYS`` triggered by seccomp will have a si_code of ``SYS_SECCOMP``. ”h]”(jv)�”}”(hŒ``SECCOMP_RET_TRAP``:”h]”(jQ)�”}”(hŒ``SECCOMP_RET_TRAP``”h]”hŒSECCOMP_RET_TRAP”…”�”}”(hjæh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jPhjâubhŒ:”…”�”}”(hjâh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1juh³hÊh´KwhjÞubj”)�”}”(hhh]”(hÝ)�”}”(hXvResults in the kernel sending a ``SIGSYS`` signal to the triggering task without executing the system call. ``siginfo->si_call_addr`` will show the address of the system call instruction, and ``siginfo->si_syscall`` and ``siginfo->si_arch`` will indicate which syscall was attempted. The program counter will be as though the syscall happened (i.e. it will not point to the syscall instruction). The return value register will contain an arch- dependent value -- if resuming execution, set it to something sensible. (The architecture dependency is because replacing it with ``-ENOSYS`` could overwrite some useful information.)”h]”(hŒ Results in the kernel sending a ”…”�”}”(hjh²hh³Nh´NubjQ)�”}”(hŒ ``SIGSYS``”h]”hŒSIGSYS”…”�”}”(hj h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jPhjubhŒB signal to the triggering task without executing the system call. ”…”�”}”(hjh²hh³Nh´NubjQ)�”}”(hŒ``siginfo->si_call_addr``”h]”hŒsiginfo->si_call_addr”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jPhjubhŒ; will show the address of the system call instruction, and ”…”�”}”(hjh²hh³Nh´NubjQ)�”}”(hŒ``siginfo->si_syscall``”h]”hŒsiginfo->si_syscall”…”�”}”(hj-h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jPhjubhŒ and ”…”�”}”(hjh²hh³Nh´NubjQ)�”}”(hŒ``siginfo->si_arch``”h]”hŒsiginfo->si_arch”…”�”}”(hj?h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jPhjubhXQ will indicate which syscall was attempted. The program counter will be as though the syscall happened (i.e. it will not point to the syscall instruction). The return value register will contain an arch- dependent value -- if resuming execution, set it to something sensible. (The architecture dependency is because replacing it with ”…”�”}”(hjh²hh³Nh´NubjQ)�”}”(hŒ ``-ENOSYS``”h]”hŒ-ENOSYS”…”�”}”(hjQh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jPhjubhŒ* could overwrite some useful information.)”…”�”}”(hjh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´KihjþubhÝ)�”}”(hŒTThe ``SECCOMP_RET_DATA`` portion of the return value will be passed as ``si_errno``.”h]”(hŒThe ”…”�”}”(hjih²hh³Nh´NubjQ)�”}”(hŒ``SECCOMP_RET_DATA``”h]”hŒSECCOMP_RET_DATA”…”�”}”(hjqh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jPhjiubhŒ/ portion of the return value will be passed as ”…”�”}”(hjih²hh³Nh´NubjQ)�”}”(hŒ ``si_errno``”h]”hŒsi_errno”…”�”}”(hjƒh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jPhjiubhŒ.”…”�”}”(hjih²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´KthjþubhÝ)�”}”(hŒG``SIGSYS`` triggered by seccomp will have a si_code of ``SYS_SECCOMP``.”h]”(jQ)�”}”(hŒ ``SIGSYS``”h]”hŒSIGSYS”…”�”}”(hjŸh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jPhj›ubhŒ- triggered by seccomp will have a si_code of ”…”�”}”(hj›h²hh³Nh´NubjQ)�”}”(hŒ``SYS_SECCOMP``”h]”hŒ SYS_SECCOMP”…”�”}”(hj±h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jPhj›ubhŒ.”…”�”}”(hj›h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´Kwhjþubeh}”(h]”h ]”h"]”h$]”h&]”uh1j“hjÞubeh}”(h]”h ]”h"]”h$]”h&]”uh1joh³hÊh´Kwhjõh²hubjp)�”}”(hŒ‘``SECCOMP_RET_ERRNO``: Results in the lower 16-bits of the return value being passed to userland as the errno without executing the system call. ”h]”(jv)�”}”(hŒ``SECCOMP_RET_ERRNO``:”h]”(jQ)�”}”(hŒ``SECCOMP_RET_ERRNO``”h]”hŒSECCOMP_RET_ERRNO”…”�”}”(hjÝh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jPhjÙubhŒ:”…”�”}”(hjÙh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1juh³hÊh´K{hjÕubj”)�”}”(hhh]”hÝ)�”}”(hŒyResults in the lower 16-bits of the return value being passed to userland as the errno without executing the system call.”h]”hŒyResults in the lower 16-bits of the return value being passed to userland as the errno without executing the system call.”…”�”}”(hjøh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´Kzhjõubah}”(h]”h ]”h"]”h$]”h&]”uh1j“hjÕubeh}”(h]”h ]”h"]”h$]”h&]”uh1joh³hÊh´K{hjõh²hubjp)�”}”(hŒÞ``SECCOMP_RET_USER_NOTIF``: Results in a ``struct seccomp_notif`` message sent on the userspace notification fd, if it is attached, or ``-ENOSYS`` if it is not. See below on discussion of how to handle user notifications. ”h]”(jv)�”}”(hŒ``SECCOMP_RET_USER_NOTIF``:”h]”(jQ)�”}”(hŒ``SECCOMP_RET_USER_NOTIF``”h]”hŒSECCOMP_RET_USER_NOTIF”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jPhjubhŒ:”…”�”}”(hjh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1juh³hÊh´K€hjubj”)�”}”(hhh]”hÝ)�”}”(hŒÁResults in a ``struct seccomp_notif`` message sent on the userspace notification fd, if it is attached, or ``-ENOSYS`` if it is not. See below on discussion of how to handle user notifications.”h]”(hŒ Results in a ”…”�”}”(hj5h²hh³Nh´NubjQ)�”}”(hŒ``struct seccomp_notif``”h]”hŒstruct seccomp_notif”…”�”}”(hj=h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jPhj5ubhŒF message sent on the userspace notification fd, if it is attached, or ”…”�”}”(hj5h²hh³Nh´NubjQ)�”}”(hŒ ``-ENOSYS``”h]”hŒ-ENOSYS”…”�”}”(hjOh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jPhj5ubhŒK if it is not. See below on discussion of how to handle user notifications.”…”�”}”(hj5h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´K~hj2ubah}”(h]”h ]”h"]”h$]”h&]”uh1j“hjubeh}”(h]”h ]”h"]”h$]”h&]”uh1joh³hÊh´K€hjõh²hubjp)�”}”(hXu``SECCOMP_RET_TRACE``: When returned, this value will cause the kernel to attempt to notify a ``ptrace()``-based tracer prior to executing the system call. If there is no tracer present, ``-ENOSYS`` is returned to userland and the system call is not executed. A tracer will be notified if it requests ``PTRACE_O_TRACESECCOMP`` using ``ptrace(PTRACE_SETOPTIONS)``. The tracer will be notified of a ``PTRACE_EVENT_SECCOMP`` and the ``SECCOMP_RET_DATA`` portion of the BPF program return value will be available to the tracer via ``PTRACE_GETEVENTMSG``. The tracer can skip the system call by changing the syscall number to -1. Alternatively, the tracer can change the system call requested by changing the system call to a valid syscall number. If the tracer asks to skip the system call, then the system call will appear to return the value that the tracer puts in the return value register. The seccomp check will not be run again after the tracer is notified. (This means that seccomp-based sandboxes MUST NOT allow use of ptrace, even of other sandboxed processes, without extreme care; ptracers can use this mechanism to escape.) ”h]”(jv)�”}”(hŒ``SECCOMP_RET_TRACE``:”h]”(jQ)�”}”(hŒ``SECCOMP_RET_TRACE``”h]”hŒSECCOMP_RET_TRACE”…”�”}”(hj{h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jPhjwubhŒ:”…”�”}”(hjwh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1juh³hÊh´K˜hjsubj”)�”}”(hhh]”(hÝ)�”}”(hŒíWhen returned, this value will cause the kernel to attempt to notify a ``ptrace()``-based tracer prior to executing the system call. If there is no tracer present, ``-ENOSYS`` is returned to userland and the system call is not executed.”h]”(hŒGWhen returned, this value will cause the kernel to attempt to notify a ”…”�”}”(hj–h²hh³Nh´NubjQ)�”}”(hŒ ``ptrace()``”h]”hŒptrace()”…”�”}”(hjžh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jPhj–ubhŒR-based tracer prior to executing the system call. If there is no tracer present, ”…”�”}”(hj–h²hh³Nh´NubjQ)�”}”(hŒ ``-ENOSYS``”h]”hŒ-ENOSYS”…”�”}”(hj°h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jPhj–ubhŒ= is returned to userland and the system call is not executed.”…”�”}”(hj–h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´Kƒhj“ubhÝ)�”}”(hX#A tracer will be notified if it requests ``PTRACE_O_TRACESECCOMP`` using ``ptrace(PTRACE_SETOPTIONS)``. The tracer will be notified of a ``PTRACE_EVENT_SECCOMP`` and the ``SECCOMP_RET_DATA`` portion of the BPF program return value will be available to the tracer via ``PTRACE_GETEVENTMSG``.”h]”(hŒ)A tracer will be notified if it requests ”…”�”}”(hjÈh²hh³Nh´NubjQ)�”}”(hŒ``PTRACE_O_TRACESECCOMP``”h]”hŒPTRACE_O_TRACESECCOMP”…”�”}”(hjÐh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jPhjÈubhŒ using ”…”�”}”(hjÈh²hh³Nh´NubjQ)�”}”(hŒ``ptrace(PTRACE_SETOPTIONS)``”h]”hŒptrace(PTRACE_SETOPTIONS)”…”�”}”(hjâh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jPhjÈubhŒ$. The tracer will be notified of a ”…”�”}”(hjÈh²hh³Nh´NubjQ)�”}”(hŒ``PTRACE_EVENT_SECCOMP``”h]”hŒPTRACE_EVENT_SECCOMP”…”�”}”(hjôh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jPhjÈubhŒ and the ”…”�”}”(hjÈh²hh³Nh´NubjQ)�”}”(hŒ``SECCOMP_RET_DATA``”h]”hŒSECCOMP_RET_DATA”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jPhjÈubhŒM portion of the BPF program return value will be available to the tracer via ”…”�”}”(hjÈh²hh³Nh´NubjQ)�”}”(hŒ``PTRACE_GETEVENTMSG``”h]”hŒPTRACE_GETEVENTMSG”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jPhjÈubhŒ.”…”�”}”(hjÈh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´Kˆhj“ubhÝ)�”}”(hXUThe tracer can skip the system call by changing the syscall number to -1. Alternatively, the tracer can change the system call requested by changing the system call to a valid syscall number. If the tracer asks to skip the system call, then the system call will appear to return the value that the tracer puts in the return value register.”h]”hXUThe tracer can skip the system call by changing the syscall number to -1. Alternatively, the tracer can change the system call requested by changing the system call to a valid syscall number. If the tracer asks to skip the system call, then the system call will appear to return the value that the tracer puts in the return value register.”…”�”}”(hj0h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´KŽhj“ubhÝ)�”}”(hŒòThe seccomp check will not be run again after the tracer is notified. (This means that seccomp-based sandboxes MUST NOT allow use of ptrace, even of other sandboxed processes, without extreme care; ptracers can use this mechanism to escape.)”h]”hŒòThe seccomp check will not be run again after the tracer is notified. (This means that seccomp-based sandboxes MUST NOT allow use of ptrace, even of other sandboxed processes, without extreme care; ptracers can use this mechanism to escape.)”…”�”}”(hj>h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´K•hj“ubeh}”(h]”h ]”h"]”h$]”h&]”uh1j“hjsubeh}”(h]”h ]”h"]”h$]”h&]”uh1joh³hÊh´K˜hjõh²hubjp)�”}”(hXe``SECCOMP_RET_LOG``: Results in the system call being executed after it is logged. This should be used by application developers to learn which syscalls their application needs without having to iterate through multiple test and development cycles to build the list. This action will only be logged if "log" is present in the actions_logged sysctl string. ”h]”(jv)�”}”(hŒ``SECCOMP_RET_LOG``:”h]”(jQ)�”}”(hŒ``SECCOMP_RET_LOG``”h]”hŒSECCOMP_RET_LOG”…”�”}”(hj`h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jPhj\ubhŒ:”…”�”}”(hj\h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1juh³hÊh´K¡hjXubj”)�”}”(hhh]”(hÝ)�”}”(hŒõResults in the system call being executed after it is logged. This should be used by application developers to learn which syscalls their application needs without having to iterate through multiple test and development cycles to build the list.”h]”hŒõResults in the system call being executed after it is logged. This should be used by application developers to learn which syscalls their application needs without having to iterate through multiple test and development cycles to build the list.”…”�”}”(hj{h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´K›hjxubhÝ)�”}”(hŒXThis action will only be logged if "log" is present in the actions_logged sysctl string.”h]”hŒ\This action will only be logged if “logâ€� is present in the actions_logged sysctl string.”…”�”}”(hj‰h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´K hjxubeh}”(h]”h ]”h"]”h$]”h&]”uh1j“hjXubeh}”(h]”h ]”h"]”h$]”h&]”uh1joh³hÊh´K¡hjõh²hubjp)�”}”(hŒB``SECCOMP_RET_ALLOW``: Results in the system call being executed. ”h]”(jv)�”}”(hŒ``SECCOMP_RET_ALLOW``:”h]”(jQ)�”}”(hŒ``SECCOMP_RET_ALLOW``”h]”hŒSECCOMP_RET_ALLOW”…”�”}”(hj«h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jPhj§ubhŒ:”…”�”}”(hj§h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1juh³hÊh´K¤hj£ubj”)�”}”(hhh]”hÝ)�”}”(hŒ*Results in the system call being executed.”h]”hŒ*Results in the system call being executed.”…”�”}”(hjÆh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´K¤hjÃubah}”(h]”h ]”h"]”h$]”h&]”uh1j“hj£ubeh}”(h]”h ]”h"]”h$]”h&]”uh1joh³hÊh´K¤hjõh²hubeh}”(h]”h ]”h"]”h$]”h&]”uh1jjhj¶h²hh³hÊh´NubhÝ)�”}”(hŒ‚If multiple filters exist, the return value for the evaluation of a given system call will always use the highest precedent value.”h]”hŒ‚If multiple filters exist, the return value for the evaluation of a given system call will always use the highest precedent value.”…”�”}”(hjæh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´K¦hj¶h²hubhÝ)�”}”(hŒÙPrecedence is only determined using the ``SECCOMP_RET_ACTION`` mask. When multiple filters return values of the same precedence, only the ``SECCOMP_RET_DATA`` from the most recently installed filter will be returned.”h]”(hŒ(Precedence is only determined using the ”…”�”}”(hjôh²hh³Nh´NubjQ)�”}”(hŒ``SECCOMP_RET_ACTION``”h]”hŒSECCOMP_RET_ACTION”…”�”}”(hjüh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jPhjôubhŒM mask. When multiple filters return values of the same precedence, only the ”…”�”}”(hjôh²hh³Nh´NubjQ)�”}”(hŒ``SECCOMP_RET_DATA``”h]”hŒSECCOMP_RET_DATA”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jPhjôubhŒ: from the most recently installed filter will be returned.”…”�”}”(hjôh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´K©hj¶h²hubeh}”(h]”Œ return-values”ah ]”h"]”Œ return values”ah$]”h&]”uh1hµhh·h²hh³hÊh´KUubh¶)�”}”(hhh]”(h»)�”}”(hŒPitfalls”h]”hŒPitfalls”…”�”}”(hj1h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhj.h²hh³hÊh´K¯ubhÝ)�”}”(hX’The biggest pitfall to avoid during use is filtering on system call number without checking the architecture value. Why? On any architecture that supports multiple system call invocation conventions, the system call numbers may vary based on the specific invocation. If the numbers in the different calling conventions overlap, then checks in the filters may be abused. Always check the arch value!”h]”hX’The biggest pitfall to avoid during use is filtering on system call number without checking the architecture value. Why? On any architecture that supports multiple system call invocation conventions, the system call numbers may vary based on the specific invocation. If the numbers in the different calling conventions overlap, then checks in the filters may be abused. Always check the arch value!”…”�”}”(hj?h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´K±hj.h²hubeh}”(h]”Œpitfalls”ah ]”h"]”Œpitfalls”ah$]”h&]”uh1hµhh·h²hh³hÊh´K¯ubh¶)�”}”(hhh]”(h»)�”}”(hŒExample”h]”hŒExample”…”�”}”(hjXh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhjUh²hh³hÊh´K¹ubhÝ)�”}”(hŒ¡The ``samples/seccomp/`` directory contains both an x86-specific example and a more generic example of a higher level macro interface for BPF program generation.”h]”(hŒThe ”…”�”}”(hjfh²hh³Nh´NubjQ)�”}”(hŒ``samples/seccomp/``”h]”hŒsamples/seccomp/”…”�”}”(hjnh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jPhjfubhŒ‰ directory contains both an x86-specific example and a more generic example of a higher level macro interface for BPF program generation.”…”�”}”(hjfh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´K»hjUh²hubeh}”(h]”Œexample”ah ]”h"]”Œexample”ah$]”h&]”uh1hµhh·h²hh³hÊh´K¹ubh¶)�”}”(hhh]”(h»)�”}”(hŒUserspace Notification”h]”hŒUserspace Notification”…”�”}”(hj‘h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhjŽh²hh³hÊh´KÀubhÝ)�”}”(hX!The ``SECCOMP_RET_USER_NOTIF`` return code lets seccomp filters pass a particular syscall to userspace to be handled. This may be useful for applications like container managers, which wish to intercept particular syscalls (``mount()``, ``finit_module()``, etc.) and change their behavior.”h]”(hŒThe ”…”�”}”(hjŸh²hh³Nh´NubjQ)�”}”(hŒ``SECCOMP_RET_USER_NOTIF``”h]”hŒSECCOMP_RET_USER_NOTIF”…”�”}”(hj§h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jPhjŸubhŒÂ return code lets seccomp filters pass a particular syscall to userspace to be handled. This may be useful for applications like container managers, which wish to intercept particular syscalls (”…”�”}”(hjŸh²hh³Nh´NubjQ)�”}”(hŒ ``mount()``”h]”hŒmount()”…”�”}”(hj¹h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jPhjŸubhŒ, ”…”�”}”(hjŸh²hh³Nh´NubjQ)�”}”(hŒ``finit_module()``”h]”hŒfinit_module()”…”�”}”(hjËh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jPhjŸubhŒ", etc.) and change their behavior.”…”�”}”(hjŸh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´KÂhjŽh²hubhÝ)�”}”(hŒqTo acquire a notification FD, use the ``SECCOMP_FILTER_FLAG_NEW_LISTENER`` argument to the ``seccomp()`` syscall:”h]”(hŒ&To acquire a notification FD, use the ”…”�”}”(hjãh²hh³Nh´NubjQ)�”}”(hŒ$``SECCOMP_FILTER_FLAG_NEW_LISTENER``”h]”hŒ SECCOMP_FILTER_FLAG_NEW_LISTENER”…”�”}”(hjëh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jPhjãubhŒ argument to the ”…”�”}”(hjãh²hh³Nh´NubjQ)�”}”(hŒ ``seccomp()``”h]”hŒ seccomp()”…”�”}”(hjýh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jPhjãubhŒ syscall:”…”�”}”(hjãh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´KÇhjŽh²hubjµ)�”}”(hŒOfd = seccomp(SECCOMP_SET_MODE_FILTER, SECCOMP_FILTER_FLAG_NEW_LISTENER, &prog);”h]”hŒOfd = seccomp(SECCOMP_SET_MODE_FILTER, SECCOMP_FILTER_FLAG_NEW_LISTENER, &prog);”…”�”}”hjsbah}”(h]”h ]”h"]”h$]”h&]”jÄjÅŒforce”‰Œlanguage”Œc”Œhighlight_args”}”uh1j´h³hÊh´KÊhjŽh²hubhÝ)�”}”(hX”which (on success) will return a listener fd for the filter, which can then be passed around via ``SCM_RIGHTS`` or similar. Note that filter fds correspond to a particular filter, and not a particular task. So if this task then forks, notifications from both tasks will appear on the same filter fd. Reads and writes to/from a filter fd are also synchronized, so a filter fd can safely have many readers.”h]”(hŒawhich (on success) will return a listener fd for the filter, which can then be passed around via ”…”�”}”(hj(h²hh³Nh´NubjQ)�”}”(hŒ``SCM_RIGHTS``”h]”hŒ SCM_RIGHTS”…”�”}”(hj0h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jPhj(ubhX% or similar. Note that filter fds correspond to a particular filter, and not a particular task. So if this task then forks, notifications from both tasks will appear on the same filter fd. Reads and writes to/from a filter fd are also synchronized, so a filter fd can safely have many readers.”…”�”}”(hj(h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´KÎhjŽh²hubhÝ)�”}”(hŒGThe interface for a seccomp notification fd consists of two structures:”h]”hŒGThe interface for a seccomp notification fd consists of two structures:”…”�”}”(hjHh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´KÕhjŽh²hubjµ)�”}”(hX4struct seccomp_notif_sizes { __u16 seccomp_notif; __u16 seccomp_notif_resp; __u16 seccomp_data; }; struct seccomp_notif { __u64 id; __u32 pid; __u32 flags; struct seccomp_data data; }; struct seccomp_notif_resp { __u64 id; __s64 val; __s32 error; __u32 flags; };”h]”hX4struct seccomp_notif_sizes { __u16 seccomp_notif; __u16 seccomp_notif_resp; __u16 seccomp_data; }; struct seccomp_notif { __u64 id; __u32 pid; __u32 flags; struct seccomp_data data; }; struct seccomp_notif_resp { __u64 id; __s64 val; __s32 error; __u32 flags; };”…”�”}”hjVsbah}”(h]”h ]”h"]”h$]”h&]”jÄjÅj#‰j$j%j&}”uh1j´h³hÊh´K×hjŽh²hubhÝ)�”}”(hŒÙThe ``struct seccomp_notif_sizes`` structure can be used to determine the size of the various structures used in seccomp notifications. The size of ``struct seccomp_data`` may change in the future, so code should use:”h]”(hŒThe ”…”�”}”(hjeh²hh³Nh´NubjQ)�”}”(hŒ``struct seccomp_notif_sizes``”h]”hŒstruct seccomp_notif_sizes”…”�”}”(hjmh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jPhjeubhŒr structure can be used to determine the size of the various structures used in seccomp notifications. The size of ”…”�”}”(hjeh²hh³Nh´NubjQ)�”}”(hŒ``struct seccomp_data``”h]”hŒstruct seccomp_data”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jPhjeubhŒ. may change in the future, so code should use:”…”�”}”(hjeh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´KíhjŽh²hubjµ)�”}”(hŒNstruct seccomp_notif_sizes sizes; seccomp(SECCOMP_GET_NOTIF_SIZES, 0, &sizes);”h]”hŒNstruct seccomp_notif_sizes sizes; seccomp(SECCOMP_GET_NOTIF_SIZES, 0, &sizes);”…”�”}”hj—sbah}”(h]”h ]”h"]”h$]”h&]”jÄjÅj#‰j$j%j&}”uh1j´h³hÊh´KñhjŽh²hubhÝ)�”}”(hŒlto determine the size of the various structures to allocate. See samples/seccomp/user-trap.c for an example.”h]”hŒlto determine the size of the various structures to allocate. See samples/seccomp/user-trap.c for an example.”…”�”}”(hj¦h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´KöhjŽh²hubhÝ)�”}”(hX Users can read via ``ioctl(SECCOMP_IOCTL_NOTIF_RECV)`` (or ``poll()``) on a seccomp notification fd to receive a ``struct seccomp_notif``, which contains five members: the input length of the structure, a unique-per-filter ``id``, the ``pid`` of the task which triggered this request (which may be 0 if the task is in a pid ns not visible from the listener's pid namespace). The notification also contains the ``data`` passed to seccomp, and a filters flag. The structure should be zeroed out prior to calling the ioctl.”h]”(hŒUsers can read via ”…”�”}”(hj´h²hh³Nh´NubjQ)�”}”(hŒ#``ioctl(SECCOMP_IOCTL_NOTIF_RECV)``”h]”hŒioctl(SECCOMP_IOCTL_NOTIF_RECV)”…”�”}”(hj¼h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jPhj´ubhŒ (or ”…”�”}”(hj´h²hh³Nh´NubjQ)�”}”(hŒ ``poll()``”h]”hŒpoll()”…”�”}”(hjÎh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jPhj´ubhŒ,) on a seccomp notification fd to receive a ”…”�”}”(hj´h²hh³Nh´NubjQ)�”}”(hŒ``struct seccomp_notif``”h]”hŒstruct seccomp_notif”…”�”}”(hjàh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jPhj´ubhŒV, which contains five members: the input length of the structure, a unique-per-filter ”…”�”}”(hj´h²hh³Nh´NubjQ)�”}”(hŒ``id``”h]”hŒid”…”�”}”(hjòh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jPhj´ubhŒ, the ”…”�”}”(hj´h²hh³Nh´NubjQ)�”}”(hŒ``pid``”h]”hŒpid”…”�”}”(hj h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jPhj´ubhŒª of the task which triggered this request (which may be 0 if the task is in a pid ns not visible from the listener’s pid namespace). The notification also contains the ”…”�”}”(hj´h²hh³Nh´NubjQ)�”}”(hŒ``data``”h]”hŒdata”…”�”}”(hj h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jPhj´ubhŒf passed to seccomp, and a filters flag. The structure should be zeroed out prior to calling the ioctl.”…”�”}”(hj´h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´KùhjŽh²hubhÝ)�”}”(hX Userspace can then make a decision based on this information about what to do, and ``ioctl(SECCOMP_IOCTL_NOTIF_SEND)`` a response, indicating what should be returned to userspace. The ``id`` member of ``struct seccomp_notif_resp`` should be the same ``id`` as in ``struct seccomp_notif``.”h]”(hŒSUserspace can then make a decision based on this information about what to do, and ”…”�”}”(hj. h²hh³Nh´NubjQ)�”}”(hŒ#``ioctl(SECCOMP_IOCTL_NOTIF_SEND)``”h]”hŒioctl(SECCOMP_IOCTL_NOTIF_SEND)”…”�”}”(hj6 h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jPhj. ubhŒB a response, indicating what should be returned to userspace. The ”…”�”}”(hj. h²hh³Nh´NubjQ)�”}”(hŒ``id``”h]”hŒid”…”�”}”(hjH h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jPhj. ubhŒ member of ”…”�”}”(hj. h²hh³Nh´NubjQ)�”}”(hŒ``struct seccomp_notif_resp``”h]”hŒstruct seccomp_notif_resp”…”�”}”(hjZ h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jPhj. ubhŒ should be the same ”…”�”}”(hj. h²hh³Nh´NubjQ)�”}”(hŒ``id``”h]”hŒid”…”�”}”(hjl h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jPhj. ubhŒ as in ”…”�”}”(hj. h²hh³Nh´NubjQ)�”}”(hŒ``struct seccomp_notif``”h]”hŒstruct seccomp_notif”…”�”}”(hj~ h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jPhj. ubhŒ.”…”�”}”(hj. h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´MhjŽh²hubhÝ)�”}”(hXUserspace can also add file descriptors to the notifying process via ``ioctl(SECCOMP_IOCTL_NOTIF_ADDFD)``. The ``id`` member of ``struct seccomp_notif_addfd`` should be the same ``id`` as in ``struct seccomp_notif``. The ``newfd_flags`` flag may be used to set flags like O_CLOEXEC on the file descriptor in the notifying process. If the supervisor wants to inject the file descriptor with a specific number, the ``SECCOMP_ADDFD_FLAG_SETFD`` flag can be used, and set the ``newfd`` member to the specific number to use. If that file descriptor is already open in the notifying process it will be replaced. The supervisor can also add an FD, and respond atomically by using the ``SECCOMP_ADDFD_FLAG_SEND`` flag and the return value will be the injected file descriptor number.”h]”(hŒEUserspace can also add file descriptors to the notifying process via ”…”�”}”(hj– h²hh³Nh´NubjQ)�”}”(hŒ$``ioctl(SECCOMP_IOCTL_NOTIF_ADDFD)``”h]”hŒ ioctl(SECCOMP_IOCTL_NOTIF_ADDFD)”…”�”}”(hjž h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jPhj– ubhŒ. The ”…”�”}”(hj– h²hh³Nh´NubjQ)�”}”(hŒ``id``”h]”hŒid”…”�”}”(hj° h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jPhj– ubhŒ member of ”…”�”}”(hj– h²hh³Nh´NubjQ)�”}”(hŒ``struct seccomp_notif_addfd``”h]”hŒstruct seccomp_notif_addfd”…”�”}”(hj h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jPhj– ubhŒ should be the same ”…”�”}”(hj– h²hh³Nh´NubjQ)�”}”(hŒ``id``”h]”hŒid”…”�”}”(hjÔ h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jPhj– ubhŒ as in ”…”�”}”(hj– h²hh³Nh´NubjQ)�”}”(hŒ``struct seccomp_notif``”h]”hŒstruct seccomp_notif”…”�”}”(hjæ h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jPhj– ubhŒ. The ”…”�”}”hj– sbjQ)�”}”(hŒ``newfd_flags``”h]”hŒ newfd_flags”…”�”}”(hjø h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jPhj– ubhŒ± flag may be used to set flags like O_CLOEXEC on the file descriptor in the notifying process. If the supervisor wants to inject the file descriptor with a specific number, the ”…”�”}”(hj– h²hh³Nh´NubjQ)�”}”(hŒ``SECCOMP_ADDFD_FLAG_SETFD``”h]”hŒSECCOMP_ADDFD_FLAG_SETFD”…”�”}”(hj h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jPhj– ubhŒ flag can be used, and set the ”…”�”}”(hj– h²hh³Nh´NubjQ)�”}”(hŒ ``newfd``”h]”hŒnewfd”…”�”}”(hj h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jPhj– ubhŒÄ member to the specific number to use. If that file descriptor is already open in the notifying process it will be replaced. The supervisor can also add an FD, and respond atomically by using the ”…”�”}”(hj– h²hh³Nh´NubjQ)�”}”(hŒ``SECCOMP_ADDFD_FLAG_SEND``”h]”hŒSECCOMP_ADDFD_FLAG_SEND”…”�”}”(hj. h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jPhj– ubhŒG flag and the return value will be the injected file descriptor number.”…”�”}”(hj– h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´MhjŽh²hubhÝ)�”}”(hXeThe notifying process can be preempted, resulting in the notification being aborted. This can be problematic when trying to take actions on behalf of the notifying process that are long-running and typically retryable (mounting a filesystem). Alternatively, at filter installation time, the ``SECCOMP_FILTER_FLAG_WAIT_KILLABLE_RECV`` flag can be set. This flag makes it such that when a user notification is received by the supervisor, the notifying process will ignore non-fatal signals until the response is sent. Signals that are sent prior to the notification being received by userspace are handled normally.”h]”(hX#The notifying process can be preempted, resulting in the notification being aborted. This can be problematic when trying to take actions on behalf of the notifying process that are long-running and typically retryable (mounting a filesystem). Alternatively, at filter installation time, the ”…”�”}”(hjF h²hh³Nh´NubjQ)�”}”(hŒ*``SECCOMP_FILTER_FLAG_WAIT_KILLABLE_RECV``”h]”hŒ&SECCOMP_FILTER_FLAG_WAIT_KILLABLE_RECV”…”�”}”(hjN h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jPhjF ubhX flag can be set. This flag makes it such that when a user notification is received by the supervisor, the notifying process will ignore non-fatal signals until the response is sent. Signals that are sent prior to the notification being received by userspace are handled normally.”…”�”}”(hjF h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´MhjŽh²hubhÝ)�”}”(hXIt is worth noting that ``struct seccomp_data`` contains the values of register arguments to the syscall, but does not contain pointers to memory. The task's memory is accessible to suitably privileged traces via ``ptrace()`` or ``/proc/pid/mem``. However, care should be taken to avoid the TOCTOU mentioned above in this document: all arguments being read from the tracee's memory should be read into the tracer's memory before any policy decisions are made. This allows for an atomic decision on syscall arguments.”h]”(hŒIt is worth noting that ”…”�”}”(hjf h²hh³Nh´NubjQ)�”}”(hŒ``struct seccomp_data``”h]”hŒstruct seccomp_data”…”�”}”(hjn h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jPhjf ubhŒ¨ contains the values of register arguments to the syscall, but does not contain pointers to memory. The task’s memory is accessible to suitably privileged traces via ”…”�”}”(hjf h²hh³Nh´NubjQ)�”}”(hŒ ``ptrace()``”h]”hŒptrace()”…”�”}”(hj€ h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jPhjf ubhŒ or ”…”�”}”(hjf h²hh³Nh´NubjQ)�”}”(hŒ``/proc/pid/mem``”h]”hŒ /proc/pid/mem”…”�”}”(hj’ h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jPhjf ubhX. However, care should be taken to avoid the TOCTOU mentioned above in this document: all arguments being read from the tracee’s memory should be read into the tracer’s memory before any policy decisions are made. This allows for an atomic decision on syscall arguments.”…”�”}”(hjf h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´MhjŽh²hubeh}”(h]”Œuserspace-notification”ah ]”h"]”Œuserspace notification”ah$]”h&]”uh1hµhh·h²hh³hÊh´KÀubh¶)�”}”(hhh]”(h»)�”}”(hŒSysctls”h]”hŒSysctls”…”�”}”(hjµ h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhj² h²hh³hÊh´M%ubhÝ)�”}”(hŒˆSeccomp's sysctl files can be found in the ``/proc/sys/kernel/seccomp/`` directory. Here's a description of each file in that directory:”h]”(hŒ-Seccomp’s sysctl files can be found in the ”…”�”}”(hjà h²hh³Nh´NubjQ)�”}”(hŒ``/proc/sys/kernel/seccomp/``”h]”hŒ/proc/sys/kernel/seccomp/”…”�”}”(hjË h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jPhjà ubhŒB directory. Here’s a description of each file in that directory:”…”�”}”(hjà h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´M'hj² h²hubjk)�”}”(hhh]”(jp)�”}”(hX ``actions_avail``: A read-only ordered list of seccomp return values (refer to the ``SECCOMP_RET_*`` macros above) in string form. The ordering, from left-to-right, is the least permissive return value to the most permissive return value. The list represents the set of seccomp return values supported by the kernel. A userspace program may use this list to determine if the actions found in the ``seccomp.h``, when the program was built, differs from the set of actions actually supported in the current running kernel. ”h]”(jv)�”}”(hŒ``actions_avail``:”h]”(jQ)�”}”(hŒ``actions_avail``”h]”hŒ actions_avail”…”�”}”(hjî h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jPhjê ubhŒ:”…”�”}”(hjê h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1juh³hÊh´M4hjæ ubj”)�”}”(hhh]”(hÝ)�”}”(hŒÛA read-only ordered list of seccomp return values (refer to the ``SECCOMP_RET_*`` macros above) in string form. The ordering, from left-to-right, is the least permissive return value to the most permissive return value.”h]”(hŒ@A read-only ordered list of seccomp return values (refer to the ”…”�”}”(hj h²hh³Nh´NubjQ)�”}”(hŒ``SECCOMP_RET_*``”h]”hŒ SECCOMP_RET_*”…”�”}”(hj h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jPhj ubhŒŠ macros above) in string form. The ordering, from left-to-right, is the least permissive return value to the most permissive return value.”…”�”}”(hj h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´M+hj ubhÝ)�”}”(hXThe list represents the set of seccomp return values supported by the kernel. A userspace program may use this list to determine if the actions found in the ``seccomp.h``, when the program was built, differs from the set of actions actually supported in the current running kernel.”h]”(hŒ�The list represents the set of seccomp return values supported by the kernel. A userspace program may use this list to determine if the actions found in the ”…”�”}”(hj) h²hh³Nh´NubjQ)�”}”(hŒ ``seccomp.h``”h]”hŒ seccomp.h”…”�”}”(hj1 h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jPhj) ubhŒo, when the program was built, differs from the set of actions actually supported in the current running kernel.”…”�”}”(hj) h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´M0hj ubeh}”(h]”h ]”h"]”h$]”h&]”uh1j“hjæ ubeh}”(h]”h ]”h"]”h$]”h&]”uh1joh³hÊh´M4hjã ubjp)�”}”(hXö``actions_logged``: A read-write ordered list of seccomp return values (refer to the ``SECCOMP_RET_*`` macros above) that are allowed to be logged. Writes to the file do not need to be in ordered form but reads from the file will be ordered in the same way as the actions_avail sysctl. The ``allow`` string is not accepted in the ``actions_logged`` sysctl as it is not possible to log ``SECCOMP_RET_ALLOW`` actions. Attempting to write ``allow`` to the sysctl will result in an EINVAL being returned. ”h]”(jv)�”}”(hŒ``actions_logged``:”h]”(jQ)�”}”(hŒ``actions_logged``”h]”hŒactions_logged”…”�”}”(hj] h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jPhjY ubhŒ:”…”�”}”(hjY h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1juh³hÊh´M?hjU ubj”)�”}”(hhh]”(hÝ)�”}”(hX A read-write ordered list of seccomp return values (refer to the ``SECCOMP_RET_*`` macros above) that are allowed to be logged. Writes to the file do not need to be in ordered form but reads from the file will be ordered in the same way as the actions_avail sysctl.”h]”(hŒAA read-write ordered list of seccomp return values (refer to the ”…”�”}”(hjx h²hh³Nh´NubjQ)�”}”(hŒ``SECCOMP_RET_*``”h]”hŒ SECCOMP_RET_*”…”�”}”(hj€ h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jPhjx ubhŒ· macros above) that are allowed to be logged. Writes to the file do not need to be in ordered form but reads from the file will be ordered in the same way as the actions_avail sysctl.”…”�”}”(hjx h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´M7hju ubhÝ)�”}”(hŒÖThe ``allow`` string is not accepted in the ``actions_logged`` sysctl as it is not possible to log ``SECCOMP_RET_ALLOW`` actions. Attempting to write ``allow`` to the sysctl will result in an EINVAL being returned.”h]”(hŒThe ”…”�”}”(hj˜ h²hh³Nh´NubjQ)�”}”(hŒ ``allow``”h]”hŒallow”…”�”}”(hj  h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jPhj˜ ubhŒ string is not accepted in the ”…”�”}”(hj˜ h²hh³Nh´NubjQ)�”}”(hŒ``actions_logged``”h]”hŒactions_logged”…”�”}”(hj² h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jPhj˜ ubhŒ% sysctl as it is not possible to log ”…”�”}”(hj˜ h²hh³Nh´NubjQ)�”}”(hŒ``SECCOMP_RET_ALLOW``”h]”hŒSECCOMP_RET_ALLOW”…”�”}”(hjÄ h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jPhj˜ ubhŒ actions. Attempting to write ”…”�”}”(hj˜ h²hh³Nh´NubjQ)�”}”(hŒ ``allow``”h]”hŒallow”…”�”}”(hjÖ h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jPhj˜ ubhŒ7 to the sysctl will result in an EINVAL being returned.”…”�”}”(hj˜ h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´M<hju ubeh}”(h]”h ]”h"]”h$]”h&]”uh1j“hjU ubeh}”(h]”h ]”h"]”h$]”h&]”uh1joh³hÊh´M?hjã h²hubeh}”(h]”h ]”h"]”h$]”h&]”uh1jjhj² h²hh³hÊh´Nubeh}”(h]”Œsysctls”ah ]”h"]”Œsysctls”ah$]”h&]”uh1hµhh·h²hh³hÊh´M%ubh¶)�”}”(hhh]”(h»)�”}”(hŒAdding architecture support”h]”hŒAdding architecture support”…”�”}”(hj h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhj h²hh³hÊh´MBubhÝ)�”}”(hXKSee ``arch/Kconfig`` for the authoritative requirements. In general, if an architecture supports both ptrace_event and seccomp, it will be able to support seccomp filter with minor fixup: ``SIGSYS`` support and seccomp return value checking. Then it must just add ``CONFIG_HAVE_ARCH_SECCOMP_FILTER`` to its arch-specific Kconfig.”h]”(hŒSee ”…”�”}”(hj h²hh³Nh´NubjQ)�”}”(hŒ``arch/Kconfig``”h]”hŒ arch/Kconfig”…”�”}”(hj! h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jPhj ubhŒ© for the authoritative requirements. In general, if an architecture supports both ptrace_event and seccomp, it will be able to support seccomp filter with minor fixup: ”…”�”}”(hj h²hh³Nh´NubjQ)�”}”(hŒ ``SIGSYS``”h]”hŒSIGSYS”…”�”}”(hj3 h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jPhj ubhŒC support and seccomp return value checking. Then it must just add ”…”�”}”(hj h²hh³Nh´NubjQ)�”}”(hŒ#``CONFIG_HAVE_ARCH_SECCOMP_FILTER``”h]”hŒCONFIG_HAVE_ARCH_SECCOMP_FILTER”…”�”}”(hjE h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jPhj ubhŒ to its arch-specific Kconfig.”…”�”}”(hj h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´MDhj h²hubeh}”(h]”Œadding-architecture-support”ah ]”h"]”Œadding architecture support”ah$]”h&]”uh1hµhh·h²hh³hÊh´MBubh¶)�”}”(hhh]”(h»)�”}”(hŒCaveats”h]”hŒCaveats”…”�”}”(hjh h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhje h²hh³hÊh´MMubhÝ)�”}”(hXIThe vDSO can cause some system calls to run entirely in userspace, leading to surprises when you run programs on different machines that fall back to real syscalls. To minimize these surprises on x86, make sure you test with ``/sys/devices/system/clocksource/clocksource0/current_clocksource`` set to something like ``acpi_pm``.”h]”(hŒâThe vDSO can cause some system calls to run entirely in userspace, leading to surprises when you run programs on different machines that fall back to real syscalls. To minimize these surprises on x86, make sure you test with ”…”�”}”(hjv h²hh³Nh´NubjQ)�”}”(hŒD``/sys/devices/system/clocksource/clocksource0/current_clocksource``”h]”hŒ@/sys/devices/system/clocksource/clocksource0/current_clocksource”…”�”}”(hj~ h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jPhjv ubhŒ set to something like ”…”�”}”(hjv h²hh³Nh´NubjQ)�”}”(hŒ ``acpi_pm``”h]”hŒacpi_pm”…”�”}”(hj� h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jPhjv ubhŒ.”…”�”}”(hjv h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´MOhje h²hubhÝ)�”}”(hŒ¬On x86-64, vsyscall emulation is enabled by default. (vsyscalls are legacy variants on vDSO calls.) Currently, emulated vsyscalls will honor seccomp, with a few oddities:”h]”hŒ¬On x86-64, vsyscall emulation is enabled by default. (vsyscalls are legacy variants on vDSO calls.) Currently, emulated vsyscalls will honor seccomp, with a few oddities:”…”�”}”(hj¨ h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´MVhje h²hubhŒ bullet_list”“”)�”}”(hhh]”(hŒ list_item”“”)�”}”(hX¨A return value of ``SECCOMP_RET_TRAP`` will set a ``si_call_addr`` pointing to the vsyscall entry for the given call and not the address after the 'syscall' instruction. Any code which wants to restart the call should be aware that (a) a ret instruction has been emulated and (b) trying to resume the syscall will again trigger the standard vsyscall emulation security checks, making resuming the syscall mostly pointless. ”h]”hÝ)�”}”(hX§A return value of ``SECCOMP_RET_TRAP`` will set a ``si_call_addr`` pointing to the vsyscall entry for the given call and not the address after the 'syscall' instruction. Any code which wants to restart the call should be aware that (a) a ret instruction has been emulated and (b) trying to resume the syscall will again trigger the standard vsyscall emulation security checks, making resuming the syscall mostly pointless.”h]”(hŒA return value of ”…”�”}”(hjÁ h²hh³Nh´NubjQ)�”}”(hŒ``SECCOMP_RET_TRAP``”h]”hŒSECCOMP_RET_TRAP”…”�”}”(hjÉ h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jPhjÁ ubhŒ will set a ”…”�”}”(hjÁ h²hh³Nh´NubjQ)�”}”(hŒ``si_call_addr``”h]”hŒ si_call_addr”…”�”}”(hjÛ h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jPhjÁ ubhXi pointing to the vsyscall entry for the given call and not the address after the ‘syscall’ instruction. Any code which wants to restart the call should be aware that (a) a ret instruction has been emulated and (b) trying to resume the syscall will again trigger the standard vsyscall emulation security checks, making resuming the syscall mostly pointless.”…”�”}”(hjÁ h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´MZhj½ ubah}”(h]”h ]”h"]”h$]”h&]”uh1j» hj¸ h²hh³hÊh´Nubj¼ )�”}”(hX}A return value of ``SECCOMP_RET_TRACE`` will signal the tracer as usual, but the syscall may not be changed to another system call using the orig_rax register. It may only be changed to -1 order to skip the currently emulated call. Any other change MAY terminate the process. The rip value seen by the tracer will be the syscall entry address; this is different from normal behavior. The tracer MUST NOT modify rip or rsp. (Do not rely on other changes terminating the process. They might work. For example, on some kernels, choosing a syscall that only exists in future kernels will be correctly emulated (by returning ``-ENOSYS``). ”h]”hÝ)�”}”(hX|A return value of ``SECCOMP_RET_TRACE`` will signal the tracer as usual, but the syscall may not be changed to another system call using the orig_rax register. It may only be changed to -1 order to skip the currently emulated call. Any other change MAY terminate the process. The rip value seen by the tracer will be the syscall entry address; this is different from normal behavior. The tracer MUST NOT modify rip or rsp. (Do not rely on other changes terminating the process. They might work. For example, on some kernels, choosing a syscall that only exists in future kernels will be correctly emulated (by returning ``-ENOSYS``).”h]”(hŒA return value of ”…”�”}”(hjý h²hh³Nh´NubjQ)�”}”(hŒ``SECCOMP_RET_TRACE``”h]”hŒSECCOMP_RET_TRACE”…”�”}”(hj h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jPhjý ubhXH will signal the tracer as usual, but the syscall may not be changed to another system call using the orig_rax register. It may only be changed to -1 order to skip the currently emulated call. Any other change MAY terminate the process. The rip value seen by the tracer will be the syscall entry address; this is different from normal behavior. The tracer MUST NOT modify rip or rsp. (Do not rely on other changes terminating the process. They might work. For example, on some kernels, choosing a syscall that only exists in future kernels will be correctly emulated (by returning ”…”�”}”(hjý h²hh³Nh´NubjQ)�”}”(hŒ ``-ENOSYS``”h]”hŒ-ENOSYS”…”�”}”(hj h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jPhjý ubhŒ).”…”�”}”(hjý h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´Mbhjù ubah}”(h]”h ]”h"]”h$]”h&]”uh1j» hj¸ h²hh³hÊh´Nubeh}”(h]”h ]”h"]”h$]”h&]”Œbullet”Œ-”uh1j¶ h³hÊh´MZhje h²hubhÝ)�”}”(hX¥To detect this quirky behavior, check for ``addr & ~0x0C00 == 0xFFFFFFFFFF600000``. (For ``SECCOMP_RET_TRACE``, use rip. For ``SECCOMP_RET_TRAP``, use ``siginfo->si_call_addr``.) Do not check any other condition: future kernels may improve vsyscall emulation and current kernels in vsyscall=native mode will behave differently, but the instructions at ``0xF...F600{0,4,8,C}00`` will not be system calls in these cases.”h]”(hŒ*To detect this quirky behavior, check for ”…”�”}”(hj= h²hh³Nh´NubjQ)�”}”(hŒ(``addr & ~0x0C00 == 0xFFFFFFFFFF600000``”h]”hŒ$addr & ~0x0C00 == 0xFFFFFFFFFF600000”…”�”}”(hjE h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jPhj= ubhŒ. (For ”…”�”}”(hj= h²hh³Nh´NubjQ)�”}”(hŒ``SECCOMP_RET_TRACE``”h]”hŒSECCOMP_RET_TRACE”…”�”}”(hjW h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jPhj= ubhŒ, use rip. For ”…”�”}”(hj= h²hh³Nh´NubjQ)�”}”(hŒ``SECCOMP_RET_TRAP``”h]”hŒSECCOMP_RET_TRAP”…”�”}”(hji h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jPhj= ubhŒ, use ”…”�”}”(hj= h²hh³Nh´NubjQ)�”}”(hŒ``siginfo->si_call_addr``”h]”hŒsiginfo->si_call_addr”…”�”}”(hj{ h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jPhj= ubhŒ±.) Do not check any other condition: future kernels may improve vsyscall emulation and current kernels in vsyscall=native mode will behave differently, but the instructions at ”…”�”}”(hj= h²hh³Nh´NubjQ)�”}”(hŒ``0xF...F600{0,4,8,C}00``”h]”hŒ0xF...F600{0,4,8,C}00”…”�”}”(hj� h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jPhj= ubhŒ) will not be system calls in these cases.”…”�”}”(hj= h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´Mmhje h²hubhÝ)�”}”(hŒýNote that modern systems are unlikely to use vsyscalls at all -- they are a legacy feature and they are considerably slower than standard syscalls. New code will use the vDSO, and vDSO-issued system calls are indistinguishable from normal system calls.”h]”hŒýNote that modern systems are unlikely to use vsyscalls at all -- they are a legacy feature and they are considerably slower than standard syscalls. New code will use the vDSO, and vDSO-issued system calls are indistinguishable from normal system calls.”…”�”•× }”(hj¥ h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÜh³hÊh´Muhje h²hubeh}”(h]”Œcaveats”ah ]”h"]”Œcaveats”ah$]”h&]”uh1hµhh·h²hh³hÊh´MMubeh}”(h]”Œ)seccomp-bpf-secure-computing-with-filters”ah ]”h"]”Œ+seccomp bpf (secure computing with filters)”ah$]”h&]”uh1hµhhh²hh³hÊh´Kubeh}”(h]”h ]”h"]”h$]”h&]”Œsource”hÊuh1hŒcurrent_source”NŒ current_line”NŒsettings”Œdocutils.frontend”ŒValues”“”)�”}”(hºNŒ generator”NŒ datestamp”NŒ source_link”NŒ source_url”NŒ toc_backlinks”Œentry”Œfootnote_backlinks”KŒ sectnum_xform”KŒstrip_comments”NŒstrip_elements_with_classes”NŒ strip_classes”NŒ report_level”KŒ halt_level”KŒexit_status_level”KŒdebug”NŒwarning_stream”NŒ traceback”ˆŒinput_encoding”Œ utf-8-sig”Œinput_encoding_error_handler”Œstrict”Œoutput_encoding”Œutf-8”Œoutput_encoding_error_handler”jæ Œerror_encoding”Œutf-8”Œerror_encoding_error_handler”Œbackslashreplace”Œ language_code”Œen”Œrecord_dependencies”NŒconfig”NŒ id_prefix”hŒauto_id_prefix”Œid”Œ dump_settings”NŒdump_internals”NŒdump_transforms”NŒdump_pseudo_xml”NŒexpose_internals”NŒstrict_visitor”NŒ_disable_config”NŒ_source”hÊŒ _destination”NŒ _config_files”]”Œ7/var/lib/git/docbuild/linux/Documentation/docutils.conf”aŒfile_insertion_enabled”ˆŒ raw_enabled”KŒline_length_limit”M'Œpep_references”NŒ pep_base_url”Œhttps://peps.python.org/”Œpep_file_url_template”Œpep-%04d”Œrfc_references”NŒ rfc_base_url”Œ&https://datatracker.ietf.org/doc/html/”Œ tab_width”KŒtrim_footnote_reference_space”‰Œsyntax_highlight”Œlong”Œ smart_quotes”ˆŒsmartquotes_locales”]”Œcharacter_level_inline_markup”‰Œdoctitle_xform”‰Œ docinfo_xform”KŒsectsubtitle_xform”‰Œ image_loading”Œlink”Œembed_stylesheet”‰Œcloak_email_addresses”ˆŒsection_self_link”‰Œenv”NubŒreporter”NŒindirect_targets”]”Œsubstitution_defs”}”Œsubstitution_names”}”Œrefnames”}”Œrefids”}”Œnameids”}”(jÀ j½ j j j4j1j³j°j+j(jRjOj‹jˆj¯ j¬ j j jb j_ j¸ jµ uŒ nametypes”}”(jÀ ‰j ‰j4‰j³‰j+‰jR‰j‹‰j¯ ‰j ‰jb ‰j¸ ‰uh}”(j½ h·j hËj1jj°j7j(j¶jOj.jˆjUj¬ jŽj j² j_ j jµ je uŒ footnote_refs”}”Œ citation_refs”}”Œ autofootnotes”]”Œautofootnote_refs”]”Œsymbol_footnotes”]”Œsymbol_footnote_refs”]”Œ footnotes”]”Œ citations”]”Œautofootnote_start”KŒsymbol_footnote_start”KŒ id_counter”Œ collections”ŒCounter”“”}”…”R”Œparse_messages”]”Œtransform_messages”]”Œ transformer”NŒ include_log”]”Œ decoration”Nh²hub.