Closed MrQubo closed 3 months ago
Works fine on non-hardened linux.
This also works fine:
boot.kernelPackages = pkgs.linuxPackages_hardened;
services.ananicy = {
enable = true;
package = pkgs.ananicy;
};
Seems like the issue is with ananicy-cpp.
Could you try with the latest kernel, though I am not sure how a kernel change could be impacting this.
EDIT: it is failing to load BPF programs, using the latest kernel (6.9+ as of now) should fix things.
I can't check 6.9 because I'm on zfs. With 6.8 hardened the error is still there.
You could try chaotic-nyx's cachyos hardended kernel. That is on 6.9 AFAIK.
You could try chaotic-nyx's cachyos hardended kernel. That is on 6.9 AFAIK.
on regular linux-cachyos (6.9) works fine. i suppose will work on cachyos-hardenedas well, but if you mind - i'll test.
core dumped..
I can't check 6.9 because I'm on zfs. With 6.8 hardened the error is still there.
so. after some tests we came to a suggestion that this is hardened kernel issue:
i've and Luis tested it out. on cachyos-6.9.9
on my end nothing gone wrong, benchmark done and done well. as @JohnRTitor suggested - you can try linux-cachyos
from chaotic-nyx flake, but not hardened one. :D
To be honest any non-hardened kernel should work.
Yeah, works fine with default pkgs.linuxPackages_hardened
.
I think it's possible to build with netlink instead of bpf. Maybe this would work on hardened? But I don't know cmake to well, I'm not sure how to change this flag? nvm, it's -DUSE_BPF_PROC_IMPL=OFF
https://gitlab.com/ananicy-cpp/ananicy-cpp/-/blob/097d79fd14607d3bce1021aa8b08a49c82c3222d/CMakeLists.txt#L192-200
I can't check 6.9 because I'm on zfs. With 6.8 hardened the error is still there.
so. after some tests we came to a suggestion that this is hardened kernel issue: i've and Luis tested it out. on
cachyos-6.9.9
on my end nothing gone wrong, benchmark done and done well. as @JohnRTitor suggested - you can trylinux-cachyos
from chaotic-nyx flake, but not hardened one. :D
That's not it. On nixos I have CONFIG_BPF_SYSCALL=y
in /proc/config.gz
with linuxPackages_6_8_hardened
.
I can't check 6.9 because I'm on zfs. With 6.8 hardened the error is still there.
so. after some tests we came to a suggestion that this is hardened kernel issue: i've and Luis tested it out. on
cachyos-6.9.9
on my end nothing gone wrong, benchmark done and done well. as @JohnRTitor suggested - you can trylinux-cachyos
from chaotic-nyx flake, but not hardened one. :DThat's not it. On nixos I have
CONFIG_BPF_SYSCALL=y
in/proc/config.gz
withlinuxPackages_6_8_hardened
.
'k!
diff 6.8 6.8.hardened
*BTF*
ones might be important?
In order ananicy-cpp to function, make sure that kernelparams "debugfs=off" is not set.
Thanks @VeilSilence!
debugfs=off
is the default on hardened. Adding debugfs=on
to cmdline fixes the issue. Doesn't work with debugfs=no-mount
.
Compiling with cmake flag -DUSE_BPF_PROC_IMPL=OFF
also makes it work (with the default debugfs=off
).
pkgs.ananicy-cpp.overrideAttrs (prevAttrs: { cmakeFlags = (lib.remove "-DUSE_BPF_PROC_IMPL=ON" prevAttrs.cmakeFlags) ++ [ "-DUSE_BPF_PROC_IMPL=OFF" ]; })
Seems like debugfs is not required, only tracefs, which can be enabled with
fileSystems."/sys/kernel/tracing" = {
device = "tracefs";
fsType = "tracefs";
};
Seems like debugfs is not required, only tracefs, which can be enabled with
fileSystems."/sys/kernel/tracing" = { device = "tracefs"; fsType = "tracefs"; };
Good to know. Maybe i'll disable once again debugfs.
So I think the fix should be to disable "-DUSE_BPF_PROC_IMPL=ON"
on hardened kernel?
I've realized that we cannot do the check whether kernel is hardened or not in package itself. I was thinking, that the best course of action would be to create nixos module for ananicy-cpp.
I've realized that we cannot do the check whether kernel is hardened or not in package itself. I was thinking, that the best course of action would be to create nixos module for ananicy-cpp.
sounds actually good, i agree with it. :D
Please test #330488, just override bpfSupport = false;
@JohnRTitor I disabled debugfs and tracefs, and tested it like this:
services.ananicy = {
enable = true;
package =
let
ananicy-cpp = (import (builtins.fetchTarball "https://github.com/NixOS/nixpkgs/archive/refs/pull/330488/head.tar.gz") {}).ananicy-cpp;
in ananicy-cpp.override ({ withBpf = false; });
rulesProvider = pkgs.ananicy-rules-cachyos;
};
No more errors.
The problem with debugs/tracefs is that it seems like there's no nixos way to check for debufs/tracefs.
I was thinking of adding option services.ananicy-cpp.withBpf
which would default to false on hardened and true otherwise. With boot.tracefs
we could add an assert for withBpf -> (boot.tracefs.enabled || boot.debugfs.enabled)
.
No need to add an additional module. You can check if services.ananicy.package
's pname == pkgs.ananicy-cpp
's pname AND config.boot.kernelPackages.isHardened == true
, then the override should be applied.
You could send the patch here and I'll commit it for you, or send another PR after I merge this.
I think it would be better to expose withBpf as module option so it can be documented properly for the users.
Describe the bug
Ananicy systemd service fails. Here's the log from journal:
The service gets auto-restarted after that failure and the next error is different:
Also, here's the stack trace from coredump:
Steps To Reproduce
Notify maintainers
@Artturin @JohnRTitor @diniamo
Metadata
Please run
nix-shell -p nix-info --run "nix-info -m"
and paste the result.Add a :+1: reaction to issues you find important.