Skip to contentSkip to conversation

docs: sysctl/kernel: document BPF entries

PATCH Superseded Stephen Kitt 3 participants 5 messages Feb 21, 2020 – Feb 25, 2020

Subsystems (2)

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 docs: sysctl/kernel: document BPF entries

Based on the implementation in kernel/bpf/syscall.c, kernel/bpf/trampoline.c, include/linux/filter.h, and the documentation in bpftool-prog.rst.

---
 Documentation/admin-guide/sysctl/kernel.rst | 24 +++++++++++++++++++++
 1 file changed, 24 insertions(+)
Documentation/admin-guide/sysctl/kernel.rst +24 -0
index 1c48ab4bfe30..89c70ea7de7c 100644
@@ -102,6 +102,20 @@ See the ``type_of_loader`` and ``ext_loader_ver`` fields in
 :doc:`/x86/boot` for additional information.
 
 
+bpf_stats_enabled
+=================
+
+Controls whether the kernel should collect statistics on BPF programs
+(total time spent running, number of times run...). Enabling
+statistics causes a slight reduction in performance on each program
+run. The statistics can be seen using ``bpftool``.
+
+= ===================================
+0 Don't collect statistics (default).
+1 Collect statistics.
+= ===================================
+
+
 cap_last_cap
 ============
 
@@ -1152,6 +1166,16 @@ NMI switch that most IA32 servers have fires unknown NMI up, for
 example.  If a system hangs up, try pressing the NMI switch.
 
 
+unprivileged_bpf_disabled
+=========================
+
+Writing 1 to this entry will disabled unprivileged calls to ``bpf()``;
+once disabled, calling ``bpf()`` without ``CAP_SYS_ADMIN`` will return
+``-EPERM``.
+
+Once set, this can't be cleared.
+
+
 watchdog
 ========
 
Signature · 1 line
2.20.1
#1 lore raw
Quoted 36 lines · Stephen Kitt

Based on the implementation in kernel/bpf/syscall.c, kernel/bpf/trampoline.c, include/linux/filter.h, and the documentation in bpftool-prog.rst.

---
 Documentation/admin-guide/sysctl/kernel.rst | 24 +++++++++++++++++++++
 1 file changed, 24 insertions(+)
Documentation/admin-guide/sysctl/kernel.rst +14 -0
index 1c48ab4bfe30..89c70ea7de7c 100644
@@ -102,6 +102,20 @@ See the ``type_of_loader`` and ``ext_loader_ver`` fields in
 :doc:`/x86/boot` for additional information.
 
 
+bpf_stats_enabled
+=================
+
+Controls whether the kernel should collect statistics on BPF programs
+(total time spent running, number of times run...). Enabling
+statistics causes a slight reduction in performance on each program
+run. The statistics can be seen using ``bpftool``.
+
+= ===================================
+0 Don't collect statistics (default).
+1 Collect statistics.
+= ===================================
+
+
 cap_last_cap
 ============
 

Documentation/admin-guide/sysctl/kernel.rst NMI switch that most IA32 servers have fires unknown NMI up, for · line 1172

Quoted 7 lines
Documentation/admin-guide/sysctl/kernel.rst +4 -0
@@ -1152,6 +1166,16 @@ NMI switch that most IA32 servers have fires unknown NMI up, for
 example.  If a system hangs up, try pressing the NMI switch.
 
 
+unprivileged_bpf_disabled
+=========================
+
+Writing 1 to this entry will disabled unprivileged calls to ``bpf()``;

'will disable' ?

It doesn't apply to bpf-next with:
error: sha1 information is lacking or useless (Documentation/admin-guide/sysctl/kernel.rst).
error: could not build fake ancestor
Patch failed at 0001 docs: sysctl/kernel: Document BPF entries

#2 lore raw
Quoted 6 lines · Alexei Starovoitov
Quoted 5 lines · Stephen Kitt
(quoted diff) +0 -0
@@ -1152,6 +1166,16 @@ NMI switch that most IA32 servers have fires

unknown NMI up, for example. If a system hangs up, try pressing the NMI switch.

Quoted 6 lines

Documentation/admin-guide/sysctl/kernel.rst NMI switch that most IA32 servers have fires unknown NMI up, for · line 1172

Quoted 4 lines
Documentation/admin-guide/sysctl/kernel.rst +4 -0
+unprivileged_bpf_disabled
+=========================
+
+Writing 1 to this entry will disabled unprivileged calls to ``bpf()``;  

'will disable' ?

Indeed, thanks.

Quoted 5 lines

It doesn't apply to bpf-next with:
error: sha1 information is lacking or useless (Documentation/admin-guide/sysctl/kernel.rst).
error: could not build fake ancestor
Patch failed at 0001 docs: sysctl/kernel: Document BPF entries

Sorry, I forgot to include the base commit information; this is against 8f21f54b8a95 in docs-next.

I’ll wait for that to make it to Linus’ tree and re-submit the patch (with the fix above).

Regards,

Stephen

#3 lore raw
Quoted 24 lines · Stephen Kitt
Quoted 6 lines · Alexei Starovoitov
Quoted 5 lines · Stephen Kitt
(quoted diff) +0 -0
@@ -1152,6 +1166,16 @@ NMI switch that most IA32 servers have fires

unknown NMI up, for example. If a system hangs up, try pressing the NMI switch.

Quoted 6 lines

Documentation/admin-guide/sysctl/kernel.rst NMI switch that most IA32 servers have fires unknown NMI up, for · line 1172

Quoted 4 lines
Documentation/admin-guide/sysctl/kernel.rst +4 -0
+unprivileged_bpf_disabled
+=========================
+
+Writing 1 to this entry will disabled unprivileged calls to ``bpf()``;

'will disable' ?

Indeed, thanks.

Quoted 5 lines

It doesn't apply to bpf-next with:
error: sha1 information is lacking or useless (Documentation/admin-guide/sysctl/kernel.rst).
error: could not build fake ancestor
Patch failed at 0001 docs: sysctl/kernel: Document BPF entries

Quoted 5 lines

Sorry, I forgot to include the base commit information; this is against 8f21f54b8a95 in docs-next.

I’ll wait for that to make it to Linus’ tree and re-submit the patch (with the fix above).

Please use bpf-next tree as a base for your patch.

maintainer
#4 lore raw
Quoted 7 lines · On Mon, 24 Feb 2020 21:43:33 -0800 Alexei Starovoitov…
Quoted 5 lines

Sorry, I forgot to include the base commit information; this is against 8f21f54b8a95 in docs-next.

I’ll wait for that to make it to Linus’ tree and re-submit the patch (with the fix above).

Please use bpf-next tree as a base for your patch.

It seems that folks want to take this through the BPF tree, so I'll assume it's not my problem :)

Thanks,

jon