rseq: fix headers conflict on Mariner GNU/Linux

1. For some reason, Marier distribution headers
not correctly define __GLIBC_HAVE_KERNEL_RSEQ
compile-time constant. It remains undefined,
but in fact header files provides corresponding
rseq types declaration which leads to conflict.

2. Another issue, is that they use uint*_t types
instead of __u* types as in original rseq.h.

This leads to compile time issues like this:
format '%llx' expects argument of type 'long long unsigned int', but argument 5 has type 'uint64_t' {aka 'long unsigned int'}

and we can't even replace %llx to %PRIx64 because it will break
compilation on other distros (like Fedora) with analogical error:

error: format ‘%lx’ expects argument of type ‘long unsigned int’, but argument 6 has type ‘__u64’ {aka ‘long long unsigned int’}

Let's use our-own struct rseq copy fully equal to the kernel one,
it's safe because this structure is a part of Linux Kernel ABI.

Fixes #1934

Reported-by: Nikola Bojanic
Signed-off-by: Alexander Mikhalitsyn <alexander.mikhalitsyn@virtuozzo.com>
This commit is contained in:
Alexander Mikhalitsyn 2022-07-08 12:36:57 +00:00 committed by Andrei Vagin
parent ad58553d90
commit e30d18f435
5 changed files with 44 additions and 15 deletions

View file

@ -196,3 +196,22 @@ int main(void)
return 0;
}
endef
define FEATURE_TEST_NO_LIBC_RSEQ_DEFS
#ifdef __has_include
#if __has_include(\"sys/rseq.h\")
#include <sys/rseq.h>
#endif
#endif
enum rseq_cpu_id_state {
RSEQ_CPU_ID_UNINITIALIZED = -1,
RSEQ_CPU_ID_REGISTRATION_FAILED = -2,
};
int main(void)
{
return 0;
}
endef