Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

当我使用kp_malloc或者vmalloc时模块加载失败 #133

Open
SoyBeanMilkx opened this issue Oct 25, 2024 · 0 comments
Open

当我使用kp_malloc或者vmalloc时模块加载失败 #133

SoyBeanMilkx opened this issue Oct 25, 2024 · 0 comments

Comments

@SoyBeanMilkx
Copy link

Currently, there is no immediate solution. You need to troubleshoot it yourself or provide the device to me for further investigation.
代码时kpms里的demo
#include <compiler.h>
#include <kpmodule.h>
#include <linux/printk.h>
#include <common.h>
#include <kputils.h>
#include <linux/string.h>
#include <kpmalloc.h>

KPM_NAME("kpm-hello-demo");
KPM_VERSION("1.0.0");
KPM_LICENSE("GPL v2");
KPM_AUTHOR("bmax121");
KPM_DESCRIPTION("KernelPatch Module Example");

static long hello_init(const char *args, const char *event, void *__user reserved)
{
pr_info("kpm hello init, event: %s, args: %s\n", event, args);
pr_info("kernelpatch version: %x\n", kpver);
return 0;
}

static long hello_control0(const char *args, char *__user out_msg, int outlen)
{
pr_info("kpm hello control0, args: %s\n", args);
char echo[64] = "echo: ";
strncat(echo, args, 48);
compat_copy_to_user(out_msg, echo, sizeof(echo));
return 0;
}

static long hello_control1(void a1, void a2, void a3)
{
/char str = (char
)kp_malloc(sizeof(char) * 10);
kp_free(str);
/
int
arr = kp_malloc(sizeof(int) * 10);
kp_free(arr);
pr_info("kpm hello control1, a1: %llx, a2: %llx, a3: %llx\n", a1, a2, a3);
return 0;
}

static long hello_exit(void *__user reserved)
{
pr_info("kpm hello exit\n");
return 0;
}

KPM_INIT(hello_init);
KPM_CTL0(hello_control0);
KPM_CTL1(hello_control1);
KPM_EXIT(hello_exit);

只是加了这段,模块就无法加载了
/char str = (char*)kp_malloc(sizeof(char) * 10);
kp_free(str);/
int
arr = kp_malloc(sizeof(int) * 10);
kp_free(arr);
请问这个是什么原因呢?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant