Proper way of getting the address of non-exported kernel symbols in a Linux kernel module

Disclaimer: using non-exported symbols is in general not a good idea, so you should only do it for testing/educational purposes, not for production-ready modules/drivers. Before Linux v5.7, you indeed would have used kallsyms_lookup_name() to look-up non-exported kernel symbols from a module. See How do I access any kernel symbol in a kernel module? if you … Read more

Why is RCX not used for passing parameters to system calls, being replaced with R10? [duplicate]

X86-64 system calls use syscall instruction. This instruction saves return address to rcx, and after that it loads rip from IA32_LSTAR MSR. I.e. rcx is immediately destroyed by syscall. This is the reason why rcx had to be replaced for system call ABI. This same syscall instruction also saves rflags into r11, and then masks … Read more

how could I intercept linux sys calls?

Why can’t you / don’t want to use the LD_PRELOAD trick? Example code here: /* * File: soft_atimes.c * Author: D.J. Capelis * * Compile: * gcc -fPIC -c -o soft_atimes.o soft_atimes.c * gcc -shared -o soft_atimes.so soft_atimes.o -ldl * * Use: * LD_PRELOAD=”./soft_atimes.so” command * * Copyright 2007 Regents of the University of California … Read more

How do I get a thread ID from an arbitrary pthread_t?

Since pthreads do not need to be implemented with Linux threads (or kernel threads at all, for that matter), and some implementations are entirely user-level or mixed, the pthreads interface does not provide functions to access these implementation details, as those would not be portable (even across pthreads implementations on Linux). Thread libraries that use … Read more