From: Zoltan Menyhart <Zoltan.Menyhart_AT_bull.net@nospam.org>
To: linux-kernel@vger.kernel.org, linux-ia64@vger.kernel.org
Subject: Dynamic System Calls & System Call Hijacking - demo syscall
Date: Tue, 20 Apr 2004 11:09:19 +0200 [thread overview]
Message-ID: <4084E8BF.2CEAE31F@nospam.org> (raw)
[-- Attachment #1: Type: text/plain, Size: 1 bytes --]
[-- Attachment #2: foo.c --]
[-- Type: text/plain, Size: 1286 bytes --]
/*
* Demo dynamic syscall
*/
#include <linux/module.h>
#include <asm/dyn_syscall.h>
const char name[] = "foo";
asmlinkage long
sys_foo(const int cmd, const caddr_t address, const size_t length,
const int node, const pid_t pid)
{
printk("\nsys_foo(%d, 0x%p, 0x%lx, %d, %d)\n",
cmd, address, length, node, pid);
return 0;
}
int syscall;
static int __init
init_foo(void)
{
int rc;
printk("\nModule Foo\n");
rc = dyn_syscall_reg(name, 0, (dyn_syscall_t) sys_foo);
printk("dyn_syscall_reg() returned: %d\n", rc);
if (rc < 0)
return rc;
syscall = rc;
rc = syscall_unlock(name, syscall);
if (rc < 0)
panic("syscall_unlock() returned: %d\n", rc);
return 0;
}
static void __exit
exit_foo(void)
{
printk("\nModule Foo getting unloaded\n");
int rc;
rc = prep_restore_syscall(name, syscall);
if (rc < 0)
panic("prep_restore_syscall() returned: %d\n", rc);
while((rc = syscall_trylock(name, syscall)) == -EAGAIN){
/*
* Having some blocking syscalls? Don't just busy wait,
* wake them up, sleep a bit in the mean time.
*/
}
if (rc < 0)
panic("syscall_trylock() returned: %d\n", rc);
rc = dyn_syscall_unreg(name, syscall);
if (rc < 0)
panic("dyn_syscall_unreg() returned: %d\n", rc);
}
module_init(init_foo);
module_exit(exit_foo);
reply other threads:[~2004-04-20 9:20 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=4084E8BF.2CEAE31F@nospam.org \
--to=zoltan.menyhart_at_bull.net@nospam.org \
--cc=Zoltan.Menyhart@bull.net \
--cc=linux-ia64@vger.kernel.org \
--cc=linux-kernel@vger.kernel.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