Trying to add a new system call in linux kernel 4.18.13, but failed to pass function parameters
Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
Ubuntu18, linux kernel 4.18.13
I added a new system call with following steps:
1. edit ./arth/x86/entry/syscalls/syscall_64.tbl
401 common my_syscall sys_my_syscall
- edit ./arth/x86/include/asm/syscalls.h
asmlinkage int sys_my_syscall(...)
- and the ./mine/my_syscall.c, ./mine/my_syscall.h:
my_syscall.c
#include <linux/linkage.h>
asmlinkage int sys_my_syscall(int n)
printk("test %dn", n);
return n;
my_syscall.h
#ifndef HELLO_WORLD_H
#define HELLO_WORLD_H
asmlinkage int sys_my_syscall(int n);
#endif
then use Makefile to make the new files in step 3.
compile the kernel.
try my syscall with the following program:
#include <stdio.h>
#include <linux/unistd.h>
int main()
int ret = syscall(401, 20);
printf("ret %dn", ret);
return 0;
And the syscall is successfully called. I can see the "test xxx" and "ret xxx" on my terminal. However, the parameter I pass into the syscall was wrong -- it is always an undefined number, 1018123134, -2021134452, and so on.
see step 2 above:
- edit ./arth/x86/include/asm/syscalls.h
asmlinkage int sys_my_syscall(...)
You see (...), where I tried (char*), (int), (int, int), (char*, int) but none of them can make it correct. I dont know the principle here. Or maybe the problem is caused by other mistakes?
However, my friend tried the same method but succeeded in linux kernel 4.7.x! How could that be?
I have tried to search by google but failed to find the same problem. Could anyone help me to pass the parameter to my syscall? Thanks very much!
Ubuntu18, linux kernel 4.18.13
linux linux-kernel system-calls
New contributor
add a comment |Â
up vote
0
down vote
favorite
Ubuntu18, linux kernel 4.18.13
I added a new system call with following steps:
1. edit ./arth/x86/entry/syscalls/syscall_64.tbl
401 common my_syscall sys_my_syscall
- edit ./arth/x86/include/asm/syscalls.h
asmlinkage int sys_my_syscall(...)
- and the ./mine/my_syscall.c, ./mine/my_syscall.h:
my_syscall.c
#include <linux/linkage.h>
asmlinkage int sys_my_syscall(int n)
printk("test %dn", n);
return n;
my_syscall.h
#ifndef HELLO_WORLD_H
#define HELLO_WORLD_H
asmlinkage int sys_my_syscall(int n);
#endif
then use Makefile to make the new files in step 3.
compile the kernel.
try my syscall with the following program:
#include <stdio.h>
#include <linux/unistd.h>
int main()
int ret = syscall(401, 20);
printf("ret %dn", ret);
return 0;
And the syscall is successfully called. I can see the "test xxx" and "ret xxx" on my terminal. However, the parameter I pass into the syscall was wrong -- it is always an undefined number, 1018123134, -2021134452, and so on.
see step 2 above:
- edit ./arth/x86/include/asm/syscalls.h
asmlinkage int sys_my_syscall(...)
You see (...), where I tried (char*), (int), (int, int), (char*, int) but none of them can make it correct. I dont know the principle here. Or maybe the problem is caused by other mistakes?
However, my friend tried the same method but succeeded in linux kernel 4.7.x! How could that be?
I have tried to search by google but failed to find the same problem. Could anyone help me to pass the parameter to my syscall? Thanks very much!
Ubuntu18, linux kernel 4.18.13
linux linux-kernel system-calls
New contributor
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
Ubuntu18, linux kernel 4.18.13
I added a new system call with following steps:
1. edit ./arth/x86/entry/syscalls/syscall_64.tbl
401 common my_syscall sys_my_syscall
- edit ./arth/x86/include/asm/syscalls.h
asmlinkage int sys_my_syscall(...)
- and the ./mine/my_syscall.c, ./mine/my_syscall.h:
my_syscall.c
#include <linux/linkage.h>
asmlinkage int sys_my_syscall(int n)
printk("test %dn", n);
return n;
my_syscall.h
#ifndef HELLO_WORLD_H
#define HELLO_WORLD_H
asmlinkage int sys_my_syscall(int n);
#endif
then use Makefile to make the new files in step 3.
compile the kernel.
try my syscall with the following program:
#include <stdio.h>
#include <linux/unistd.h>
int main()
int ret = syscall(401, 20);
printf("ret %dn", ret);
return 0;
And the syscall is successfully called. I can see the "test xxx" and "ret xxx" on my terminal. However, the parameter I pass into the syscall was wrong -- it is always an undefined number, 1018123134, -2021134452, and so on.
see step 2 above:
- edit ./arth/x86/include/asm/syscalls.h
asmlinkage int sys_my_syscall(...)
You see (...), where I tried (char*), (int), (int, int), (char*, int) but none of them can make it correct. I dont know the principle here. Or maybe the problem is caused by other mistakes?
However, my friend tried the same method but succeeded in linux kernel 4.7.x! How could that be?
I have tried to search by google but failed to find the same problem. Could anyone help me to pass the parameter to my syscall? Thanks very much!
Ubuntu18, linux kernel 4.18.13
linux linux-kernel system-calls
New contributor
Ubuntu18, linux kernel 4.18.13
I added a new system call with following steps:
1. edit ./arth/x86/entry/syscalls/syscall_64.tbl
401 common my_syscall sys_my_syscall
- edit ./arth/x86/include/asm/syscalls.h
asmlinkage int sys_my_syscall(...)
- and the ./mine/my_syscall.c, ./mine/my_syscall.h:
my_syscall.c
#include <linux/linkage.h>
asmlinkage int sys_my_syscall(int n)
printk("test %dn", n);
return n;
my_syscall.h
#ifndef HELLO_WORLD_H
#define HELLO_WORLD_H
asmlinkage int sys_my_syscall(int n);
#endif
then use Makefile to make the new files in step 3.
compile the kernel.
try my syscall with the following program:
#include <stdio.h>
#include <linux/unistd.h>
int main()
int ret = syscall(401, 20);
printf("ret %dn", ret);
return 0;
And the syscall is successfully called. I can see the "test xxx" and "ret xxx" on my terminal. However, the parameter I pass into the syscall was wrong -- it is always an undefined number, 1018123134, -2021134452, and so on.
see step 2 above:
- edit ./arth/x86/include/asm/syscalls.h
asmlinkage int sys_my_syscall(...)
You see (...), where I tried (char*), (int), (int, int), (char*, int) but none of them can make it correct. I dont know the principle here. Or maybe the problem is caused by other mistakes?
However, my friend tried the same method but succeeded in linux kernel 4.7.x! How could that be?
I have tried to search by google but failed to find the same problem. Could anyone help me to pass the parameter to my syscall? Thanks very much!
Ubuntu18, linux kernel 4.18.13
linux linux-kernel system-calls
linux linux-kernel system-calls
New contributor
New contributor
New contributor
asked 5 mins ago
JM233333
1
1
New contributor
New contributor
add a comment |Â
add a comment |Â
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
JM233333 is a new contributor. Be nice, and check out our Code of Conduct.
JM233333 is a new contributor. Be nice, and check out our Code of Conduct.
JM233333 is a new contributor. Be nice, and check out our Code of Conduct.
JM233333 is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f476189%2ftrying-to-add-a-new-system-call-in-linux-kernel-4-18-13-but-failed-to-pass-func%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password