gst: clock: Block futex_time64 usage on Android API level < 30

This syscall is seccomp blocked on all lower API levels:

ee7bc3002d

While at it, also fix all direct tests on __NR_futex_time64 and
__NR_futex so that they refer to the results available in
config.h.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6477>
This commit is contained in:
L. E. Segovia 2024-03-27 16:55:10 +00:00 committed by GStreamer Marge Bot
parent b18b3d00b7
commit 6ce27e328d
2 changed files with 15 additions and 7 deletions

View file

@ -250,8 +250,12 @@ gst_futex_cond_broadcast (guint * cond_val)
{
g_atomic_int_inc (cond_val);
#if defined(__NR_futex_time64)
#if defined(HAVE_FUTEX_TIME64)
#if defined(__BIONIC__)
if (__builtin_available (android 30, *)) {
#else
{
#endif
int res;
res = syscall (__NR_futex_time64, cond_val, (gsize) FUTEX_WAKE_PRIVATE,
(gsize) INT_MAX, NULL);
@ -260,7 +264,7 @@ gst_futex_cond_broadcast (guint * cond_val)
* normal `futex` syscall. This can happen if newer kernel headers are
* used than the kernel that is actually running.
*/
#ifdef __NR_futex
#if defined(HAVE_FUTEX)
if (res >= 0 || errno != ENOSYS) {
#else
{
@ -270,7 +274,7 @@ gst_futex_cond_broadcast (guint * cond_val)
}
#endif
#if defined(__NR_futex)
#if defined(HAVE_FUTEX)
syscall (__NR_futex, cond_val, (gsize) FUTEX_WAKE_PRIVATE, (gsize) INT_MAX,
NULL);
#endif
@ -308,8 +312,12 @@ gst_futex_cond_wait_until (guint * cond_val, GMutex * mutex, gint64 end_time)
* define `__NR_futex_time64`.
*/
#ifdef __NR_futex_time64
#if defined(HAVE_FUTEX_TIME64)
#if defined(__BIONIC__)
if (__builtin_available (android 30, *)) {
#else
{
#endif
struct
{
gint64 tv_sec;
@ -329,7 +337,7 @@ gst_futex_cond_wait_until (guint * cond_val, GMutex * mutex, gint64 end_time)
* normal `futex` syscall. This can happen if newer kernel headers are
* used than the kernel that is actually running.
*/
#ifdef __NR_futex
#if defined(HAVE_FUTEX)
if (res >= 0 || errno != ENOSYS) {
#else
{
@ -342,7 +350,7 @@ gst_futex_cond_wait_until (guint * cond_val, GMutex * mutex, gint64 end_time)
}
#endif
#ifdef __NR_futex
#if defined(HAVE_FUTEX)
{
struct
{

View file

@ -313,7 +313,7 @@ if cc.compiles('''#include <linux/futex.h>
int main (int argc, char ** argv) {
syscall (__NR_futex_time64, NULL, FUTEX_WAKE, FUTEX_WAIT);
return 0;
}''', name : 'futex(2) system call')
}''', name : 'futex_time64(2) system call')
cdata.set('HAVE_FUTEX_TIME64', 1)
endif