lkml.org 
[lkml]   [2019]   [Feb]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectUnremovable kernel module with one line of code.
From
Date
All is needed in a kernel module to make it unremovable without a
reboot is a single line of code. This should not be possible IMHO.

#include <linux/module.h> /* Needed by all modules */
#include <linux/kernel.h> /* Needed for KERN_INFO */

int init_module(void)
{
printk(KERN_INFO "Hello world.\n");
THIS_MODULE->name[0]=0x41; //or any other character than "h"
return 0;
}

void cleanup_module(void)
{
printk(KERN_INFO "Goodbye world.\n");
}

After the modue "hello.ko" is loaded, changing the first letter of the
module name to anything different than the original first letter of the
module names causes it to be unremovable by using rmmod or modprobe -r.
The only way I found so far is (obviously) a reboot.

Solution:
when installing a module, the kernel should assign it an unchangeable
ID. Afterwards, it should always be possible to remove it using that id
and not the name.
[unhandled content-type:application/pgp-signature]
\
 
 \ /
  Last update: 2019-02-08 13:07    [W:0.024 / U:3.884 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site