1

Trying to implemented syscall in kernel space and wrapper in glibc so I can call from userspace. When I call the function call in user program it says "Function not implemented".

I have modified glibc and linux code to add function called vroperation.

In GLIBC:

glibc/srcdir/sysdeps/unix/sysv/linux/sys/syscall.h:26:#ifndef __NR_vroperation
glibc/srcdir/sysdeps/unix/sysv/linux/sys/syscall.h:36:#define __NR_vroperation 285
glibc/srcdir/sysdeps/unix/sysv/linux/sys/syscall.h:40:#define __NR_vroperation  338
glibc/srcdir/sysdeps/unix/sysv/linux/sys/syscall.h:44:#endif  /* __NR_vroperation */
glibc/srcdir/sysdeps/unix/syscalls.list:91:vroperation  -       vroperation     i:iii   __vroperation   vroperation
glibc/srcdir/sysdeps/generic/vroperation.c:25:__vroperation (int vr_index, int oper, int flags)
glibc/srcdir/sysdeps/generic/vroperation.c:30:stub_warning (vroperation)
glibc/srcdir/sysdeps/generic/vroperation.c:32:weak_alias (__vroperation, vroperation)
glibc/srcdir/conform/data/unistd.h-data:603:function int vroperation(int, int, int);
glibc/srcdir/include/unistd.h:198:extern int __vroperation(int __vr_index, int __oper, int __flags);
glibc/srcdir/posix/unistd.h:686:extern int vroperation (int __vr_index, int __oper, int __flags) __THROW;
glibc/srcdir/posix/Versions:111:    vroperation;
glibc/srcdir/posix/Makefile:180:  vroperation \
glibc/srcdir/posix/annexc.c:544:  "ttyname_r", "unlink", "vroperation", "write"

In LINUX:

arch/x86/entry/syscalls/syscall_64.tbl:361:338  64      vroperation             __x64_sys_vroperation
arch/x86/entry/syscalls/syscall_32.tbl:300:285  i386    vroperation             sys_vroperation                 __ia32_sys_vroperation
kernel/sys.c:2527:SYSCALL_DEFINE3(vroperation, int, vr_index, int, oper, int, flags)
kernel/sys_ni.c:185:COND_SYSCALL(vroperation);

When I run Strace:

execve("/tmp/vroperation", ["/tmp/vroperation", "delete", "0"], 0x7fffaa0d51e0 /* 23 vars */) = 0
/tmp/strace: [ Process PID=19284 runs in 32 bit mode. ]
brk(NULL)                               = 0x9e63000
brk(0x9e63880)                          = 0x9e63880
set_thread_area({entry_number=-1, base_addr=0x9e63380, limit=0x0fffff, seg_32bit=1, contents=0, read_exec_only=0, limit_in_pages=1, seg_not_present=0, useable=1}) = 0 (entry_number=12)
set_tid_address(0x9e633e8)              = 19284
set_robust_list(0x9e633ec, 12)          = 0
rseq(0x9e63820, 0x20,
ugetrlimit(RLIMIT_STACK, {rlim_cur=8192*1024, rlim_max=RLIM_INFINITY}) = 0
readlinkat(AT_FDCWD, "/proc/self/exe", "/var/tmp/vroperation", 4096) = 20
getrandom("\xbd\x59\x2c\xbd", 4, GRND_NONBLOCK) = 4
brk(NULL)                               = 0x9e63880
brk(0x9e84880)                          = 0x9e84880
brk(0x9e85000)                          = 0x9e85000
mprotect(0x80d9000, 12288, PROT_READ)   = 0
dup(2)                                  = 3
fcntl64(3, F_GETFL)                     = 0x2 (flags O_RDWR)
statx(3, "", AT_STATX_SYNC_AS_STAT|AT_NO_AUTOMOUNT|AT_EMPTY_PATH, STATX_BASIC_STATS, {stx_mask=STATX_BASIC_STATS, stx_attributes=0, stx_mode=S_IFCHR|0622, stx_size=0, ...}) = 0
write(3, "vroperation: Function not implem"..., 38vroperation: Function not implemented
) = 38
close(3)                                = 0
brk(0x9e84000)                          = 0x9e84000
exit_group(1)                           = ?
+++ exited with 1 +++

Trying to implement syscall in kernel and wraper in glibc which can be called in userspace.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.