]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-123014: Disable pidfd API on older Android versions (#124458)
authorMalcolm Smith <smith@chaquo.com>
Wed, 25 Sep 2024 14:23:30 +0000 (15:23 +0100)
committerGitHub <noreply@github.com>
Wed, 25 Sep 2024 14:23:30 +0000 (16:23 +0200)
Doc/library/os.rst
Doc/library/signal.rst
Misc/NEWS.d/next/Library/2024-09-24-19-32-14.gh-issue-123014.zVcfkZ.rst [new file with mode: 0644]
Modules/clinic/posixmodule.c.h
Modules/clinic/signalmodule.c.h
Modules/posixmodule.c
Modules/signalmodule.c

index cd7ae7bdd7385a65f36a99558dadd66c662cde78..33dd58febd9a5ebb5624a9546e00f9abd306e89a 100644 (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
index 79c4948e99e96753f824f2f46bd2103f4669dfd0..17fcb2b3707978854deda040c6d1f9b582e9e208 100644 (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
 
 
diff --git a/Misc/NEWS.d/next/Library/2024-09-24-19-32-14.gh-issue-123014.zVcfkZ.rst b/Misc/NEWS.d/next/Library/2024-09-24-19-32-14.gh-issue-123014.zVcfkZ.rst
new file mode 100644 (file)
index 0000000..53dbabd
--- /dev/null
@@ -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.
index 9722f06a5935b9f7bd27cc6e8d4d795f45a3eadb..749fe54598cc3912cb233356824f6eaff5acdbd9 100644 (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]*/
index 1d3a143dfd8d39bf1934c731a51ba379d82e4da3..986c0289f2bfcb9143b786607333f635b09c79e4 100644 (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]*/
index 86366c66c4655297ed5bfda410e585e45b9f7fb2..334350285f3b6f74ba6921cf389da2e1d709b03d 100644 (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
index 73bfcb756657b80c460d593cc2e54f822a35f641..0e53a36bca55f0326ed29bfd22af55e4aa7397ed 100644 (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