diff --git a/Makefile b/Makefile index 41a0a45..4810b08 100644 --- a/Makefile +++ b/Makefile @@ -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/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/uart/virtual_uart.c \ + internal/uart/virtual_uart.c internal/ioscheduler_fixer.c \ \ config/cmdline_delegate.c config/runtime_config.c \ \ diff --git a/internal/ioscheduler_fixer.c b/internal/ioscheduler_fixer.c new file mode 100644 index 0000000..6c1405e --- /dev/null +++ b/internal/ioscheduler_fixer.c @@ -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 //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; +} \ No newline at end of file diff --git a/internal/ioscheduler_fixer.h b/internal/ioscheduler_fixer.h new file mode 100644 index 0000000..728f789 --- /dev/null +++ b/internal/ioscheduler_fixer.h @@ -0,0 +1,6 @@ +#ifndef REDPILL_IOSCHEDULER_FIXER_H +#define REDPILL_IOSCHEDULER_FIXER_H + +int reset_elevator(void); + +#endif //REDPILL_IOSCHEDULER_FIXER_H diff --git a/redpill_main.c b/redpill_main.c index a3d1cc7..874f042 100644 --- a/redpill_main.c +++ b/redpill_main.c @@ -63,6 +63,7 @@ static int __init init_(void) || (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 = initialize_stealth(¤t_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;