lkrg-org / lkrg

Linux Kernel Runtime Guard
https://lkrg.org
Other
403 stars 72 forks source link

Net: Add net_log_scope setting #304

Open solardiz opened 4 months ago

solardiz commented 4 months ago

Nov 9, 2022

The initial implementation is sending all new kernel messages appearing since LKRG is loaded. We probably want to add a knob to choose between several modes:

  1. Send new LKRG messages only (no non-LKRG, no old).
  2. Send new LKRG and non-LKRG messages only (no old). This is the current behavior.
  3. Send all kernel messages (including old - that is, those buffered by the kernel prior to LKRG loading).

We could also have:

  1. Like 3 on first LKRG load, like 2 on subsequent reloads.

However, the implementation for 4 is tricky/hackish - how do we determine that LKRG had already been loaded in this kernel's uptime? We're going to go through the buffered messages anyway, and could infer from there, but this means going through them twice (first to see no mentions of LKRG, then to send the buffered messages). Alternatively, we could leave some in-kernel flag even upon LKRG unloading, so we could check it on a subsequent LKRG reload easily.

We could also easily have:

  1. Send all LKRG messages, including old (but no non-LKRG).

However, why would we? In case LKRG was loaded without networking, then is reloaded with networking? Sounds like too much of a special case to bother.