Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disabling vsyscalls in Linux

I'm working on a piece of software that monitors other processes' system calls using ptrace(2). Unfortunately most modern operating system implement some kind of fast user-mode syscalls that are called vsyscalls in Linux.

Is there any way to disable the use of vsyscalls/vDSO for a single process or, if that is not possible, for the whole operating system?

like image 651
Michael Avatar asked Nov 26 '11 16:11

Michael


People also ask

How to disable a services in Linux?

How to Disable a Services in Linux. In Red Hat based distributions such as Fedora and CentOS, make use of a script called ‘ chkconfig ‘ to enable and disable the running services in Linux. For example, lets disable the Apache web server at the system startup. [ avishek@tecmint ]# chkconfig httpd off [ avishek@tecmint ]# chkconfig httpd --del.

How to disable SSLv3 in Linux?

How to disable SSLv3 in Linux? When you know that the server is a possible target, there is a need to act fast to avoid hackers exploiting this vulnerability. Unfortunately, a simple ready made patch for this do not exist. The only possible way is to disable SSLv3 in the different applications used on the server.

How to disable weak algorithms at server side in SSH?

Disable weak algorithms at server side 1 First, we log into the server as a root user. 2 Then, we open the file sshd_config located in /etc/ssh and add the following directives.#N#Ciphers aes256-gcm@openssh. 3 At last, to make the changes effective in SSH, we restart sshd service More ...

How to disable weak SSH ciphers in Linux?

In short, How to disable weak SSH ciphers in Linux has quite an easy solution. It is by adding a directive in the config file and can be either at the server-side or client-side. Why is My SSH Connection Refused?


4 Answers

Try echo 0 > /proc/sys/kernel/vsyscall64

If you're trying to ptrace on gettimeofday calls and they aren't showing up, what time source is the system using (pmtimer, acpi, tsc, hpet, etc). I wonder if you'd humor me by trying to force your timer to something older like pmtimer. It's possible one of the many gtod timer specific optimizations is causing your ptrace calls to be avoided, even with vsyscall set to zero.

like image 100
Jeremiah Gowdy Avatar answered Sep 17 '22 17:09

Jeremiah Gowdy


Is there any way to disable the use of vsyscalls/vDSO for a single process or, if that is not possible, for the whole operating system?

It turns out there IS a way to effectively disable linking vDSO for a single process without disabling it system-wide using ptrace!

All you have to do is to stop the traced process before it returns from execve and remove the AT_SYSINFO_EHDR entry from the auxiliary vector (which comes directly after environment variables along the memory region pointed to in rsp). PTRACE_EVENT_EXEC is a good place to do this.

AT_SYSINFO_EHDR is what the kernel uses to tell the system linker where vDSO is mapped in the process's address space. If this entry is not present, ld seems to act as if the system hasn't mapped a vDSO.

Note that this doesn't somehow unmap the vDSO from your processes memory, it merely ignores it when linking other shared libraries. A malicious program will still be able to interact with it if the author really wanted to.

I know this answer is a bit late, but I hope this information will spare some poor soul a headache

like image 21
Tenders McChiken Avatar answered Sep 20 '22 17:09

Tenders McChiken


For newer systems echo 0 > /proc/sys/kernel/vsyscall64 might not work. In Ubuntu 16.04 vDSO can be disabled system-wide by adding the kernel parameter vdso=0 in /etc/default/grub under the parameter: GRUB_CMDLINE_LINUX_DEFAULT.

IMPORTANT: Parameter GRUB_CMDLINE_LINUX_DEFAULT might be overwriten by other configuration files in /etc/default/grub.d/..., so double check when to add your custom configuration.

like image 34
Anastasios Andronidis Avatar answered Sep 16 '22 17:09

Anastasios Andronidis


Picking up on Tenders McChiken's approach, I did create a wrapper that disables vDSO for an arbitrary binary, without affecting the rest of the system: https://github.com/danteu/novdso

The general procedure is quite simple:

  1. use ptrace to wait for return from execve(2)
  2. find the address of the auxvector
  3. overwrite the AT_SYSINFO_EHDR entry with AT_IGNORE, telling the application to ignore the following value
like image 27
Daniel Teunis Avatar answered Sep 19 '22 17:09

Daniel Teunis