Skip to content

antoniakras/custom-linux-kernel

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

🖥️ Linux Kernel System Calls: Set/Get Task Parameters

📖 About

This project involves modifying the Linux 2.6.38.1 kernel to implement two new system calls: set_task_params and get_task_params. The goal is to gain hands-on experience with:

  • Kernel source code exploration and modification
  • Adding custom system calls to Linux
  • Compiling and booting a modified kernel using QEMU
  • User-space interaction with custom kernel functionality

These system calls allow setting and retrieving custom task-specific parameters (group_name and member_id) for processes, demonstrating low-level OS development, memory-safe user-kernel communication, and kernel data structure manipulation.


✨ Features & Technical Highlights

  • New System Calls

    • set_param_sys: Sets task-specific parameters (group name, member ID) for the current process.
    • get_param_sys: Retrieves these parameters for a given task.
    • dummy_sys: A placeholder system call for testing kernel modifications.
  • Kernel Modifications

    • include/linux/sched.h: Added group_name and member_id fields to task_struct.
    • arch/x86/include/asm/unistd_32.h: Defined system call numbers for new calls.
    • arch/x86/kernel/syscall_table_32.S: Linked new system calls to kernel syscall table.
    • include/asm-generic/syscalls.h: Declared prototypes for new system calls.
    • kernel/Makefile: Included new .o files for compilation.
    • New files: dummy_sys.c, get_param_sys.c, set_param_sys.c.
    • kernel/d_params.h: Defined struct d_params { char group_name; int member_id; }.
  • User-Space Integration

    • Modified /usr/include/unistd.h in QEMU to include struct d_params for testing.
    • Demonstrates safe access to kernel memory using get_current() and copy_to_user().
  • Testing Environment

    • Compiled the modified kernel on the host OS.
    • Loaded and ran the kernel in QEMU, verifying that the new system calls work correctly.
    • Example user programs can call set_param_sys and get_param_sys to manipulate and retrieve task parameters.

🧠 Implementation Details

  • Set Params: Accesses the current task (get_current()) and sets group_name and member_id according to the function parameters.
  • Get Params: Copies the values from the task struct to a user-space struct d_params using copy_to_user().
  • Compilation & Configuration: Used the provided .config file, modifying CONFIG_LOCALVERSION to include the username, ensuring the custom kernel can be distinguished in QEMU.
  • QEMU Testing: Verified functionality by running multiple user-space test programs that set and get task parameters.

🛠️ Setup & Run

  1. Copy and extract the kernel source:
    cp ~hy345/qemu-linux/linux-2.6.38.1-patched.tar.bz2 /spare/[username]/
    tar xvjf linux-2.6.38.1-patched.tar.bz2
    cd linux-2.6.38.1
    cp /path/to/provided/config .config
        # Use the provided .config file and modify CONFIG_LOCALVERSION:
        # Edit CONFIG_LOCALVERSION += "_username"
        # Compile the Kernel
    make
        # Boot QEMU with the new kernel image and test using user-level programs that call set_param_sys and get_param_sys.
     

Releases

No releases published

Packages

No packages published