A system call is used by programs to request services from the operating system's kernel.
Questions tagged [system-calls]
3690 questions
1
vote
1 answer
why setuid fails after capset is used?
trying to figure out the linux capabilities interface, i came across with an unexpected issue (for me at least). When seting the capabilities of a process with the capset syscall the kernel rejects a change of userid with the setuid syscall. Does…

Lino Bossio
- 103
- 1
- 8
1
vote
1 answer
filesystem fd from file fd
My program opens a file and wants to set O_DIRECT for it. But the program assumes block size of 512. So, I need to check for that size. man 2 open suggests to do it like this ioctl(filesystem_fd, BLKSSZGET, &block_size).
And my question is: how to…

Eugene Kosov
- 993
- 7
- 15
1
vote
2 answers
What are the __NR_-prefixed symbols in glibc?
I'm trying to compile Box86 on Alpine Linux, a Linux distribution which uses the musl libc implementation rather than glibc. At 46% completion, the compilation halts with the following errors:
/home/newbyte/box86/src/emu/x86syscall.c:124:11: error:…

Newbyte
- 2,421
- 5
- 22
- 45
1
vote
1 answer
C syscall() cannot accept void pointers
I am working on a dynamic language written in go. I am using C to allow this language to access syscalls (for linux at least). C's any type is a void*, so I thought that I can pass them into a syscall. I tested using some code which looks…

Ank i zle
- 2,089
- 3
- 14
- 36
1
vote
1 answer
Performing syscalls in inline C assembly causes a segfault
I recently dabbled into low level programming, and want to make a function somesyscall that accepts (CType rax, CType rbx, CType rcx, CType rdx). struct CType looks like:
/*
TYPES:
0 int
1 string
2 bool
*/
typedef struct…

Ank i zle
- 2,089
- 3
- 14
- 36
1
vote
0 answers
Socket C - Address family not supported by protocol
So I am trying to create a packet sniffer in C. After following the man7 page I inferred that the socket function should look like this
.....
int socketfd = socket(AF_PACKET , SOCK_RAW , htons(ETH_P_ALL));
if(socketfd < 0)
{
perror("Socket…

Patch
- 694
- 1
- 10
- 29
1
vote
0 answers
why Packets are not received via raw socket from all protocol using ETH_P_ALL?
package main
import (
"fmt"
"syscall"
)
func main() { `
fd, err:= syscall.Socket(syscall.AF_PACKET, syscall.SOCK_RAW, syscall.ETH_P_ALL) //opening raw socket
if (err != nil) {
fmt.Println("Error: " + err.Error())
return;
}
…

nivetha a
- 11
- 1
1
vote
1 answer
Error when copying data from kernel to user space using copy_to_user()
#include
#include
unsigned long long cnt = 0;
asmlinkage long sys_customcall(unsigned long long __user *output)
{
unsigned long err;
err = copy_to_user(output, &cnt, sizeof(unsigned long…

SY LEE
- 11
- 2
1
vote
1 answer
Meaning of 'vector' in asm context
For something like:
int $0x80
I understand that it is executing the int instruction on the destination operand value 0x80 or 128. And, if I'm understanding correctly, 128 is a system call and it'll execute the call that is stored in eax. However,…

samuelbrody1249
- 4,379
- 1
- 15
- 58
1
vote
1 answer
Search for bad sectors of a device in C
I'm trying to create a simple script in c which is able to identify bad sectors of (a device) for educational purpose. In my example, I use an HD with read-only mode. The idea behind is simple, but maybe too simple and I would know if this is…

Virgula
- 318
- 4
- 12
1
vote
1 answer
Remote mmap syscall using ptrace (Linux, C)
I've been stuck with this problem for some days, and still haven't manage to fix it. Basically, I want to do a remote syscall from an attacker program to the target. But before showing the code, I think it'd be a good idea to present my thought…

rdbo
- 144
- 10
1
vote
2 answers
Why doesn't readlink return a null-terminated value?
Both The Single UNIX ® Specification, Version 2 (1997) and The Open Group Base Specifications Issue 6 (2004) require that readlink would not place a null-terminated value in buffer:
APPLICATION USAGE
Conforming applications should not assume that…

Yam Mesicka
- 6,243
- 7
- 45
- 64
1
vote
1 answer
replacing system() with execl() : when do I need to use fork()?
I am trying to call an external program from within my C program. I understand that calling system() is a bad habit. I've been reading up on how to use execl() or execv() to replace system(), but due to my limited brain capacity, I would like to…

kwantum
- 59
- 6
1
vote
3 answers
My ifstream doesn't seem to be working
This is a main file that I am using to test methods before I implement them. I am trying to get the list of all files in a directory, write them to a txt file (It works fine until here), then read the file names from that text file.
using namespace…

mrswmmr
- 2,081
- 5
- 21
- 23
1
vote
1 answer
Understanding how waitpid works with signals
Consider the following Pseudo-C code:
static int G = 0;
void alrm_handler(int signo) {
G = 1;
}
void son() {
struct sched_param param;
param.sched_priority = 50;
sched_setscheduler(getpid(),SCHED_FIFO, ¶m);
kill(getppid(),…

vesii
- 2,760
- 4
- 25
- 71