commit 55516b355b0c cause SMEP/SMAP feature not work

From: guocai he
Date: Mon Sep 23 2024 - 04:22:08 EST


Andy, Thomas and all:

branch: v5.15/standard/preempt-rt/x86

commit: 55516b355b0c x86/syscall: Don't force use of indirect calls for system calls

I found this commit cause the intel CPU feature of SMEP/SMAP does not work.

SMEP/SMAP is to "trick" the kernel into using instructions or data from a user-space program and get call trace


testing:

1 enable SMEP/SMAP

2 in user-space, the test case source code:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/mman.h>
#include <sys/syscall.h>
#include <errno.h>

#define BUF_SIZE 128

int main(int argc, char **argv)
{
    char *map;

    map = mmap(NULL , 1024, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_ANONYMOUS|MAP_PRIVATE, -1, 0);
    if (map == MAP_FAILED) {
        printf("Failed to mmap: %s\n", strerror(errno));
        return -1;
    }

    memset(map, 0, sizeof(BUF_SIZE));

    mlockall(MCL_CURRENT);

    syscall(247, map);

    return 0;
}


3 after the test case  executed, expect to get the call trace. but this commit cause the test case can not find the call trace.


do you have chance to look at this issue?


Thanks

Guocai