File tree Expand file tree Collapse file tree 3 files changed +77
-0
lines changed
Expand file tree Collapse file tree 3 files changed +77
-0
lines changed Original file line number Diff line number Diff line change 4141 ./sysrq.nix
4242 ./tcp-timestamps.nix
4343 ./restrict-line-disciplines.nix
44+ ./harden-bpf.nix
45+ ./restrict-bpf.nix
4446 ]
4547 {
4648 inherit
Original file line number Diff line number Diff line change 1+ # This file is part of nix-mineral (https://github.com/cynicsketch/nix-mineral/).
2+ # Copyright (c) 2025 cynicsketch
3+ #
4+ # This program is free software: you can redistribute it and/or modify
5+ # it under the terms of the GNU General Public License as published by
6+ # the Free Software Foundation, either version 3 of the License, or
7+ # (at your option) any later version.
8+ #
9+ # This program is distributed in the hope that it will be useful,
10+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
11+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+ # GNU General Public License for more details.
13+ #
14+ # You should have received a copy of the GNU General Public License
15+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
16+
17+ {
18+ l ,
19+ cfg ,
20+ ...
21+ } :
22+
23+ {
24+ options = {
25+ harden-bpf = l . mkBoolOption ''
26+ Harden eBPF against JIT spraying attacks, to reduce the risk of abuse
27+ because eBPF allows executing potentially dangerous code in the kernel.
28+
29+ See https://en.wikipedia.org/wiki/EBPF#Security for more info.
30+ '' true ;
31+ } ;
32+
33+ config = l . mkIf cfg {
34+ boot . kernel . sysctl = {
35+ "net.core.bpf_jit_harden" = l . mkDefault "2" ;
36+ } ;
37+ } ;
38+ }
Original file line number Diff line number Diff line change 1+ # This file is part of nix-mineral (https://github.com/cynicsketch/nix-mineral/).
2+ # Copyright (c) 2025 cynicsketch
3+ #
4+ # This program is free software: you can redistribute it and/or modify
5+ # it under the terms of the GNU General Public License as published by
6+ # the Free Software Foundation, either version 3 of the License, or
7+ # (at your option) any later version.
8+ #
9+ # This program is distributed in the hope that it will be useful,
10+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
11+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+ # GNU General Public License for more details.
13+ #
14+ # You should have received a copy of the GNU General Public License
15+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
16+
17+ {
18+ l ,
19+ cfg ,
20+ ...
21+ } :
22+
23+ {
24+ options = {
25+ restrict-bpf = l . mkBoolOption ''
26+ Restrict eBPF to CAP_BPF in order to prevent abuse by unprivileged users.
27+
28+ See https://en.wikipedia.org/wiki/EBPF#Security for more info.
29+ '' true ;
30+ } ;
31+
32+ config = l . mkIf cfg {
33+ boot . kernel . sysctl = {
34+ "kernel.unprivileged_bpf_disabled" = l . mkDefault "1" ;
35+ } ;
36+ } ;
37+ }
You can’t perform that action at this time.
0 commit comments