action.yml 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. name: Setup SUSFS
  2. description: Clone and apply SUSFS patches with version-specific fixes
  3. inputs:
  4. android_version:
  5. description: 'Android version (e.g., android15)'
  6. required: true
  7. kernel_version:
  8. description: 'Kernel version (e.g., 6.6)'
  9. required: true
  10. os_patch_level:
  11. description: 'OS patch level (e.g., 2024-07)'
  12. required: true
  13. sublevel:
  14. description: 'Kernel sublevel'
  15. required: true
  16. susfs_commit:
  17. description: 'Commit map (branch:commit,branch:commit...)'
  18. required: false
  19. runs:
  20. using: composite
  21. steps:
  22. - name: Setup SUSFS Branch
  23. shell: bash
  24. run: |
  25. SUSFS_BRANCH="gki-${{ inputs.android_version }}-${{ inputs.kernel_version }}"
  26. SUSFS_REPO="https://gitlab.com/simonpunk/susfs4ksu.git"
  27. echo "Preparing SUSFS for branch: $SUSFS_BRANCH"
  28. # Parse commit map to find the commit for this branch
  29. COMMIT_MAP="${{ inputs.susfs_commit }}"
  30. TARGET_COMMIT=""
  31. if [ -n "$COMMIT_MAP" ]; then
  32. # Split by comma
  33. IFS=',' read -ra ENTRIES <<< "$COMMIT_MAP"
  34. for entry in "${ENTRIES[@]}"; do
  35. # Split by colon
  36. IFS=':' read -r branch commit <<< "$entry"
  37. if [ "$branch" == "$SUSFS_BRANCH" ]; then
  38. TARGET_COMMIT="$commit"
  39. break
  40. fi
  41. done
  42. fi
  43. if [ -n "$TARGET_COMMIT" ]; then
  44. echo "Found specific commit for $SUSFS_BRANCH: $TARGET_COMMIT"
  45. git clone "$SUSFS_REPO" -b "$SUSFS_BRANCH" susfs4ksu
  46. cd susfs4ksu
  47. git checkout "$TARGET_COMMIT"
  48. cd ..
  49. else
  50. echo "No specific commit found for $SUSFS_BRANCH, cloning latest..."
  51. git clone "$SUSFS_REPO" -b "$SUSFS_BRANCH" --depth=1 susfs4ksu
  52. fi
  53. SUSFS_VERSION="v2.1.0"
  54. echo "SUSFS_VERSION=$SUSFS_VERSION" >> $GITHUB_ENV
  55. echo "SUSFS_BRANCH=$SUSFS_BRANCH" >> $GITHUB_ENV
  56. echo "SUSFS_COMMIT=$TARGET_COMMIT" >> $GITHUB_ENV
  57. - name: Enable KernelSU SUSFS Config
  58. shell: bash
  59. working-directory: ${{ github.workspace }}/kernel
  60. run: |
  61. cat >> "${{ github.workspace }}/wild_gki.fragment" << 'EOF'
  62. # KernelSU SUSFS Configuration
  63. CONFIG_KSU_SUSFS=y
  64. CONFIG_KSU_SUSFS_SUS_PATH=y
  65. CONFIG_KSU_SUSFS_SUS_MOUNT=y
  66. CONFIG_KSU_SUSFS_SUS_KSTAT=y
  67. CONFIG_KSU_SUSFS_SPOOF_UNAME=y
  68. CONFIG_KSU_SUSFS_ENABLE_LOG=y
  69. CONFIG_KSU_SUSFS_HIDE_KSU_SUSFS_SYMBOLS=y
  70. CONFIG_KSU_SUSFS_SPOOF_CMDLINE_OR_BOOTCONFIG=y
  71. CONFIG_KSU_SUSFS_OPEN_REDIRECT=y
  72. CONFIG_KSU_SUSFS_SUS_MAP=y
  73. EOF
  74. - name: Apply KSU SUSFS Patches
  75. shell: bash
  76. working-directory: ${{ github.workspace }}/kernel/KernelSU-Next
  77. run: |
  78. cp ${{ github.workspace }}/kernel_patches/wild/ksun-0daf55582-susfs-v2.1.0-e259e7d6.patch ./
  79. patch -p1 < ksun-0daf55582-susfs-v2.1.0-e259e7d6.patch
  80. - name: Apply Kernel SUSFS Patches
  81. shell: bash
  82. working-directory: ${{ github.workspace }}/kernel/common
  83. run: |
  84. # Apply base SUSFS patches
  85. cp "${{ github.workspace }}/susfs4ksu/kernel_patches/fs/"* "${{ github.workspace }}/kernel/common/fs/"
  86. cp "${{ github.workspace }}/susfs4ksu/kernel_patches/include/linux/"* "${{ github.workspace }}/kernel/common/include/linux/"
  87. cp ${{ github.workspace }}/susfs4ksu/kernel_patches/50_add_susfs_in_gki-${{ inputs.android_version }}-${{ inputs.kernel_version }}.patch ./
  88. FIX_NAMESPACE=0
  89. if [ "${{ inputs.kernel_version }}" = "6.1" ]; then
  90. if grep -q '^#include <trace/hooks/blk.h>$' fs/namespace.c; then
  91. sed -i '/^#include <trace\/hooks\/blk.h>$/d' fs/namespace.c
  92. FIX_NAMESPACE=1
  93. fi
  94. fi
  95. patch -p1 < 50_add_susfs_in_gki-${{ inputs.android_version }}-${{ inputs.kernel_version }}.patch || true
  96. if [ "$FIX_NAMESPACE" = "1" ]; then
  97. sed -i '/^#include "internal.h"$/a #include <trace/hooks/blk.h>' fs/namespace.c
  98. fi
  99. SHOULD_FIX=0
  100. if [[ "${{ inputs.android_version }}" = "android12" && "${{ inputs.kernel_version }}" = "5.10" && "${{ inputs.sublevel }}" -le 209 ]]; then
  101. SHOULD_FIX=1
  102. elif [[ "${{ inputs.android_version }}" = "android13" && "${{ inputs.kernel_version }}" = "5.10" && "${{ inputs.sublevel }}" -le 209 && "${{ inputs.os_patch_level }}" != "2024-05" ]]; then
  103. SHOULD_FIX=1
  104. elif [[ "${{ inputs.android_version }}" = "android13" && "${{ inputs.kernel_version }}" = "5.15" && "${{ inputs.sublevel }}" -le 148 && "${{ inputs.os_patch_level }}" != "2024-05" ]]; then
  105. SHOULD_FIX=1
  106. elif [[ "${{ inputs.android_version }}" = "android14" && "${{ inputs.kernel_version }}" = "5.15" && "${{ inputs.sublevel }}" -le 148 && "${{ inputs.os_patch_level }}" != "2024-05" ]]; then
  107. SHOULD_FIX=1
  108. elif [[ "${{ inputs.android_version }}" = "android14" && "${{ inputs.kernel_version }}" = "6.1" ]]; then
  109. SHOULD_FIX=1
  110. fi
  111. if [[ "$SHOULD_FIX" = "1" ]]; then
  112. sed -i -e 's/goto show_pad;/return 0;/' ./fs/proc/task_mmu.c
  113. fi
  114. - name: Apply Android 12 5.10 Fixes
  115. if: inputs.android_version == 'android12' && inputs.kernel_version == '5.10'
  116. shell: bash
  117. working-directory: ${{ github.workspace }}/kernel/common
  118. run: |
  119. if [ "${{ inputs.sublevel }}" -le "43" ]; then
  120. sed '/size_t this_len = min_t(size_t, count, PAGE_SIZE);/r'<(cat <<'EOF'
  121. #ifdef CONFIG_KSU_SUSFS_SUS_MAP
  122. vma = find_vma(mm, addr);
  123. if (vma && vma->vm_file) {
  124. struct inode *inode = file_inode(vma->vm_file);
  125. if (SUSFS_IS_INODE_SUS_MAP(inode)) {
  126. if (write) {
  127. copied = -EFAULT;
  128. } else {
  129. copied = -EIO;
  130. }
  131. *ppos = addr;
  132. mmput(mm);
  133. goto free;
  134. }
  135. }
  136. #endif
  137. EOF
  138. ) fs/proc/base.c
  139. fi
  140. if [ "${{ inputs.sublevel }}" -le "117" ]; then
  141. sed '/size_t this_len = min_t(size_t, count, PAGE_SIZE);/r'<(cat <<'EOF'
  142. #ifdef CONFIG_KSU_SUSFS_SUS_MOUNT
  143. mnt = real_mount(file->f_path.mnt);
  144. if (mnt->mnt_id >= DEFAULT_KSU_MNT_ID &&
  145. likely(susfs_is_current_proc_umounted()))
  146. {
  147. struct path path;
  148. char *pathname = kmalloc(PAGE_SIZE, GFP_KERNEL);
  149. char *dpath;
  150. if (!pathname) {
  151. goto orig_flow;
  152. }
  153. dpath = d_path(&file->f_path, pathname, PAGE_SIZE);
  154. if (!dpath) {
  155. goto out_kfree;
  156. }
  157. if (kern_path(dpath, 0, &path)) {
  158. goto out_kfree;
  159. }
  160. if (!path.dentry->d_inode) {
  161. goto out_path_put;
  162. }
  163. seq_printf(m, "inotify wd:%x ino:%lx sdev:%x mask:%x ignored_mask:0 ",
  164. inode_mark->wd, path.dentry->d_inode->i_ino, path.dentry->d_inode->i_sb->s_dev,
  165. inotify_mark_user_mask(mark));
  166. show_mark_fhandle(m, path.dentry->d_inode);
  167. seq_putc(m, '\n');
  168. path_put(&path);
  169. kfree(pathname);
  170. iput(inode);
  171. return;
  172. out_path_put:
  173. path_put(&path);
  174. out_kfree:
  175. kfree(pathname);
  176. }
  177. orig_flow:
  178. #endif // #ifdef CONFIG_KSU_SUSFS_SUS_MOUNT
  179. EOF
  180. ) fs/notify/fdinfo.c
  181. fi