linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Unremovable kernel module with one line of code.
@ 2019-02-08 12:06 Zibri
  0 siblings, 0 replies; only message in thread
From: Zibri @ 2019-02-08 12:06 UTC (permalink / raw)
  To: linux-kernel

[-- Attachment #1: Type: text/plain, Size: 915 bytes --]

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.

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 455 bytes --]

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2019-02-08 12:06 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-08 12:06 Unremovable kernel module with one line of code Zibri

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).