From 3b87f9aa95892fcfd92d5b939e061110589d63b6 Mon Sep 17 00:00:00 2001 From: DreamConnected <1487442471@qq.com> Date: Fri, 1 Aug 2025 11:22:13 +0800 Subject: [PATCH 1/3] lxc/rexec.c: fixed memfd-rexec on android not enabled by default Signed-off-by: DreamConnected <1487442471@qq.com> --- .github/workflows/code-test.yml | 14 +++++++++++++- src/lxc/rexec.c | 26 ++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/.github/workflows/code-test.yml b/.github/workflows/code-test.yml index 78bade4c1b..4ef4345d94 100644 --- a/.github/workflows/code-test.yml +++ b/.github/workflows/code-test.yml @@ -28,7 +28,7 @@ jobs: meson setup build \ -Dprefix=/data/share \ - -Dinit-script=sysvinit \ + -Dinit-script=monitd \ -Druntime-path=/data/local/tmp \ -Dstrip=true \ -Dd_lto=true \ @@ -48,3 +48,15 @@ jobs: --cross-file aarch64-android-api30.txt meson compile -C build + + - name: Upload artifacts sysroot + uses: actions/upload-artifact@v4.3.1 + with: + name: android-aarch64-deps-shared-api30 + path: /data/sysroot/* + + - name: Upload artifacts lxc + uses: actions/upload-artifact@v4.3.1 + with: + name: android-aarch64-lxc-shared-api30 + path: /data/share/* diff --git a/src/lxc/rexec.c b/src/lxc/rexec.c index f2802c2fa7..fdc44c2334 100644 --- a/src/lxc/rexec.c +++ b/src/lxc/rexec.c @@ -96,7 +96,12 @@ static void lxc_rexec_as_memfd(char **argv, char **envp, const char *memfd_name) tmpfd = -EBADF; int ret; ssize_t bytes_sent = 0; +#if IS_BIONIC && __ANDROID_API__ >= 30 + off_t fd_size = -1; +#else + #error "memfd_create() not implemented under Android 30" struct stat st = {0}; +#endif memfd = memfd_create(memfd_name, MFD_ALLOW_SEALING | MFD_CLOEXEC); if (memfd < 0) { @@ -121,15 +126,32 @@ static void lxc_rexec_as_memfd(char **argv, char **envp, const char *memfd_name) return; /* sendfile() handles up to 2GB. */ +#if IS_BIONIC + fd_size = lseek(fd, 0, SEEK_END); + if (fd_size < 0) { + return; + } + + lseek(fd, 0, SEEK_SET); +#else ret = fstat(fd, &st); if (ret) return; +#endif +#if IS_BIONIC + while (bytes_sent < fd_size) { +#else while (bytes_sent < st.st_size) { +#endif ssize_t sent; sent = lxc_sendfile_nointr(memfd >= 0 ? memfd : tmpfd, fd, NULL, +#if IS_BIONIC + fd_size - (off_t)bytes_sent); +#else st.st_size - bytes_sent); +#endif if (sent < 0) { /* * Fallback to shoveling data between kernel- and @@ -166,7 +188,11 @@ static void lxc_rexec_as_memfd(char **argv, char **envp, const char *memfd_name) if (execfd < 0) return; +#if IS_BIONIC + execveat(execfd, "", argv, envp, AT_EMPTY_PATH); +#else fexecve(execfd, argv, envp); +#endif } /* From c20994b6cfa56435b76e6f1052d3008f56b38fdc Mon Sep 17 00:00:00 2001 From: DreamConnected <1487442471@qq.com> Date: Fri, 1 Aug 2025 11:30:50 +0800 Subject: [PATCH 2/3] CI code-test.yml: add install for upload artifacts Signed-off-by: DreamConnected <1487442471@qq.com> --- .github/workflows/code-test.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/code-test.yml b/.github/workflows/code-test.yml index 4ef4345d94..869a473c14 100644 --- a/.github/workflows/code-test.yml +++ b/.github/workflows/code-test.yml @@ -48,6 +48,7 @@ jobs: --cross-file aarch64-android-api30.txt meson compile -C build + sudo /usr/local/bin/ninja -C build install - name: Upload artifacts sysroot uses: actions/upload-artifact@v4.3.1 From 5eb1114e726c11cc5cd5f4f4b985fe7f7b5b7808 Mon Sep 17 00:00:00 2001 From: DreamConnected <1487442471@qq.com> Date: Fri, 1 Aug 2025 11:35:25 +0800 Subject: [PATCH 3/3] CI code-test.yml: no need to upload artifacts sysroot Signed-off-by: DreamConnected <1487442471@qq.com> --- .github/workflows/code-test.yml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/.github/workflows/code-test.yml b/.github/workflows/code-test.yml index 869a473c14..5de7da7c57 100644 --- a/.github/workflows/code-test.yml +++ b/.github/workflows/code-test.yml @@ -49,12 +49,6 @@ jobs: meson compile -C build sudo /usr/local/bin/ninja -C build install - - - name: Upload artifacts sysroot - uses: actions/upload-artifact@v4.3.1 - with: - name: android-aarch64-deps-shared-api30 - path: /data/sysroot/* - name: Upload artifacts lxc uses: actions/upload-artifact@v4.3.1