insmod:插入内核模块时出错

问题描述 投票:1回答:2

我正在尝试实现一个内核模块,该模块可以访问用户进程的task_struct,该进程的进程ID已经为我所知。我正在使用find_get_pidpid_task来获取进程的task_struct:

#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/sched.h>
#include <linux/pid.h>
#include <linux/pid_namespace.h>

int init_module( void )
{
//Declaring the variables
    int p_id = 6980;    //6980 is the process ID of my user process
    struct pid *pid_struct;
    struct task_struct *task;

// Trying to access the variables of the p_id
    pid_struct = find_get_pid(p_id);
    task = pid_task(pid_struct, PIDTYPE_PID);

//Printing the info from the task_struct
    printk( KERN_INFO "*** [%d]\n",task->pid);
    return 0;
}

void cleanup_module( void )
{
  return;
}

它正在成功编译,并且正在获取* .ko文件,但是当我尝试将其插入内核时,它给了我一个错误:insmod: error inserting 'main.ko': -1 Unknown symbol in moduleDmesg给我以下输出:main: Unknown symbol find_get_pid (err 0)我不知道如何进行,如果有人可以帮助我,将不胜感激。

c linux-kernel kernel-module kernel
2个回答
2
投票
还请记住,“核心内核”(大概包括frob_task_by_pid_hard及其类似物)中的大部分都是纯GPL的,因此,除非您将模块的许可证声明为GPL,否则您将无处可寻。也要这样填写模块上的其他样板数据:MODULE_AUTHOR,MODULE_DESCRIPTION,MODULE_LICENSE至少。

1
投票
sudo apt安装mokutilsudo mokutil --disable-validation或者,您可以搜索特定操作系统的如何禁用安全启动选项。
© www.soinside.com 2019 - 2024. All rights reserved.