[LTP] [PATCH v6 1/3] syscalls/modify_ldt: Add lapi/ldt.h
Cyril Hrubis
chrubis@suse.cz
Mon Apr 7 14:09:27 CEST 2025
Hi!
> +static inline int modify_ldt(int func, const struct user_desc *ptr,
> + unsigned long bytecount)
> +{
> + return tst_syscall(__NR_modify_ldt, func, ptr, bytecount);
> +}
> +
> +static inline int safe_modify_ldt(const char *file, const int lineno, int func,
> + const struct user_desc *ptr,
> + unsigned long bytecount)
> +{
> + int rval;
> +
> + rval = modify_ldt(func, ptr, bytecount);
> + if (rval == -1)
> + tst_brk_(file, lineno, TBROK | TERRNO,
> + "modify_ldt(%d, %p, %lu)", func, ptr, bytecount);
We should make sure that we only accept the success value here (as we do
in the rest of the safe macros) so that we catch the cases when kernel
returns an invalid value.
This should be:
if (rval == -1) {
tst_brk_(...);
} else if (rval) {
tst_brk_("modify_ltd(...) invalid retval %i", ...);
}
With that fixed:
Reviewed-by: Cyril Hrubis <chrubis@suse.cz>
--
Cyril Hrubis
chrubis@suse.cz
More information about the ltp
mailing list