[LTP] [PATCH 04/10] Add SAFE_PRCTL macro

Petr Vorel pvorel@suse.cz
Wed Jul 10 17:47:53 CEST 2024


Hi Andrea, Li,

...
> +int safe_prctl(const char *file, const int lineno,
> +	int option, unsigned long arg2, unsigned long arg3,
> +	unsigned long arg4, unsigned long arg5)
> +{
> +	int rval;
> +
> +	rval = prctl(option, arg2, arg3, arg4, arg5);
> +	if (rval == -1) {
> +		tst_brk_(file, lineno, TBROK | TERRNO,
> +			"prctl(%d, %lu, %lu, %lu, %lu)",
> +			option, arg2, arg3, arg4, arg5);
If I understand man prctl(2) correctly, valid values are >= 0, -1 is for error.
Shouldn't we check for invalid return value, e.g. else if (rval < 0) should
TBROK (see other uses safe_dup)? If yes, this applies to landlock SAFE_* macros
as well.

Also, some modes are for new kernels: PR_SET_IO_FLUSHER (since Linux 5.6), but I
would solve it once needed.

Otherwise LGTM.

Reviewed-by: Petr Vorel <pvorel@suse.cz>

> +	}
> +
> +	return rval;
> +}


More information about the ltp mailing list