How to stop init_module: linux kernel

I have a program as shown below.

test_module.c

#include <linux/version.h>
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/delay.h>

int init_module(void)
{
        while(1) {
                pr_info("hello 4 sec\n");
                msleep(4 * 1000);
        }
        return 0;
}

void cleanup_module(void)
{
        pr_info("module removed successful\n");
}

When I load this module, my terminal freezes / locks. How to stop this program. I tried sudo rmmod test_modulebut did not use. So I rebooted my system. How to break init_module? In the future, if something goes wrong, and if mine init_moduledoes not end, what should I do? And what happens if we don't stop at init_module?

+4
source share
1 answer

Reboot the computer.

This is the only way. User land processes are isolated and can be forcibly terminated, all of this, but there are no such protections in the kernel.

init_module . .

- , tasklet worqueue, . . linux. , ( , ).

+5

Source: https://habr.com/ru/post/1542035/


All Articles