[LTP] arch_prctl: add ARCH_GET_FS, ARCH_GET_GS tests

linuxtestproject.agent@gmail.com linuxtestproject.agent@gmail.com
Sat Oct 10 00:23:02 CEST 2026


Hi Dmitry,

On 2026-10-09, Dmitry Chestnykh wrote:
> arch_prctl: add ARCH_GET_FS, ARCH_GET_GS tests

> diff --git a/testcases/kernel/syscalls/arch_prctl/arch_prctl02.c b/testcases/kernel/syscalls/arch_prctl/arch_prctl02.c
> +static int arch_prctl_get(int code, unsigned long *out)
> +{
> +	return tst_syscall(__NR_arch_prctl, code, out);
> +}

High: On x32, unsigned long is four bytes, but these raw GET operations
write eight bytes, overflowing fs_prctl and gs_prctl. Both __x86_64__ and
the framework's x86_64 architecture check admit x32; glibc's x32
arch_prctl wrapper uses a uint64_t temporary, but tst_syscall bypasses it.
Use uint64_t for the output pointer, both output objects, and comparison
values.

> +	if (gs == 0) {
> +		unsigned long test_gs = 0xabababab;
> +		TST_EXP_PASS_SILENT(set_gs(test_gs));
> +		if (TST_PASS) {
> +			TEST_GS_BASE();
> +		}
> +	}

Low: GS remains nonzero after the first iteration, so subsequent -i
iterations skip the zero-base comparison and ARCH_SET_GS branch; -i 3
produces seven comparisons rather than repeating all three each time.
Restore the original GS base after the changed-base comparison.

> +	unsigned long long __res_fs;                       \
> +	unsigned long long __res_gs;                       \
> +		if (TST_PASS) {
> +			TEST_GS_BASE();
> +		}
> +	unsigned idx;
> +static void run(unsigned index)

Low: check-arch_prctl02 reports missing blank lines after declarations,
unnecessary single-statement braces, an unnecessary blank line before a
closing brace, and bare unsigned declarations; fix these and use unsigned
int. Rename __res_fs and __res_gs to avoid reserved identifiers.

Verdict - Needs revision

---
Note:

The agent can sometimes produce false positives although often its
findings are genuine. If you find issues with the review, please
comment this email or ignore the suggestions.

Regards,
LTP AI Reviewer


More information about the ltp mailing list