I'm currently trying to implement my own VDSO. I have seen this tutorial which explains how to do this.

However, this tutorial is made for Linux 2.6.x and I would like to use it on Linux 4.8.x. But the architectural structure of vdso changed a lot since this version (e.g. vextern.h has been suppressed) and I don't know how to adapt it to get it working.

Do you know how I could adapt this tutorial for a recent kernel or where I can find enough resources about vdso to implement my own?

Also, do you know whether I can simply recreate the behavior of an arbitrary syscall as a VDSO? I know it is a very bad idea from a security perspective (and the performance gain is negligible)

closed as off-topic by Rui F Ribeiro, Jeff Schaller, RalfFriedl, G-Man, Archemar Nov 21 '18 at 8:12

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Requests for learning materials (tutorials, how-tos etc.) are off topic. The only exception is questions about where to find official documentation (e.g. POSIX specifications). See the Help Center and our Community Meta for more information." – Rui F Ribeiro, RalfFriedl, Archemar
If this question can be reworded to fit the rules in the help center, please edit the question.

  • Thanks I learnt something new. However the phrase “the kernel is divided into two primary segments of memory: userland and kernel land.” is inept. This is as silly as saying that apples are divided into two groups: apples and oranges. – ctrl-alt-delor Nov 20 '18 at 14:02

I’m not sure there’s an updated tutorial in the same style, but the changes are limited:

  • arch/x86/vdso moved to arch/x86/entry/vdso;
  • variable declarations have been greatly simplified.

The latter means that you only need to declare your variable once, in arch/x86/include/asm/vvar.h, at a fixed offset, with the DECLARE_VVAR macro. To define it, use the DEFINE_VVAR macro; to access it, use the VVAR macro. The linked commit above has a number of examples (all the existing uses of shared variables).

You can’t recreate the behaviour of an arbitrary syscall in the vDSO, at least not without calling into the kernel in kernel mode. The vDSO is only really useful for calls which can be handled in user space; there aren’t many of those.

Not the answer you're looking for? Browse other questions tagged or ask your own question.