util: avoid calling kcmp on Android

On some combinations of Android version and kernel version, calling kcmp
results in seccomp killing the process.

As there doesn't seem to be a way to query for that in advance, skip
this check altogether on Android.

Signed-off-by: Eric Engestrom <eric@igalia.com>
Reviewed-by: Rob Clark <robclark@freedesktop.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20180>
This commit is contained in:
Eric Engestrom 2023-02-01 17:58:02 +00:00 committed by Marge Bot
parent 0d6c240fcc
commit a72035f9c5
3 changed files with 16 additions and 1 deletions

View File

@ -851,6 +851,16 @@ if with_platform_android
]
endif
# On Android, seccomp kills the process on kernels without
# CONFIG_KCMP/CONFIG_CHECKPOINT_RESTORE if it attemps to use KCMP.
# Since we can't detect that, err on the side of caution and disable
# KCMP by default on Android.
if get_option('allow-kcmp') \
.disable_auto_if(with_platform_android) \
.allowed()
pre_args += '-DALLOW_KCMP'
endif
prog_python = import('python').find_installation('python3')
has_mako = run_command(
prog_python, '-c',

View File

@ -427,6 +427,11 @@ option(
value : 25,
description : 'Android Platform SDK version. Default: Nougat version.'
)
option(
'allow-kcmp',
type : 'feature',
description : 'Allow using KCMP_FILE to compare file descriptions. auto = allowed everywhere except on Android'
)
option(
'zstd',
type : 'feature',

View File

@ -194,7 +194,7 @@ os_read_file(const char *filename, size_t *size)
return buf;
}
#if DETECT_OS_LINUX
#if DETECT_OS_LINUX && ALLOW_KCMP
#include <sys/syscall.h>
#include <unistd.h>