lkm5: add ioscheduler fixer

Signed-off-by: AuxXxilium <info@auxxxilium.tech>
This commit is contained in:
AuxXxilium 2024-03-01 15:43:47 +01:00
parent 9d7aa00997
commit 99645488f0
4 changed files with 34 additions and 1 deletions

View File

@ -13,7 +13,7 @@ SRCS-y += compat/string_compat.c \
internal/override/override_symbol.c internal/override/override_syscall.c internal/intercept_execve.c \ internal/override/override_symbol.c internal/override/override_syscall.c internal/intercept_execve.c \
internal/call_protected.c internal/intercept_driver_register.c internal/stealth/sanitize_cmdline.c \ internal/call_protected.c internal/intercept_driver_register.c internal/stealth/sanitize_cmdline.c \
internal/stealth.c internal/virtual_pci.c internal/uart/uart_swapper.c internal/uart/vuart_virtual_irq.c \ internal/stealth.c internal/virtual_pci.c internal/uart/uart_swapper.c internal/uart/vuart_virtual_irq.c \
internal/uart/virtual_uart.c \ internal/uart/virtual_uart.c internal/ioscheduler_fixer.c \
\ \
config/cmdline_delegate.c config/runtime_config.c \ config/cmdline_delegate.c config/runtime_config.c \
\ \

View File

@ -0,0 +1,26 @@
/**
* This very simple submodule which prevents kernel log from being flooded with "I/O scheduler elevator not found"
*
* When this shim is loaded as a I/O scheduler (to load very early) it is being set as a I/O scheduler. As we later
* remove the module file the system will constantly try to load now non-existing module "elevator-iosched". By
* resetting the "chosen_elevator" using the same function called by "elevator=" handler we can pretend no custom
* I/O scheduler was ever set (so that the system uses default one and stops complaining)
*/
#include "ioscheduler_fixer.h"
#include "../common.h"
#include "call_protected.h" //is_system_booting(), elevator_setup()
#include <linux/kernel.h> //system_state
#define SHIM_NAME "I/O scheduler fixer"
int reset_elevator(void)
{
if (!is_system_booting()) {
pr_loc_wrn("Cannot reset I/O scheduler / elevator= set - system is past booting stage (state=%d)",
system_state);
return 0; //This is not an error technically speaking
}
pr_loc_dbg("Resetting I/O scheduler to default");
return _elevator_setup("") == 1 ? 0 : -EINVAL;
}

View File

@ -0,0 +1,6 @@
#ifndef REDPILL_IOSCHEDULER_FIXER_H
#define REDPILL_IOSCHEDULER_FIXER_H
int reset_elevator(void);
#endif //REDPILL_IOSCHEDULER_FIXER_H

View File

@ -63,6 +63,7 @@ static int __init init_(void)
|| (out = register_disk_smart_shim()) != 0 //provide fake SMART to userspace || (out = register_disk_smart_shim()) != 0 //provide fake SMART to userspace
|| (out = register_pmu_shim(current_config.hw_config)) != 0 //this is used as early as mfgBIOS loads (=late) || (out = register_pmu_shim(current_config.hw_config)) != 0 //this is used as early as mfgBIOS loads (=late)
|| (out = initialize_stealth(&current_config)) != 0 //Should be after any shims to let shims have real stuff || (out = initialize_stealth(&current_config)) != 0 //Should be after any shims to let shims have real stuff
|| (out = reset_elevator()) != 0 //Cosmetic, can be the last one
) )
goto error_out; goto error_out;