[LTP] lapi/sched: add SAFE_SCHED_SETATTR()

linuxtestproject.agent@gmail.com linuxtestproject.agent@gmail.com
Thu Sep 3 01:07:41 CEST 2026


Hi Andrea,

On Sep 2, 2026, Andrea Cervesato wrote:
> lapi/sched: add SAFE_SCHED_SETATTR()

--- [PATCH 1/3] ---

> static inline int safe_sched_setattr(const char *file, const int lineno,
> 				     pid_t pid, const struct sched_attr *attr,
> 				     unsigned int flags)
> {
> 	int ret;
>
> 	ret = sched_setattr(pid, attr, flags);

glibc's sched_setattr() takes a non-const struct sched_attr pointer, so this
discards const and fails with -Werror=discarded-qualifiers on the new glibc
API. Match that prototype here and in the fallback declaration.

> #define SAFE_SCHED_SETATTR(pid, attr, flags)\
> 	safe_sched_setattr(__FILE__, __LINE__, (pid), (attr), (flags))

This new public macro needs a kernel-doc comment documenting its arguments
and failure behavior.

--- [PATCH 2/3] ---

> #ifndef PR_SET_MM_MAP
> # define PR_SET_MM_MAP	14
> #endif
> #ifndef PR_SET_MM_MAP_SIZE
> # define PR_SET_MM_MAP_SIZE	15
> #endif
>
> #if !(HAVE_STRUCT_PRCTL_MM_MAP) && !defined(PR_SET_MM_MAP)
> struct prctl_mm_map {

The fallback struct is unreachable when needed because PR_SET_MM_MAP is
defined immediately before the condition. Gate it solely on
HAVE_STRUCT_PRCTL_MM_MAP, otherwise the new CVE test fails to compile on
systems lacking the struct.

--- [PATCH 3/3] ---

> static struct tst_test test = {
> 	.setup = setup,
> 	.test_all = run,
> 	.runtime = 180,
> 	.needs_checkpoints = 1,

PR_SET_MM_MAP was added in Linux 3.18. Add .min_kver = "3.18"; otherwise
3.3--3.17 kernels with both requested configs reach setup and report TBROK
for the unsupported operation.

> 	SAFE_CLOCK_GETTIME(CLOCK_MONOTONIC, &ts);
> 	ts = tst_timespec_add(ts, (struct timespec){ .tv_sec = 10, .tv_nsec = 0 });
> 	futex_wait_requeue_pi(&f_wait, &f_pi_target, &ts);
>
> 	TST_CHECKPOINT_WAKE(CP_SPRAYED);

The futex result is ignored, so expiry or another failure publishes
CP_SPRAYED without establishing the PI topology and causes a spurious TBROK.
Use an untimed blocking wait, or validate the result before the wake.

> refluxfs
> sctphantom
> ghostlock

Keep the new .gitignore entry sorted by placing ghostlock before refluxfs.

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