The purpose is I want my program running on Linux to be terminated when some random process is terminated. I can get PID or process handle of the process that my program is to monitor. Are there any possible approaches that I could take? Answer Linux 5.3 introduced pidfd_open, which lets you get a file descriptor from a PID. The
Tag: system-calls
Linux API: is it possible to specify `O_SYNC` option for a single `write` syscall
Such flags as O_DIRECT, O_SYNC, O_DSYNC can be used to specify synchronous / asynchronous IO at the time when descriptor is created (create syscall). But is it possible to use this flags for distinct write (or similar) syscalls in order to make some of them synchronous? Answer is it possible to use this flags for distinct write (or similar) syscalls
assembly, how to use mprotect?
I am trying to make self modifying code in Linux. I thought it would works but didn’t. I used nasm on ubuntu 18.04. INT 0x80 return value is -22 0xffffffea I don’t know what is wrong. Answer Run your program under strace, like strace ./a.out to decode system call args and return values. Probably your base address isn’t page-aligned, or
BUG: unable to handle kernel paging request when accessing a custom struct in syscall
Using linux with kernel 4.4.21, I was required to implement a system call which has a custom struct’s pointer among its parameters. These are the files to to edit: I put sys_procmem.c (implementation) in linux-4.4.21/kernel/sys_procmem.c (sys_procmem.o added in that dir’s Makefile): Test: Both were killed miserably. dmesg: This was done inside a 64-bit Ubuntu 14.04 virtual machine. My friends had
How are parameters passed to Linux system call ? Via register or stack?
I trying to understand the internals of the Linux kernel by reading Robert Love’s Linux Kernel Development. On page 74 he says the easiest way to pass arguments to a syscall is via : Somehow, user-space must relay the parameters to the kernel during the trap.The easiest way to do this is via the same means that the syscall number
More explanation on `statfs64`
According to documentation, the structure fields explanation follows: Does “total file nodes in file system” mean how much existing files we have? Does it include directories and links? What does mean “free file nodes in fs”? What is f_spare? In some Linux forks (for example, in Android) I see that f_spare size is 4, and additional field f_flags is defined.
Problem doing a system call, the system call is not displaying to kernel
In Ubuntu, I wrote a new system call: This is my testing file: But the testing file is good. The system call is not doing anything and I cannot see why. What am I supposed to do that I am doing wrong? I don’t really have anything left to find. I checked the testing file and it runs properly. It
Understanding read syscall
I’m reading man read manual page and discovered that it was possible to read less then the desired number of bytes passed in as a parameter: It is not an error if this number is smaller than the number of bytes requested; this may happen for example because fewer bytes are actually available right now (maybe because we were close
Errors when executing execute_command_line() in a Fortran code
I have wrote down Fortran code to calculate the distance and then sorting, but there is some problem in calling executable command. Here is the code The input file is a.gro outfile file 3, dist.txt so, I want to sort r(i,j), keeping i same j different.but call line is not working in fortran code. error that is coming Please let
How can I find all syscalls that have to be whitelisted for seccomp?
I have an existing program that I would like to sandbox using seccomp (v2). How can I find what seccomp rules I need to allow for the program? I’ve tried adding seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(…), 0) for all syscalls printed by strace -xfc a.out, but apparently that wasn’t enough, since I’m still getting “SIGSYS, Bad system call” when I run the