I would like to put this to discussion: does it make sense to default kernel.yama.ptrace_scope & net.core.bpf_jit_harden to 1? Both are 0 at the moment.
 → Update regarding the ongoing discussion below: it might be useful to consider 2 at bpf_jit_harden rather than 1 because the performance disadvantage might be not noteworthy in practice.
This adds some mitigations for respective attacks. While searching for a solution for a different problem, I stumbled over the two through the Arch Wiki, became curious and wondered about our defaults could be improved:
net.core.bpf_jit_harden:
Arch) https://wiki.archlinux.org/title/Security#BPF_hardening
Kernel Docs) Documentation for /proc/sys/net/ — The Linux Kernel documentation
kernel.yama.ptrace_scope:
Arch) Security - ArchWiki
Kernel Docs) Yama — The Linux Kernel documentation
I avoid further elaboration and refer to both the arch wiki and the related kernel documentation.
With regards to net.core.bpf_jit_harden:
I am not sure how much unprivileged code is affected on Fedora about this, but imho the mitigation (value 1 hardens against unprivileged code) is worth to be put in place and justifies the trade-off in performance: I saw that Arch sets this already by default to 2 (hardens against all code) in its hardened-kernel (though 0 in the other kernel but still suggesting 1 or 2), so if even a do-it-yourself community defaults to 2 for everyone using the hardened kernel (and generally suggesting it), I presume the performance trade-off ain’t that worse. I am aware that there are major differences between the distributions, but presume in this respect there might be comparability. Update: given the ongoing discussion below, it might be useful to consider to use 2 rather than 1 in bpf_jit_harden.
With regards to kernel.yama.ptrace_scope:
@decathorpe mentioned that he heard that Ubuntu already defaulted to 1. Arch sets this already by default to 1 too (also in the normal kernel, not just the hardened one). Again, I think 1 makes sense while 2 or 3 might cause negative trade-offs, in which we would have a bigger/wider issue with origins from somewhere else anyway. But feel free to discuss, again, my experience here is limited…
For now, I just want to raise some awareness of the possibilities and facilitate a discussion.
For the record (assuming this question might come up): The Fedora kernel is built with CONFIG_BPF_JIT_ALWAYS_ON=y/true (source: kernel-ark; can be verified with net.core.bpf_jit_enable=1)