Re: [PATCHv16 13/17] selftests/x86/lam: Add mmap and SYSCALL test cases for linear-address masking

From: Florian Weimer
Date: Sat Aug 09 2025 - 12:05:12 EST


* Kirill A. Shutemov:

> From: Weihong Zhang <weihong.zhang@xxxxxxxxx>
>
> Add mmap and SYSCALL test cases.
>
> SYSCALL test cases:
>
> - LAM supports set metadata in high bits 62:57 (LAM_U57) of a user
> pointer, pass the pointer to SYSCALL, SYSCALL can dereference the
> pointer and return correct result.

Is this test expected to pass?

I've tried to compile the Fedora kernel (6.15.9-201.fc42) with address
masking and LAM enabled, and while basic LAM support is there (the CPU
ignores the metadata bits after the arch_prctl system call), it's not
valid to use addresses with metadata in system calls:

$ ./lam_64 -t 8
not ok 1 SYSCALL: LAM_U57. syscall with metadata
ok 2 SYSCALL:[Negative] Disable LAM. Dereferencing pointer with metadata.
not ok 3 GET_USER: get_user() and pass a properly tagged user pointer.
ok 4 GET_USER:[Negative] get_user() with a kernel pointer and the top bit cleared.
ok 5 GET_USER:[Negative] get_user() with a kernel pointer and the bottom sign-extension bit cleared.
ok 6 GET_USER:[Negative] get_user() and pass a kernel pointer.
1..6
# Totals: pass:4 fail:2 xfail:0 xpass:0 skip:0 error:0

This also happens outside the test, where write (for example) returns
EFAULT if passed an address with metadata.

Thanks,
Florian