kernelnewbies.kernelnewbies.org archive mirror
 help / color / mirror / Atom feed
From: geraint0923@gmail.com (Geraint Yang)
To: kernelnewbies@lists.kernelnewbies.org
Subject: How to hook the system call?
Date: Thu, 24 Nov 2011 00:50:25 +0800	[thread overview]
Message-ID: <CAAdM-RXuuDewT3rqvYubHqtdCzBQPSp+cdwcYKS5KYLwxmkkcA@mail.gmail.com> (raw)
In-Reply-To: <CALJfu6NR-Qo5E_AZu-D8o33nzgtVEHwE9398v4Yh-oxr97muZg@mail.gmail.com>

Hi,
Thank all of you for helping me with problem!
I don't want to modify my kernel source so I am trying to learn to use LSM
security hook even though it seems that it couldn't hook all the system
calls, I think it should be enough for me.
Thanks again!



On Wed, Nov 23, 2011 at 8:02 PM, rohan puri <rohan.puri15@gmail.com> wrote:

>
>
> On Wed, Nov 23, 2011 at 3:57 PM, Alexandru Juncu <alex.juncu@rosedu.org>wrote:
>
>> On Wed, Nov 23, 2011 at 12:10 PM, Daniel Baluta <daniel.baluta@gmail.com>
>> wrote:
>> > On Wed, Nov 23, 2011 at 11:22 AM, Alexandru Juncu <
>> alex.juncu at rosedu.org> wrote:
>> >> On Wed, Nov 23, 2011 at 10:40 AM, Geraint Yang <geraint0923@gmail.com>
>> wrote:
>> >>> Hello everyone,
>> >>>
>> >>> I am going to hook a system call like 'read' or 'send' by modifying
>> the
>> >>> sys_call_table, but it seems that the sys_call_table is in read only
>> page,
>> >>> how can I set modify the sys_call_table ? Or if there any method that
>> I can
>> >>> use to hook a system call in module without modify the kernel source?
>> >>>
>> >>> Thanks!
>> >>
>> >> On a 2.6.35 kernel, it worked for me just by changing an entry in the
>> >> sys_call_table, within a kernel module.  Something like this:
>> >
>> > Alex,
>> > I am pretty sure that you are using a hacked version of 2.6.35.
>> >
>> > Geraint,
>> > In order to be able to hook a syscall you must do the following:
>> >
>> > 1. export syscall_table in arch/x86/kernel/i386_ksyms_32.c
>> >
>> > extern void* sys_call_table[];
>> > EXPORT_SYMBOL(sys_call_table);
>> >
>> > 2. make sys_call_table writebale. In arch/x86/kernel/entry_32.S
>> > you must have:
>> >
>> > .section .data,"a"
>> > #include "syscall_table_32.S"
>> >
>> > thanks,
>> > Daniel.
>> >
>>
>> Ah, Daniel is right... I forgot about that part...
>>
>> _______________________________________________
>> Kernelnewbies mailing list
>> Kernelnewbies at kernelnewbies.org
>> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>>
>
> You can get the address of the sys_call_table from the /proc/kallsyms and
> regarding the read-only section of the this symbol you can re-map the
> addresses by making use of vmap api in kernel. This will avoid the need for
> the compilation of the kernel. But I would not recommend you to do this.
> Their is LSM framework specifically available for this try to see if you
> can make use of that.
>
> Regards,
> Rohan Puri
>



-- 
Geraint Yang
Tsinghua University Department of Computer Science and Technology
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20111124/da051d01/attachment-0001.html 

  reply	other threads:[~2011-11-23 16:50 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-23  8:40 How to hook the system call? Geraint Yang
2011-11-23  9:22 ` Alexandru Juncu
2011-11-23 10:10   ` Daniel Baluta
2011-11-23 10:27     ` Alexandru Juncu
2011-11-23 12:02       ` rohan puri
2011-11-23 16:50         ` Geraint Yang [this message]
2011-11-23 16:59           ` Alexandru Juncu
2011-11-23 18:05             ` Geraint Yang
2011-11-23 18:20               ` Nuno Martins
2011-11-24  4:04               ` rohan puri
2011-11-27 22:17 ` Jonathan Neuschäfer
2011-11-28  1:12   ` richard -rw- weinberger
2011-11-28  2:12     ` Geraint Yang
2011-11-28  9:48     ` Jonathan Neuschäfer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAAdM-RXuuDewT3rqvYubHqtdCzBQPSp+cdwcYKS5KYLwxmkkcA@mail.gmail.com \
    --to=geraint0923@gmail.com \
    --cc=kernelnewbies@lists.kernelnewbies.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).