[LTP] [PATCH 0/3] safe_macros: Fix undefined behaviour in vararg handling
Cyril Hrubis
chrubis@suse.cz
Tue Nov 29 12:48:21 CET 2022
Hi!
> Accessing elements in an empty va_list results in undefined behaviour[0]
> that can include accessing arbitrary stack memory. While typically this
> doesn't raise a fault, some new more security-oriented architectures
> (e.g. CHERI[1] or Morello[2]) don't allow it.
Looking at how glibc handles this, the code looks like:
int mode = 0;
if (__OPEN_NEEDS_MODE(oflag)) {
..
mode = va_arg(arg, int);
..
}
That sounds much easier than messing with the macros and should avoid
undefined behavior.
--
Cyril Hrubis
chrubis@suse.cz
More information about the ltp
mailing list