€•¦mŒ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”Œ*/translations/zh_CN/bpf/prog_cgroup_sysctl”Œmodname”NŒ classname”NŒ refexplicit”ˆuŒtagname”hhh ubh)�”}”(hhh]”hŒChinese (Traditional)”…”�”}”hh2sbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ*/translations/zh_TW/bpf/prog_cgroup_sysctl”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)�”}”(hhh]”hŒItalian”…”�”}”hhFsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ*/translations/it_IT/bpf/prog_cgroup_sysctl”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)�”}”(hhh]”hŒJapanese”…”�”}”hhZsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ*/translations/ja_JP/bpf/prog_cgroup_sysctl”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)�”}”(hhh]”hŒKorean”…”�”}”hhnsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ*/translations/ko_KR/bpf/prog_cgroup_sysctl”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)�”}”(hhh]”hŒPortuguese (Brazilian)”…”�”}”hh‚sbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ*/translations/pt_BR/bpf/prog_cgroup_sysctl”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)�”}”(hhh]”hŒSpanish”…”�”}”hh–sbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ*/translations/sp_SP/bpf/prog_cgroup_sysctl”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubeh}”(h]”h ]”h"]”h$]”h&]”Œcurrent_language”ŒEnglish”uh1h hhŒ _document”hŒsource”NŒline”NubhŒcomment”“”)�”}”(hŒ3SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause)”h]”hŒ3SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause)”…”�”}”hh·sbah}”(h]”h ]”h"]”h$]”h&]”Œ xml:space”Œpreserve”uh1hµhhh²hh³ŒD/var/lib/git/docbuild/linux/Documentation/bpf/prog_cgroup_sysctl.rst”h´KubhŒsection”“”)�”}”(hhh]”(hŒtitle”“”)�”}”(hŒBPF_PROG_TYPE_CGROUP_SYSCTL”h]”hŒBPF_PROG_TYPE_CGROUP_SYSCTL”…”�”}”(hhÏh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÍhhÊh²hh³hÇh´KubhŒ paragraph”“”)�”}”(hŒnThis document describes ``BPF_PROG_TYPE_CGROUP_SYSCTL`` program type that provides cgroup-bpf hook for sysctl.”h]”(hŒThis document describes ”…”�”}”(hhßh²hh³Nh´NubhŒliteral”“”)�”}”(hŒ``BPF_PROG_TYPE_CGROUP_SYSCTL``”h]”hŒBPF_PROG_TYPE_CGROUP_SYSCTL”…”�”}”(hhéh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hçhhßubhŒ7 program type that provides cgroup-bpf hook for sysctl.”…”�”}”(hhßh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÝh³hÇh´KhhÊh²hubhÞ)�”}”(hŒ–The hook has to be attached to a cgroup and will be called every time a process inside that cgroup tries to read from or write to sysctl knob in proc.”h]”hŒ–The hook has to be attached to a cgroup and will be called every time a process inside that cgroup tries to read from or write to sysctl knob in proc.”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÝh³hÇh´K hhÊh²hubhÉ)�”}”(hhh]”(hÎ)�”}”(hŒ1. Attach type”h]”hŒ1. Attach type”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÍhjh²hh³hÇh´KubhÞ)�”}”(hŒo``BPF_CGROUP_SYSCTL`` attach type has to be used to attach ``BPF_PROG_TYPE_CGROUP_SYSCTL`` program to a cgroup.”h]”(hè)�”}”(hŒ``BPF_CGROUP_SYSCTL``”h]”hŒBPF_CGROUP_SYSCTL”…”�”}”(hj$h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hçhj ubhŒ& attach type has to be used to attach ”…”�”}”(hj h²hh³Nh´Nubhè)�”}”(hŒ``BPF_PROG_TYPE_CGROUP_SYSCTL``”h]”hŒBPF_PROG_TYPE_CGROUP_SYSCTL”…”�”}”(hj6h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hçhj ubhŒ program to a cgroup.”…”�”}”(hj h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÝh³hÇh´Khjh²hubeh}”(h]”Œ attach-type”ah ]”h"]”Œ1. attach type”ah$]”h&]”uh1hÈhhÊh²hh³hÇh´KubhÉ)�”}”(hhh]”(hÎ)�”}”(hŒ 2. Context”h]”hŒ 2. Context”…”�”}”(hjYh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÍhjVh²hh³hÇh´KubhÞ)�”}”(hŒ[``BPF_PROG_TYPE_CGROUP_SYSCTL`` provides access to the following context from BPF program::”h]”(hè)�”}”(hŒ``BPF_PROG_TYPE_CGROUP_SYSCTL``”h]”hŒBPF_PROG_TYPE_CGROUP_SYSCTL”…”�”}”(hjkh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hçhjgubhŒ; provides access to the following context from BPF program:”…”�”}”(hjgh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÝh³hÇh´KhjVh²hubhŒ literal_block”“”)�”}”(hŒ;struct bpf_sysctl { __u32 write; __u32 file_pos; };”h]”hŒ;struct bpf_sysctl { __u32 write; __u32 file_pos; };”…”�”}”hj…sbah}”(h]”h ]”h"]”h$]”h&]”hÅhÆuh1jƒh³hÇh´KhjVh²hubhŒ bullet_list”“”)�”}”(hhh]”(hŒ list_item”“”)�”}”(hŒl``write`` indicates whether sysctl value is being read (``0``) or written (``1``). This field is read-only. ”h]”hÞ)�”}”(hŒk``write`` indicates whether sysctl value is being read (``0``) or written (``1``). This field is read-only.”h]”(hè)�”}”(hŒ ``write``”h]”hŒwrite”…”�”}”(hj¢h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hçhjžubhŒ/ indicates whether sysctl value is being read (”…”�”}”(hjžh²hh³Nh´Nubhè)�”}”(hŒ``0``”h]”hŒ0”…”�”}”(hj´h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hçhjžubhŒ) or written (”…”�”}”(hjžh²hh³Nh´Nubhè)�”}”(hŒ``1``”h]”hŒ1”…”�”}”(hjÆh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hçhjžubhŒ). This field is read-only.”…”�”}”(hjžh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÝh³hÇh´Khjšubah}”(h]”h ]”h"]”h$]”h&]”uh1j˜hj•h²hh³hÇh´Nubj™)�”}”(hXÔ``file_pos`` indicates file position sysctl is being accessed at, read or written. This field is read-write. Writing to the field sets the starting position in sysctl proc file ``read(2)`` will be reading from or ``write(2)`` will be writing to. Writing zero to the field can be used e.g. to override whole sysctl value by ``bpf_sysctl_set_new_value()`` on ``write(2)`` even when it's called by user space on ``file_pos > 0``. Writing non-zero value to the field can be used to access part of sysctl value starting from specified ``file_pos``. Not all sysctl support access with ``file_pos != 0``, e.g. writes to numeric sysctl entries must always be at file position ``0``. See also ``kernel.sysctl_writes_strict`` sysctl. ”h]”hÞ)�”}”(hXÓ``file_pos`` indicates file position sysctl is being accessed at, read or written. This field is read-write. Writing to the field sets the starting position in sysctl proc file ``read(2)`` will be reading from or ``write(2)`` will be writing to. Writing zero to the field can be used e.g. to override whole sysctl value by ``bpf_sysctl_set_new_value()`` on ``write(2)`` even when it's called by user space on ``file_pos > 0``. Writing non-zero value to the field can be used to access part of sysctl value starting from specified ``file_pos``. Not all sysctl support access with ``file_pos != 0``, e.g. writes to numeric sysctl entries must always be at file position ``0``. See also ``kernel.sysctl_writes_strict`` sysctl.”h]”(hè)�”}”(hŒ ``file_pos``”h]”hŒfile_pos”…”�”}”(hjìh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hçhjèubhŒ¥ indicates file position sysctl is being accessed at, read or written. This field is read-write. Writing to the field sets the starting position in sysctl proc file ”…”�”}”(hjèh²hh³Nh´Nubhè)�”}”(hŒ ``read(2)``”h]”hŒread(2)”…”�”}”(hjþh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hçhjèubhŒ will be reading from or ”…”�”}”(hjèh²hh³Nh´Nubhè)�”}”(hŒ ``write(2)``”h]”hŒwrite(2)”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hçhjèubhŒb will be writing to. Writing zero to the field can be used e.g. to override whole sysctl value by ”…”�”}”(hjèh²hh³Nh´Nubhè)�”}”(hŒ``bpf_sysctl_set_new_value()``”h]”hŒbpf_sysctl_set_new_value()”…”�”}”(hj"h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hçhjèubhŒ on ”…”�”}”(hjèh²hh³Nh´Nubhè)�”}”(hŒ ``write(2)``”h]”hŒwrite(2)”…”�”}”(hj4h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hçhjèubhŒ* even when it’s called by user space on ”…”�”}”(hjèh²hh³Nh´Nubhè)�”}”(hŒ``file_pos > 0``”h]”hŒ file_pos > 0”…”�”}”(hjFh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hçhjèubhŒi. Writing non-zero value to the field can be used to access part of sysctl value starting from specified ”…”�”}”(hjèh²hh³Nh´Nubhè)�”}”(hŒ ``file_pos``”h]”hŒfile_pos”…”�”}”(hjXh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hçhjèubhŒ%. Not all sysctl support access with ”…”�”}”(hjèh²hh³Nh´Nubhè)�”}”(hŒ``file_pos != 0``”h]”hŒ file_pos != 0”…”�”}”(hjjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hçhjèubhŒH, e.g. writes to numeric sysctl entries must always be at file position ”…”�”}”(hjèh²hh³Nh´Nubhè)�”}”(hŒ``0``”h]”hŒ0”…”�”}”(hj|h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hçhjèubhŒ . See also ”…”�”}”(hjèh²hh³Nh´Nubhè)�”}”(hŒ``kernel.sysctl_writes_strict``”h]”hŒkernel.sysctl_writes_strict”…”�”}”(hjŽh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hçhjèubhŒ sysctl.”…”�”}”(hjèh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÝh³hÇh´K!hjäubah}”(h]”h ]”h"]”h$]”h&]”uh1j˜hj•h²hh³hÇh´Nubeh}”(h]”h ]”h"]”h$]”h&]”Œbullet”Œ*”uh1j“h³hÇh´KhjVh²hubhÞ)�”}”(hŒISee `linux/bpf.h`_ for more details on how context field can be accessed.”h]”(hŒSee ”…”�”}”(hj´h²hh³Nh´NubhŒ reference”“”)�”}”(hŒ`linux/bpf.h`_”h]”hŒ linux/bpf.h”…”�”}”(hj¾h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”Œname”Œ linux/bpf.h”Œrefuri”Œ../../include/uapi/linux/bpf.h”uh1j¼hj´Œresolved”KubhŒ7 for more details on how context field can be accessed.”…”�”}”(hj´h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÝh³hÇh´K,hjVh²hubeh}”(h]”Œcontext”ah ]”h"]”Œ 2. context”ah$]”h&]”uh1hÈhhÊh²hh³hÇh´KubhÉ)�”}”(hhh]”(hÎ)�”}”(hŒ3. Return code”h]”hŒ3. Return code”…”�”}”(hjæh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÍhjãh²hh³hÇh´K/ubhÞ)�”}”(hŒV``BPF_PROG_TYPE_CGROUP_SYSCTL`` program must return one of the following return codes:”h]”(hè)�”}”(hŒ``BPF_PROG_TYPE_CGROUP_SYSCTL``”h]”hŒBPF_PROG_TYPE_CGROUP_SYSCTL”…”�”}”(hjøh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hçhjôubhŒ7 program must return one of the following return codes:”…”�”}”(hjôh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÝh³hÇh´K1hjãh²hubj”)�”}”(hhh]”(j™)�”}”(hŒ&``0`` means "reject access to sysctl";”h]”hÞ)�”}”(hjh]”(hè)�”}”(hŒ``0``”h]”hŒ0”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hçhjubhŒ% means “reject access to sysctlâ€�;”…”�”}”(hjh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÝh³hÇh´K4hjubah}”(h]”h ]”h"]”h$]”h&]”uh1j˜hjh²hh³hÇh´Nubj™)�”}”(hŒ#``1`` means "proceed with access". ”h]”hÞ)�”}”(hŒ"``1`` means "proceed with access".”h]”(hè)�”}”(hŒ``1``”h]”hŒ1”…”�”}”(hj@h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hçhj<ubhŒ! means “proceed with accessâ€�.”…”�”}”(hj<h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÝh³hÇh´K5hj8ubah}”(h]”h ]”h"]”h$]”h&]”uh1j˜hjh²hh³hÇh´Nubeh}”(h]”h ]”h"]”h$]”h&]”j²j³uh1j“h³hÇh´K4hjãh²hubhÞ)�”}”(hŒ|If program returns ``0`` user space will get ``-1`` from ``read(2)`` or ``write(2)`` and ``errno`` will be set to ``EPERM``.”h]”(hŒIf program returns ”…”�”}”(hjdh²hh³Nh´Nubhè)�”}”(hŒ``0``”h]”hŒ0”…”�”}”(hjlh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hçhjdubhŒ user space will get ”…”�”}”(hjdh²hh³Nh´Nubhè)�”}”(hŒ``-1``”h]”hŒ-1”…”�”}”(hj~h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hçhjdubhŒ from ”…”�”}”(hjdh²hh³Nh´Nubhè)�”}”(hŒ ``read(2)``”h]”hŒread(2)”…”�”}”(hj�h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hçhjdubhŒ or ”…”�”}”(hjdh²hh³Nh´Nubhè)�”}”(hŒ ``write(2)``”h]”hŒwrite(2)”…”�”}”(hj¢h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hçhjdubhŒ and ”…”�”}”(hjdh²hh³Nh´Nubhè)�”}”(hŒ ``errno``”h]”hŒerrno”…”�”}”(hj´h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hçhjdubhŒ will be set to ”…”�”}”(hjdh²hh³Nh´Nubhè)�”}”(hŒ ``EPERM``”h]”hŒEPERM”…”�”}”(hjÆh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hçhjdubhŒ.”…”�”}”(hjdh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÝh³hÇh´K7hjãh²hubeh}”(h]”Œ return-code”ah ]”h"]”Œ3. return code”ah$]”h&]”uh1hÈhhÊh²hh³hÇh´K/ubhÉ)�”}”(hhh]”(hÎ)�”}”(hŒ 4. Helpers”h]”hŒ 4. Helpers”…”�”}”(hjéh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÍhjæh²hh³hÇh´K;ubhÞ)�”}”(hŒ‚Since sysctl knob is represented by a name and a value, sysctl specific BPF helpers focus on providing access to these properties:”h]”hŒ‚Since sysctl knob is represented by a name and a value, sysctl specific BPF helpers focus on providing access to these properties:”…”�”}”(hj÷h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÝh³hÇh´K=hjæh²hubj”)�”}”(hhh]”(j™)�”}”(hŒt``bpf_sysctl_get_name()`` to get sysctl name as it is visible in ``/proc/sys`` into provided by BPF program buffer; ”h]”hÞ)�”}”(hŒs``bpf_sysctl_get_name()`` to get sysctl name as it is visible in ``/proc/sys`` into provided by BPF program buffer;”h]”(hè)�”}”(hŒ``bpf_sysctl_get_name()``”h]”hŒbpf_sysctl_get_name()”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hçhj ubhŒ( to get sysctl name as it is visible in ”…”�”}”(hj h²hh³Nh´Nubhè)�”}”(hŒ ``/proc/sys``”h]”hŒ /proc/sys”…”�”}”(hj"h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hçhj ubhŒ% into provided by BPF program buffer;”…”�”}”(hj h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÝh³hÇh´K@hjubah}”(h]”h ]”h"]”h$]”h&]”uh1j˜hjh²hh³hÇh´Nubj™)�”}”(hŒÃ``bpf_sysctl_get_current_value()`` to get string value currently held by sysctl into provided by BPF program buffer. This helper is available on both ``read(2)`` from and ``write(2)`` to sysctl; ”h]”hÞ)�”}”(hŒÂ``bpf_sysctl_get_current_value()`` to get string value currently held by sysctl into provided by BPF program buffer. This helper is available on both ``read(2)`` from and ``write(2)`` to sysctl;”h]”(hè)�”}”(hŒ"``bpf_sysctl_get_current_value()``”h]”hŒbpf_sysctl_get_current_value()”…”�”}”(hjHh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hçhjDubhŒt to get string value currently held by sysctl into provided by BPF program buffer. This helper is available on both ”…”�”}”(hjDh²hh³Nh´Nubhè)�”}”(hŒ ``read(2)``”h]”hŒread(2)”…”�”}”(hjZh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hçhjDubhŒ from and ”…”�”}”(hjDh²hh³Nh´Nubhè)�”}”(hŒ ``write(2)``”h]”hŒwrite(2)”…”�”}”(hjlh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hçhjDubhŒ to sysctl;”…”�”}”(hjDh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÝh³hÇh´KChj@ubah}”(h]”h ]”h"]”h$]”h&]”uh1j˜hjh²hh³hÇh´Nubj™)�”}”(hŒ«``bpf_sysctl_get_new_value()`` to get new string value currently being written to sysctl before actual write happens. This helper can be used only on ``ctx->write == 1``; ”h]”hÞ)�”}”(hŒª``bpf_sysctl_get_new_value()`` to get new string value currently being written to sysctl before actual write happens. This helper can be used only on ``ctx->write == 1``;”h]”(hè)�”}”(hŒ``bpf_sysctl_get_new_value()``”h]”hŒbpf_sysctl_get_new_value()”…”�”}”(hj’h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hçhjŽubhŒx to get new string value currently being written to sysctl before actual write happens. This helper can be used only on ”…”�”}”(hjŽh²hh³Nh´Nubhè)�”}”(hŒ``ctx->write == 1``”h]”hŒctx->write == 1”…”�”}”(hj¤h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hçhjŽubhŒ;”…”�”}”(hjŽh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÝh³hÇh´KGhjŠubah}”(h]”h ]”h"]”h$]”h&]”uh1j˜hjh²hh³hÇh´Nubj™)�”}”(hXè``bpf_sysctl_set_new_value()`` to override new string value currently being written to sysctl before actual write happens. Sysctl value will be overridden starting from the current ``ctx->file_pos``. If the whole value has to be overridden BPF program can set ``file_pos`` to zero before calling to the helper. This helper can be used only on ``ctx->write == 1``. New string value set by the helper is treated and verified by kernel same way as an equivalent string passed by user space. ”h]”hÞ)�”}”(hXç``bpf_sysctl_set_new_value()`` to override new string value currently being written to sysctl before actual write happens. Sysctl value will be overridden starting from the current ``ctx->file_pos``. If the whole value has to be overridden BPF program can set ``file_pos`` to zero before calling to the helper. This helper can be used only on ``ctx->write == 1``. New string value set by the helper is treated and verified by kernel same way as an equivalent string passed by user space.”h]”(hè)�”}”(hŒ``bpf_sysctl_set_new_value()``”h]”hŒbpf_sysctl_set_new_value()”…”�”}”(hjÊh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hçhjÆubhŒ— to override new string value currently being written to sysctl before actual write happens. Sysctl value will be overridden starting from the current ”…”�”}”(hjÆh²hh³Nh´Nubhè)�”}”(hŒ``ctx->file_pos``”h]”hŒ ctx->file_pos”…”�”}”(hjÜh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hçhjÆubhŒ>. If the whole value has to be overridden BPF program can set ”…”�”}”(hjÆh²hh³Nh´Nubhè)�”}”(hŒ ``file_pos``”h]”hŒfile_pos”…”�”}”(hjîh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hçhjÆubhŒG to zero before calling to the helper. This helper can be used only on ”…”�”}”(hjÆh²hh³Nh´Nubhè)�”}”(hŒ``ctx->write == 1``”h]”hŒctx->write == 1”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hçhjÆubhŒ}. New string value set by the helper is treated and verified by kernel same way as an equivalent string passed by user space.”…”�”}”(hjÆh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÝh³hÇh´KKhjÂubah}”(h]”h ]”h"]”h$]”h&]”uh1j˜hjh²hh³hÇh´Nubeh}”(h]”h ]”h"]”h$]”h&]”j²j³uh1j“h³hÇh´K@hjæh²hubhÞ)�”}”(hŒîBPF program sees sysctl value same way as user space does in proc filesystem, i.e. as a string. Since many sysctl values represent an integer or a vector of integers, the following helpers can be used to get numeric value from the string:”h]”hŒîBPF program sees sysctl value same way as user space does in proc filesystem, i.e. as a string. Since many sysctl values represent an integer or a vector of integers, the following helpers can be used to get numeric value from the string:”…”�”}”(hj$h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÝh³hÇh´KShjæh²hubj”)�”}”(hhh]”(j™)�”}”(hŒj``bpf_strtol()`` to convert initial part of the string to long integer similar to user space `strtol(3)`_;”h]”hÞ)�”}”(hŒj``bpf_strtol()`` to convert initial part of the string to long integer similar to user space `strtol(3)`_;”h]”(hè)�”}”(hŒ``bpf_strtol()``”h]”hŒ bpf_strtol()”…”�”}”(hj=h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hçhj9ubhŒM to convert initial part of the string to long integer similar to user space ”…”�”}”(hj9h²hh³Nh´Nubj½)�”}”(hŒ `strtol(3)`_”h]”hŒ strtol(3)”…”�”}”(hjOh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”Œname”Œ strtol(3)”jÎŒ3http://man7.org/linux/man-pages/man3/strtol.3p.html”uh1j¼hj9jÐKubhŒ;”…”�”}”(hj9h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÝh³hÇh´KXhj5ubah}”(h]”h ]”h"]”h$]”h&]”uh1j˜hj2h²hh³hÇh´Nubj™)�”}”(hŒv``bpf_strtoul()`` to convert initial part of the string to unsigned long integer similar to user space `strtoul(3)`_; ”h]”hÞ)�”}”(hŒu``bpf_strtoul()`` to convert initial part of the string to unsigned long integer similar to user space `strtoul(3)`_;”h]”(hè)�”}”(hŒ``bpf_strtoul()``”h]”hŒ bpf_strtoul()”…”�”}”(hjxh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hçhjtubhŒV to convert initial part of the string to unsigned long integer similar to user space ”…”�”}”(hjth²hh³Nh´Nubj½)�”}”(hŒ `strtoul(3)`_”h]”hŒ strtoul(3)”…”�”}”(hjŠh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”Œname”Œ strtoul(3)”jÎŒ4http://man7.org/linux/man-pages/man3/strtoul.3p.html”uh1j¼hjtjÐKubhŒ;”…”�”}”(hjth²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÝh³hÇh´KZhjpubah}”(h]”h ]”h"]”h$]”h&]”uh1j˜hj2h²hh³hÇh´Nubeh}”(h]”h ]”h"]”h$]”h&]”j²j³uh1j“h³hÇh´KXhjæh²hubhÞ)�”}”(hŒ>See `linux/bpf.h`_ for more details on helpers described here.”h]”(hŒSee ”…”�”}”(hj±h²hh³Nh´Nubj½)�”}”(hŒ`linux/bpf.h`_”h]”hŒ linux/bpf.h”…”�”}”(hj¹h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”Œname”Œ linux/bpf.h”jÎjÏuh1j¼hj±jÐKubhŒ, for more details on helpers described here.”…”�”}”(hj±h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÝh³hÇh´K]hjæh²hubeh}”(h]”Œhelpers”ah ]”h"]”Œ 4. helpers”ah$]”h&]”uh1hÈhhÊh²hh³hÇh´K;ubhÉ)�”}”(hhh]”(hÎ)�”}”(hŒ 5. Examples”h]”hŒ 5. Examples”…”�”}”(hjÞh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÍhjÛh²hh³hÇh´K`ubhÞ)�”}”(hŒÝSee `test_sysctl_prog.c`_ for an example of BPF program in C that access sysctl name and value, parses string value to get vector of integers and uses the result to make decision whether to allow or deny access to sysctl.”h]”(hŒSee ”…”�”}”(hjìh²hh³Nh´Nubj½)�”}”(hŒ`test_sysctl_prog.c`_”h]”hŒtest_sysctl_prog.c”…”�”}”(hjôh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”Œname”Œtest_sysctl_prog.c”jÎŒ:../../tools/testing/selftests/bpf/progs/test_sysctl_prog.c”uh1j¼hjìjÐKubhŒÄ for an example of BPF program in C that access sysctl name and value, parses string value to get vector of integers and uses the result to make decision whether to allow or deny access to sysctl.”…”�”}”(hjìh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÝh³hÇh´KbhjÛh²hubeh}”(h]”Œexamples”ah ]”h"]”Œ 5. examples”ah$]”h&]”uh1hÈhhÊh²hh³hÇh´K`ubhÉ)�”}”(hhh]”(hÎ)�”}”(hŒ6. Notes”h]”hŒ6. Notes”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÍhjh²hh³hÇh´KgubhÞ)�”}”(hŒà``BPF_PROG_TYPE_CGROUP_SYSCTL`` is intended to be used in **trusted** root environment, for example to monitor sysctl usage or catch unreasonable values an application, running as root in a separate cgroup, is trying to set.”h]”(hè)�”}”(hŒ``BPF_PROG_TYPE_CGROUP_SYSCTL``”h]”hŒBPF_PROG_TYPE_CGROUP_SYSCTL”…”�”}”(hj,h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hçhj(ubhŒ is intended to be used in ”…”�”}”(hj(h²hh³Nh´NubhŒstrong”“”)�”}”(hŒ **trusted**”h]”hŒtrusted”…”�”}”(hj@h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j>hj(ubhŒ› root environment, for example to monitor sysctl usage or catch unreasonable values an application, running as root in a separate cgroup, is trying to set.”…”�”}”(hj(h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÝh³hÇh´Kihjh²hubhÞ)�”}”(hX¥Since `task_dfl_cgroup(current)` is called at `sys_read` / `sys_write` time it may return results different from that at `sys_open` time, i.e. process that opened sysctl file in proc filesystem may differ from process that is trying to read from / write to it and two such processes may run in different cgroups, what means ``BPF_PROG_TYPE_CGROUP_SYSCTL`` should not be used as a security mechanism to limit sysctl usage.”h]”(hŒSince ”…”�”}”(hjXh²hh³Nh´NubhŒtitle_reference”“”)�”}”(hŒ`task_dfl_cgroup(current)`”h]”hŒtask_dfl_cgroup(current)”…”�”}”(hjbh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j`hjXubhŒ is called at ”…”�”}”(hjXh²hh³Nh´Nubja)�”}”(hŒ `sys_read`”h]”hŒsys_read”…”�”}”(hjth²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j`hjXubhŒ / ”…”�”}”(hjXh²hh³Nh´Nubja)�”}”(hŒ `sys_write`”h]”hŒ sys_write”…”�”}”(hj†h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j`hjXubhŒ3 time it may return results different from that at ”…”�”}”(hjXh²hh³Nh´Nubja)�”}”(hŒ `sys_open`”h]”hŒsys_open”…”�”}”(hj˜h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j`hjXubhŒÁ time, i.e. process that opened sysctl file in proc filesystem may differ from process that is trying to read from / write to it and two such processes may run in different cgroups, what means ”…”�”}”(hjXh²hh³Nh´Nubhè)�”}”(hŒ``BPF_PROG_TYPE_CGROUP_SYSCTL``”h]”hŒBPF_PROG_TYPE_CGROUP_SYSCTL”…”�”}”(hjªh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hçhjXubhŒB should not be used as a security mechanism to limit sysctl usage.”…”�”}”(hjXh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÝh³hÇh´Kmhjh²hubhÞ)�”}”(hŒ»As with any cgroup-bpf program additional care should be taken if an application running as root in a cgroup should not be allowed to detach/replace BPF program attached by administrator.”h]”hŒ»As with any cgroup-bpf program additional care should be taken if an application running as root in a cgroup should not be allowed to detach/replace BPF program attached by administrator.”…”�”}”(hjÂh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÝh³hÇh´Kthjh²hubh¶)�”}”(hŒLinks”h]”hŒLinks”…”�”}”hjÐsbah}”(h]”h ]”h"]”h$]”h&]”hÅhÆuh1hµhjh²hh³hÇh´KxubhŒtarget”“”)�”}”(hŒ/.. _linux/bpf.h: ../../include/uapi/linux/bpf.h”h]”h}”(h]”Œ linux-bpf-h”ah ]”h"]”Œ linux/bpf.h”ah$]”h&]”jÎjÏuh1jÞh´Kyhjh²hh³hÇŒ referenced”Kubjß)�”}”(hŒB.. _strtol(3): http://man7.org/linux/man-pages/man3/strtol.3p.html”h]”h}”(h]”Œstrtol-3”ah ]”h"]”Œ strtol(3)”ah$]”h&]”jÎj_uh1jÞh´Kzhjh²hh³hÇjìKubjß)�”}”(hŒD.. _strtoul(3): http://man7.org/linux/man-pages/man3/strtoul.3p.html”h]”h}”(h]”Œ strtoul-3”ah ]”h"]”Œ strtoul(3)”ah$]”h&]”jÎjšuh1jÞh´K{hjh²hh³hÇjìKubjß)�”}”(hŒU.. _test_sysctl_prog.c: ../../tools/testing/selftests/bpf/progs/test_sysctl_prog.c”h]”h}”(h]”Œtest-sysctl-prog-c”ah ]”h"]”Œtest_sysctl_prog.c”ah$]”h&]”jÎjuh1jÞh´K|hjh²hh³hÇjìKubeh}”(h]”Œnotes”ah ]”h"]”Œ6. notes”ah$]”h&]”uh1hÈhhÊh²hh³hÇh´Kgubeh}”(h]”Œbpf-prog-type-cgroup-sysctl”ah ]”h"]”Œbpf_prog_type_cgroup_sysctl”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”jDŒ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”}”(Œ linux/bpf.h”]”(j¾j¹eŒ strtol(3)”]”jOaŒ strtoul(3)”]”jŠaŒtest_sysctl_prog.c”]”jôauŒrefids”}”Œnameids”}”(jjjSjPjàjÝjãjàjØjÕjjjjjéjæjöjójjÿjj uŒ nametypes”}”(j‰jS‰jà‰jã‰j؉j‰j‰jéˆjöˆjˆjˆuh}”(jhÊjPjjÝjVjàjãjÕjæjjÛjjjæjàjójíjÿjùj juŒ 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.