mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-12-06 04:55:44 +00:00
fix(nativeguest): restore desktop startup after child handoff (#3594)
Keep handed-off children on the guest hook’s standard wait path. Verified the exact signed PR build on a Pocket Fit Elite: the desktop reached READY with KWin, Xwayland, and Plasma running.
This commit is contained in:
1 parent
1a7a116939
commit
ec281db0d1
2 files changed
+56
No files matched your search
@@ -339,6 +339,13 @@ __asm__(".globl setrlimit64\n" ".set setrlimit64, setrlimit\n");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef CLONE_PIDFD
|
||||
#define CLONE_PIDFD 0x00001000
|
||||
#endif
|
||||
#ifndef P_PIDFD
|
||||
#define P_PIDFD 3
|
||||
#endif
|
||||
|
||||
#ifndef SECCOMP_SET_MODE_STRICT
|
||||
#define SECCOMP_SET_MODE_STRICT 0
|
||||
#endif
|
||||
@@ -639,6 +646,20 @@ long syscall(long number, ...) {
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef __NR_clone
|
||||
if (number == __NR_clone && (arg1 & CLONE_PIDFD)) {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef __NR_waitid
|
||||
if (number == __NR_waitid && (int)arg1 == P_PIDFD) {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef __NR_clone3
|
||||
if (number == __NR_clone3) {
|
||||
errno = ENOSYS;
|
||||
|
||||
@@ -1111,6 +1111,34 @@ int main(void) {
|
||||
# A worker's program with its table at fd 1000 (kept, as 900 and 901 are): a dup2() onto the pidfd
|
||||
# lets go of 900 while another thread's close_range(899, 2000) is between its parts, held there by the
|
||||
# hook's test gate. The kept fds above 900 stay open.
|
||||
PIDFD_PROBE = r"""
|
||||
#define _GNU_SOURCE
|
||||
#include <errno.h>
|
||||
#include <limits.h>
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/syscall.h>
|
||||
#include <sys/wait.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int main(void) {
|
||||
errno = 0;
|
||||
long r = syscall(SYS_waitid, 3, INT_MAX, NULL, WEXITED | WNOHANG, NULL);
|
||||
printf("waitid\t%ld %d\n", r, errno);
|
||||
int pidfd = -1;
|
||||
errno = 0;
|
||||
r = syscall(SYS_clone, 0x00001000 | SIGCHLD, NULL, &pidfd, NULL, 0);
|
||||
if (r == 0) _exit(9);
|
||||
printf("clone\t%ld %d %d\n", r < 0 ? -1L : 1L, errno, pidfd);
|
||||
if (r > 0) waitpid((pid_t)r, NULL, 0);
|
||||
r = syscall(SYS_clone, SIGCHLD, NULL, NULL, NULL, 0);
|
||||
if (r == 0) _exit(7);
|
||||
int status = 0;
|
||||
printf("fork\t%d\n", r > 0 && waitpid((pid_t)r, &status, 0) == r && WIFEXITED(status) ? WEXITSTATUS(status) : -1);
|
||||
return 0;
|
||||
}
|
||||
"""
|
||||
|
||||
DUPRACE = r"""
|
||||
#define _GNU_SOURCE
|
||||
#include <fcntl.h>
|
||||
@@ -2217,6 +2245,13 @@ class NativeHookHandoffTest(unittest.TestCase):
|
||||
pass_fds=(table,))
|
||||
return parent, dict(line.split("\t", 1) for line in out.stdout.splitlines() if "\t" in line), out
|
||||
|
||||
def test_a_guest_sees_no_pidfd_support_so_its_waits_go_through_the_handoff(self):
|
||||
parent, result, out = self.run_worker_program("pidfd", PIDFD_PROBE)
|
||||
self.assertEqual(0, out.returncode, out.stderr)
|
||||
self.assertEqual("-1 %d" % errno.EINVAL, result.get("waitid"), out.stdout + out.stderr)
|
||||
self.assertEqual("-1 %d -1" % errno.EINVAL, result.get("clone"), out.stdout)
|
||||
self.assertEqual("7", result.get("fork"), out.stdout)
|
||||
|
||||
def test_a_dup2_onto_the_parents_pidfd_while_a_close_range_runs_closes_no_kept_fd(self):
|
||||
parent, result, out = self.run_worker_program("duprace", DUPRACE, table_fd=1000)
|
||||
self.assertEqual(0, out.returncode, out.stderr)
|
||||
|
||||
Reference in new issue
Block a user