• Marcos Paulo de Souza's avatar
    selftests: livepatch: Test livepatching a heavily called syscall · 6a717704
    Marcos Paulo de Souza authored
    The test proves that a syscall can be livepatched. It is interesting
    because syscalls are called a tricky way. Also the process gets
    livepatched either when sleeping in the userspace or when entering
    or leaving the kernel space.
    
    The livepatch is a bit tricky:
      1. The syscall function name is architecture specific. Also
         ARCH_HAS_SYSCALL_WRAPPER must be taken in account.
    
      2. The syscall must stay working the same way for other processes
         on the system. It is solved by decrementing a counter only
         for PIDs of the test processes. It means that the test processes
         has to call the livepatched syscall at least once.
    
    The test creates one userspace process per online cpu. The processes
    are calling getpid in a busy loop. The intention is to create random
    locations when the livepatch gets enabled. Nothing is guarantted.
    The magic is in the randomness.
    Reviewed-by: default avatarJoe Lawrence <joe.lawrence@redhat.com>
    Reviewed-by: default avatarPetr Mladek <pmladek@suse.com>
    Signed-off-by: default avatarMarcos Paulo de Souza <mpdesouza@suse.com>
    Signed-off-by: default avatarShuah Khan <skhan@linuxfoundation.org>
    6a717704
test_klp_syscall.c 2.51 KB