1

when talking about ebpf advantage, it always mentions safe than lkm. I read some documentation, ebpf ensures safe by verifying code before it loaded. these are checklists that verify to do:

  • loops
  • out of range jumps
  • unreachable instructions
  • invalid instructions
  • uninitialized register access
  • uninitialized stack access
  • misaligned stack access
  • out of range stack access
  • invalid calling convention

most of these checks I can understand, but it's all reason that lkm cause kernel panic? if do these can ensure safe? I have 120000 servers in production, this question is the only reason to prevent me to migrate from traditional hids to ebpf hids. but if it can cause a kernel panic on a large scale, only one time, our business will be over.

Mateusz Piotrowski
  • 8,029
  • 10
  • 53
  • 79
cxiang
  • 23
  • 2

1 Answers1

2

Yes, as far as I know, the BPF verifier is meant to prevent any sort of kernel crash. That however doesn't mean you can't break things unintentionally in production. You could for example freeze your system by attaching BPF programs to all kernel functions or lose all connectivity by dropping all received packets. In those cases, the verifier has no way to know that you didn't mean to perform those actions; it won't stop you.

That being said, any sort of verification is better than no verification as in traditional kernel modules. With kernel modules, not only can you shoot yourself in the foot as I've described above, but you could also crash the whole system because of a subtle bug somewhere in the code.

Regardless of what you're using, you should obviously test it extensively before deploying to production.

pchaigno
  • 11,313
  • 2
  • 29
  • 54
  • Thank you for your reply. "but you could also crash the whole system because of a subtle bug somewhere in the code." yes, this is i want to know. Verifier through these checks can ensure that there are no bugs that can crash the whole system? – cxiang Dec 19 '21 at 13:02
  • Yes, unless there's a bug in the verifier itself, that shouldn't happen. – pchaigno Dec 19 '21 at 15:10
  • Such as loop could cause the kernel to lock up so that ebpf has loop check. if i want to know why Verifier can ensure safe. Maybe i need a list of kernel crash reasons? – cxiang Dec 21 '21 at 09:12