gh-123014: Disable pidfd API on older Android versions (#124458)

This commit is contained in:
Malcolm Smith 2024-09-25 15:23:30 +01:00 committed by GitHub
parent 461c12b438
commit c58c572a65
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 18 additions and 10 deletions

View File

@ -4602,7 +4602,7 @@ written in Python, such as a mail server's external command delivery program.
See the :manpage:`pidfd_open(2)` man page for more details.
.. availability:: Linux >= 5.3
.. availability:: Linux >= 5.3, Android >= :func:`build-time <sys.getandroidapilevel>` API level 31
.. versionadded:: 3.9
.. data:: PIDFD_NONBLOCK

View File

@ -411,7 +411,7 @@ The :mod:`signal` module defines the following functions:
See the :manpage:`pidfd_send_signal(2)` man page for more information.
.. availability:: Linux >= 5.1
.. availability:: Linux >= 5.1, Android >= :func:`build-time <sys.getandroidapilevel>` API level 31
.. versionadded:: 3.9

View File

@ -0,0 +1,3 @@
:func:`os.pidfd_open` and :func:`signal.pidfd_send_signal` are now
unavailable when building against Android API levels older than 31, since
the underlying system calls may cause a crash.

View File

@ -5954,7 +5954,7 @@ os_wait(PyObject *module, PyObject *Py_UNUSED(ignored))
#endif /* defined(HAVE_WAIT) */
#if (defined(__linux__) && defined(__NR_pidfd_open))
#if (defined(__linux__) && defined(__NR_pidfd_open) && !(defined(__ANDROID__) && __ANDROID_API__ < 31))
PyDoc_STRVAR(os_pidfd_open__doc__,
"pidfd_open($module, /, pid, flags=0)\n"
@ -6013,7 +6013,7 @@ exit:
return return_value;
}
#endif /* (defined(__linux__) && defined(__NR_pidfd_open)) */
#endif /* (defined(__linux__) && defined(__NR_pidfd_open) && !(defined(__ANDROID__) && __ANDROID_API__ < 31)) */
#if defined(HAVE_SETNS)
@ -12837,4 +12837,4 @@ os__create_environ(PyObject *module, PyObject *Py_UNUSED(ignored))
#ifndef OS__SUPPORTS_VIRTUAL_TERMINAL_METHODDEF
#define OS__SUPPORTS_VIRTUAL_TERMINAL_METHODDEF
#endif /* !defined(OS__SUPPORTS_VIRTUAL_TERMINAL_METHODDEF) */
/*[clinic end generated code: output=a736ad3f7205176e input=a9049054013a1b77]*/
/*[clinic end generated code: output=b93bbaaa8eb5b0ce input=a9049054013a1b77]*/

View File

@ -670,7 +670,7 @@ exit:
#endif /* defined(HAVE_PTHREAD_KILL) */
#if (defined(__linux__) && defined(__NR_pidfd_send_signal))
#if (defined(__linux__) && defined(__NR_pidfd_send_signal) && !(defined(__ANDROID__) && __ANDROID_API__ < 31))
PyDoc_STRVAR(signal_pidfd_send_signal__doc__,
"pidfd_send_signal($module, pidfd, signalnum, siginfo=None, flags=0, /)\n"
@ -723,7 +723,7 @@ exit:
return return_value;
}
#endif /* (defined(__linux__) && defined(__NR_pidfd_send_signal)) */
#endif /* (defined(__linux__) && defined(__NR_pidfd_send_signal) && !(defined(__ANDROID__) && __ANDROID_API__ < 31)) */
#ifndef SIGNAL_ALARM_METHODDEF
#define SIGNAL_ALARM_METHODDEF
@ -776,4 +776,4 @@ exit:
#ifndef SIGNAL_PIDFD_SEND_SIGNAL_METHODDEF
#define SIGNAL_PIDFD_SEND_SIGNAL_METHODDEF
#endif /* !defined(SIGNAL_PIDFD_SEND_SIGNAL_METHODDEF) */
/*[clinic end generated code: output=6d8e17a32cef668f input=a9049054013a1b77]*/
/*[clinic end generated code: output=c57b4b98fad6f4b8 input=a9049054013a1b77]*/

View File

@ -10121,7 +10121,10 @@ os_wait_impl(PyObject *module)
}
#endif /* HAVE_WAIT */
#if defined(__linux__) && defined(__NR_pidfd_open)
// This system call always crashes on older Android versions.
#if defined(__linux__) && defined(__NR_pidfd_open) && \
!(defined(__ANDROID__) && __ANDROID_API__ < 31)
/*[clinic input]
os.pidfd_open
pid: pid_t

View File

@ -1299,7 +1299,9 @@ signal_pthread_kill_impl(PyObject *module, unsigned long thread_id,
#endif /* #if defined(HAVE_PTHREAD_KILL) */
#if defined(__linux__) && defined(__NR_pidfd_send_signal)
// This system call always crashes on older Android versions.
#if defined(__linux__) && defined(__NR_pidfd_send_signal) && \
!(defined(__ANDROID__) && __ANDROID_API__ < 31)
/*[clinic input]
signal.pidfd_send_signal