Questions tagged [system-calls]

Questions concerning the details of how a program uses system calls to interact with the kernel API, what calls are available, how they work etc.

Filter by
Sorted by
Tagged with
0
votes
1answer
35 views

getaddrinfo() return both ipv4 and ipv6 while local system has ipv4 only

I use getaddrinfo(3) to get list ip address from a domain which support both ipv4 and ipv6, but the local system support ipv4 only or both ipv4 & ipv6, As I expect, if system support both ipv4 &...
3
votes
0answers
44 views

What could cause EROFS error for an openat call of a symlinked path, but only sometimes?

I'm trying to debug an issue which I see only intermittently, often only once or twice per server and then it goes away. I have an application which attempts to open a lock file using openat() with ...
0
votes
1answer
19 views

How find out through terminal that if any system command uses specific system call internally?

I am new to linux.I want to that how to find out through terminal that if any system command uses specific system call internally? Suppose hard linking is to be performed . So "ln" command ...
1
vote
0answers
22 views

seccomp-bpf program in linux

my question is can I use seccomp-bpf program widespread in system in Linux? I mean: we can use seccomp in our program or in our child program to filter syscalls for example, OK, now I want to use this ...
0
votes
0answers
8 views

Selinux avc denied read write to shm key

I am new to selinux concept and I want httpd to access shared memory, but some how httpd is not able to access the shared memory, as per audit log the message tells read write is denied for shm class ...
0
votes
0answers
31 views

httpd, avc: denied { unix_read unix_write }

I am new to selinux concept and here I am stuck on how to make httpd perform {unix_read unix_write} Below is the audit log message. type=IPC msg=audit(1624375715.312:4225): ouid=0 ogid=0 mode=0666 obj=...
0
votes
0answers
28 views

Strace displaying results in ASCII only at process ending and not runtime

I'm searching a way for strace to print the content of the write(...) syscall to ASCII and not useless bytes ! The Strace command I use : sudo strace -e write=1 -e trace=write -s9999 -p 551 2>&...
1
vote
1answer
46 views

how to declare a new variable in vvar.h |create a vdso in linux

I am trying to declare a new variable in vvar.h and define it near my new VDSO function. So that I could use this variable in my vdso function. I have a trouble about VVar. According to the ...
-1
votes
1answer
28 views

ptrace PTRACE_PEEKTEXT error

Why I get this error when I use ptrace PTRACE_PEEKTEXT in my C program?? the part of program that I use PTRACE_PEEKTEXT in it is: static void read_file(pid_t child, char *file) { char *child_addr; ...
1
vote
1answer
41 views

Kernel: Intercept listen call with module

I am writing an application that will detect any application calling listen(2) to open a socket for incoming connections and look up with a table of rules. It is much like ApplicationFirewall in macOS....
0
votes
0answers
17 views

Linux kernel - Syscall Implentation - Page Table Walk

I am trying to learn a few things about the linux kernel and I have come across a kind of exercise which asks to implement two system calls on th 4.15.0+ linux kernel which aim at reading the pages ...
0
votes
1answer
32 views

Sysdig does not show exit event for write syscall

I'm trying to capture write to stdout (or stderr), but apparently the actual data is related to the exit event. I wrote a simple C program that writes to stdout and stderr. #include <stdio.h> ...
0
votes
0answers
72 views

Using macros list_for_each and list_entry in linux kernel

I'm trying to add a new system call to Linux kernel (using virtual machine VMWARE with Ubuntu 18 and Linux version 4.15.0). This system call iterates all the decedents of a given process and uses ...
1
vote
2answers
93 views

How to determine, whether a file is open?

My code needs to go through files in a directory, picking only those, which are currently opened (for writing) by any other process on the system. The ideal solution would apply for all Unixes, but I'...
-1
votes
1answer
75 views

Can a program execute another program without the shell as an intermediate?

This might be a silly question. Can a program written for Linux (for example written in Golang), invoke a system call to execute another program directly, or does it have to call the shell first and ...
0
votes
0answers
13 views

Understanding sysinfo Ouput for Custom Init Process

With qemu: qemu-system-x86_64 -s -S -enable-kvm -m 512M -drive format=raw,file=myos.img -kernel {5.11.6-kernel} -append "root=/dev/sda init=/sbin/myint nokaslr" The C code (omitted libc ...
4
votes
2answers
273 views

Why is the stack argument required for the clone wrapper?

I've been carefully reading the linux man page for clone(), and I understand the difference between the clone() wrapper and the "raw" system call. But what I don't understand is why the ...
0
votes
0answers
35 views

syscall types logged by auditd vs. sysdig

I am new to Sysdig and auditd to be honest. I am wondering about the difference I notice in the syscalls recorded by each following the same user command. I checked the records logged by auditd after ...
2
votes
1answer
27 views

API/syscall to read or list BSD/macOS file flags

I've learned that besides the standard *nix file permissions, macOS also has file flags, and that they originated with BSD Unix. macOS's set of such flags is: UF_NODUMP Do not dump the file. ...
1
vote
2answers
55 views

How can I mount /dev from C?

How can I mount /dev from C? I'm writing a simple init, and I know this sounds stupid but I would like to have /dev mounted to another folder. The manpages for mount() don't show dev as a supported ...
0
votes
0answers
18 views

finding the system calls of a screen recorder resposible for interaction with the display server

Many resources online such as this and this point to the fact that screen recorders do not make any system calls to capture the screen. so how does a screen recorder capture the screen ? i came ...
3
votes
1answer
76 views

What could be a cause for getdents returning different results on 2 systems?

I have a weird situation that on one server I am getting following results: vagrant@shopping:/vagrant/deployer-example$ uname -a Linux shopping 4.19.0-0.bpo.9-amd64 #1 SMP Debian 4.19.118-2+deb10u1~...
3
votes
1answer
55 views

Strace shows that the time spent in syscalls is much longer than the total time elapsed. Why?

I am running an AI inference program based on Tensorflow-gpu. By running /usr/bin/strace -c -f /usr/bin/time ./program, I got the following output: <my program's output> 367.91user 1032.14system ...
1
vote
1answer
39 views

LD_LIBRARY_PATH env var missing in subshell from system(3) call

We have a huge client server business application, the server written in C, which does printouts on user request with something like: system("/usr/local/sisis-pap/cups/bin/lpr ...."); ...
1
vote
2answers
26 views

How do you pull the syscalls from an application and are they same as the functions used in source code?

I'm trying to pull out SysCalls from source code but I'm a little confused. I've found source like https://chromium.googlesource.com/chromiumos/docs/+/master/constants/syscalls.md and https://filippo....
0
votes
1answer
83 views

Invalid system call error when executing file command

I noticed a strange thing. When I run the file command as a regular user, I always get an invalid system call error. For example in zsh: $ file ~/.zshrc [1] 18553 invalid system call file ~/....
0
votes
0answers
14 views

Catch Seccomp Violation of Docker Container

I would like to catch any violations of prohibited systemcalls a container, started with a seccomp profile, executed. For example, my profile defines chown as blocked, which is also prevented within ...
1
vote
1answer
44 views

strace calls from running process and count them

I have a background process that will run for many many hours. I would like to trace and count the number of write calls live. sudo strace -p27861 -s50 -e write It gives me lines like this: write(1, ...
0
votes
0answers
17 views

How a not generic driver uses all the functions that a hardware device implements?

Its said that in order to use advanced functions for a hardware device, its recommended to use not generic drivers. But if system calls are the ones which call routines or functions from a driver, and ...
-1
votes
1answer
29 views

Does BTRFS support the ioctl(fd, FIFREEZE) system call?

the manpage of fsfreeze states: FSFREEZE(8) System Administration FSFREEZE(8) ...
1
vote
1answer
67 views

Is there a better method than ptrace for intercepting (“catching”) Linux syscalls coming from a forked process?

I would like to catch all syscalls coming from a forked process, modify them, send them to the kernel, and then pass them back to the forked process. Is this possible, and if so, how might I go about ...
3
votes
1answer
172 views

Correctly implementing seeking in FUSE readdir() operation

I'm trying to implement a toy file system and I'm struggling to understand how to correctly implement the readdir() operation in an efficient, scalable way. To understand the interface used by FUSE, I'...
0
votes
1answer
387 views

disable rtkit-daemon.service service when selinux is disabled

we have Hadoop cluster , each machine in the cluster is rhel 7.6 version since the provider - hortonworks recommended to disable the selinux then we disabled the selinux on all rhel machines now about ...
1
vote
2answers
119 views

Why does rmdir (the system call) only work on empty directory?

Is it not possible to atomically unlink the directory from its parent's inode? Is there any historical reason behind this?
0
votes
1answer
49 views

Zombie processes and exiting init

Assuming that I decide, for some reason, to never use the syscall wait ever again in any of the programs I write. Does it mean that my memory will be cluttered with all the finished processes that ...
0
votes
0answers
197 views

How do you call a driver function from a user space program (assuming you have properly registered the driver)

I suppose my question must seem hopelessly amateur, but I only started using linux seriously recently, and I cannot find a clear answer to this, rather simple question. I also have some additional ...
2
votes
1answer
414 views

Why is the type of stat.st_size not unsigned int?

I was trying to rely on the stat(2) system-call to determine the size of a file in order to allocate an appropriate buffer for it. More specifically I was using the stat.st_size of the structure that ...
1
vote
1answer
78 views

How pass the file's content through Named Pipe and then copy it into another one?

I wrote 2 programs that normally 1.create the named pipe(server) and 2. pass the string from the shell to the server part. I understand how to hand over a string from the terminal to the server part ...
0
votes
2answers
214 views

Does fork() also copy the file descriptor for the executable binary that the calling process is currently executing?

I've read the man pages on fork(), and they say something along the lines of "all file descriptors open in the calling process are copied". It is not 100% clear to me if the file descriptor ...
1
vote
2answers
508 views

What is the behaviour of a file-backed memory map when reading from or writing to an address larger than the length of the file?

I'm trying to figure out whether it would be undefined behaviour to open a memory map to a file with a very large length. My use-case is that I want to be able to see new data when the file is ...
1
vote
3answers
2k views

What is the relation between SIGCHLD and `waitpid()` or`wait()`?

If I am correct, a process waits for its children to terminate or stop by calling the waitpid() or wait() function. What is the relation between SIGCHLD signal and the waitpid() orwait() functions? ...
0
votes
1answer
367 views

Where to find the syscall_64.tbl in Linux?

I was following this guide to add my own custom system call inside the Linux kernel "Adding a Hello World System Call to Linux Kernel". In Step 5, it asks to modify the system call table by ...
-1
votes
2answers
86 views

Can a library call invoke more than one system call?

I understand that for example the library call printf invokes the write(2) syscall. My question is: Is there a library call that can invoke more than one system call? So in other words: Do system ...
1
vote
0answers
511 views

Implementing own system call linux

I got an assignment to implement my own system call and I have to use latest kernal v5.9. Downloaded linux-5.9-rc8(even stable version is giving same error) and extracted. Then cd into this directory. ...
2
votes
2answers
138 views

Why can kernel features that are reimplemented in user-space be faster than in kernel-space?

I was reading a blog post and noticed the following sentence: Then he said something really surprising: that in the Seastar HTTP framework, they wrote their own TCP stack, and it made everything ...
0
votes
1answer
92 views

can read system call experience short count after it is interrupted by a signal?

Let's say I call read to read 1000 bytes, and when read is reading the 501th bytes then a signal interrupts it, so does read return 500?
0
votes
1answer
256 views

Is it safe to restart system calls?

I was reading a textbook which describes how to deal with system call when interrupted: System calls can be interrupted. System calls such as read, wait, and accept that can potentially block the ...
0
votes
1answer
336 views

How does an open(at) syscall result in a file being written to disk?

I'm trying to learn as as much as I can about about the interplay between syscalls, the VFS, device driver handling and ultimately, having the end device do some operation. I thought I would look at a ...
3
votes
2answers
80 views

How do I feed data to a pipe until it's full, no more no less?

I want to use pipes on Linux as a synchronization primitive between a master process and a slave process. The classic way is to create two pipes, but I believe there's a way to use a single fd instead....
2
votes
1answer
529 views

CIFS mount is returning errors when operating on remote files (file exists, interrupted system call)

I need to replace a string in a file located in a CIFS mount (NTFS NAS). It is mounted with sudo mount -t cifs -o rw,guest,vers=1.0 //192.168.1.1/hdd /hdd I never faced this problem until a week ago, ...

1
2 3 4 5
7