xairy / linux-kernel-exploitation

A collection of links related to Linux kernel security and exploitation

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Please! Help me...

Sn0keR4xor opened this issue · comments

Hello, i'm starting do learn linux kernel exploitation, and for somehow, i need to dynamically set different at run-time of kernel using sysctl syscall, but for values of parameters that aren't listed on #include <linux/sysctl.h> I don't know how to change!!! Please help me with some ideas!!!

The code:

#define _GNU_SOURCE

#include <unistd.h>
#include <sys/syscall.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <linux/sysctl.h>


int _sysctl(struct __sysctl_args *args);

int main(void) {
	int name [] = {CTL_VM, VM_MEMORY_FAILURE_RECOVERY};
	int namelen = 2;
	int oldval[8];
	size_t len = sizeof(oldval);
	int error;
    error = sysctl (name, namelen, (void *)oldval, &len, 0 , 4);
	if (error == -1){
        perror("_sysctl");
        exit(EXIT_FAILURE);
	} else {
        printf("Changed value!");
        exit(EXIT_SUCCESS);
	}
}

For another parameters listed on header file it accepts to change, but not for parameters listed on /proc/sys/vm that aren't in header!

直接跑命令不就完了

system("sysctl vm.memory_failure_recovery=1");