Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 559987
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T12:17:43+00:00 2026-05-13T12:17:43+00:00

I’m trying to write some simple test code as a demonstration of hooking the

  • 0

I’m trying to write some simple test code as a demonstration of hooking the system call table.

“sys_call_table” is no longer exported in 2.6, so I’m just grabbing the address from the System.map file, and I can see it is correct (Looking through the memory at the address I found, I can see the pointers to the system calls).

However, when I try to modify this table, the kernel gives an “Oops” with “unable to handle kernel paging request at virtual address c061e4f4” and the machine reboots.

This is CentOS 5.4 running 2.6.18-164.10.1.el5. Is there some sort of protection or do I just have a bug? I know it comes with SELinux, and I’ve tried putting it in to permissive mode, but it doesn’t make a difference

Here’s my code:

#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/unistd.h>

void **sys_call_table;

asmlinkage int (*original_call) (const char*, int, int);

asmlinkage int our_sys_open(const char* file, int flags, int mode)
{
   printk("A file was opened\n");
   return original_call(file, flags, mode);
}

int init_module()
{
    // sys_call_table address in System.map
    sys_call_table = (void*)0xc061e4e0;
    original_call = sys_call_table[__NR_open];

    // Hook: Crashes here
    sys_call_table[__NR_open] = our_sys_open;
}

void cleanup_module()
{
   // Restore the original call
   sys_call_table[__NR_open] = original_call;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T12:17:44+00:00Added an answer on May 13, 2026 at 12:17 pm

    I finally found the answer myself.

    http://www.linuxforums.org/forum/linux-kernel/133982-cannot-modify-sys_call_table.html

    The kernel was changed at some point so that the system call table is read only.

    cypherpunk:

    Even if it is late but the Solution
    may interest others too: In the
    entry.S file you will find: Code:

    .section .rodata,"a"
    #include "syscall_table_32.S"
    

    sys_call_table -> ReadOnly You have to
    compile the Kernel new if you want to
    “hack” around with sys_call_table…

    The link also has an example of changing the memory to be writable.

    nasekomoe:

    Hi everybody. Thanks for replies. I
    solved the problem long ago by
    modifying access to memory pages. I
    have implemented two functions that do
    it for my upper level code:

    #include <asm/cacheflush.h>
    #ifdef KERN_2_6_24
    #include <asm/semaphore.h>
    int set_page_rw(long unsigned int _addr)
    {
        struct page *pg;
        pgprot_t prot;
        pg = virt_to_page(_addr);
        prot.pgprot = VM_READ | VM_WRITE;
        return change_page_attr(pg, 1, prot);
    }
    
    int set_page_ro(long unsigned int _addr)
    {
        struct page *pg;
        pgprot_t prot;
        pg = virt_to_page(_addr);
        prot.pgprot = VM_READ;
        return change_page_attr(pg, 1, prot);
    }
    
    #else
    #include <linux/semaphore.h>
    int set_page_rw(long unsigned int _addr)
    {
        return set_memory_rw(_addr, 1);
    }
    
    int set_page_ro(long unsigned int _addr)
    {
        return set_memory_ro(_addr, 1);
    }
    
    #endif // KERN_2_6_24
    

    Here’s a modified version of the original code that works for me.

    #include <linux/kernel.h>
    #include <linux/module.h>
    #include <linux/moduleparam.h>
    #include <linux/unistd.h>
    #include <asm/semaphore.h>
    #include <asm/cacheflush.h>
    
    void **sys_call_table;
    
    asmlinkage int (*original_call) (const char*, int, int);
    
    asmlinkage int our_sys_open(const char* file, int flags, int mode)
    {
       printk("A file was opened\n");
       return original_call(file, flags, mode);
    }
    
    int set_page_rw(long unsigned int _addr)
    {
       struct page *pg;
       pgprot_t prot;
       pg = virt_to_page(_addr);
       prot.pgprot = VM_READ | VM_WRITE;
       return change_page_attr(pg, 1, prot);
    }
    
    int init_module()
    {
        // sys_call_table address in System.map
        sys_call_table = (void*)0xc061e4e0;
        original_call = sys_call_table[__NR_open];
    
        set_page_rw(sys_call_table);
        sys_call_table[__NR_open] = our_sys_open;
    }
    
    void cleanup_module()
    {
       // Restore the original call
       sys_call_table[__NR_open] = original_call;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 357k
  • Answers 357k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer The other answers are correct. Here is some code you… May 14, 2026 at 9:40 am
  • Editorial Team
    Editorial Team added an answer you ruin the noConflict concept by reassigning the jquery to… May 14, 2026 at 9:40 am
  • Editorial Team
    Editorial Team added an answer If you get that particular error, you don't actually have… May 14, 2026 at 9:40 am

Related Questions

No related questions found

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.