action.yml 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311
  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. runs:
  17. using: composite
  18. steps:
  19. - name: Setup SUSFS Branch
  20. shell: bash
  21. run: |
  22. SUSFS_BRANCH="gki-${{ inputs.android_version }}-${{ inputs.kernel_version }}"
  23. SUSFS_REPO="https://gitlab.com/simonpunk/susfs4ksu.git"
  24. echo "Preparing SUSFS for branch: $SUSFS_BRANCH"
  25. echo "Cloning latest from $SUSFS_BRANCH..."
  26. git clone "$SUSFS_REPO" -b "$SUSFS_BRANCH" susfs4ksu
  27. if [ "${{ inputs.kernel_version }}" = "5.10" ] && [ "${{ inputs.android_version }}" = "android12" ]; then
  28. SUSFS_COMMIT="e2b0f05ccca5f8fdfc33991c036672235ce48f05"
  29. fi
  30. if [ "${{ inputs.kernel_version }}" = "5.10" ] && [ "${{ inputs.android_version }}" = "android13" ]; then
  31. SUSFS_COMMIT="97234f8e35cdc3b8ea22d05c98ab9829f6421d67"
  32. fi
  33. if [ "${{ inputs.kernel_version }}" = "5.15" ] && [ "${{ inputs.android_version }}" = "android13" ]; then
  34. SUSFS_COMMIT="bf9bf0091bcd4d0072d845ea62484f3011f8d5a8"
  35. fi
  36. if [ "${{ inputs.kernel_version }}" = "5.15" ] && [ "${{ inputs.android_version }}" = "android14" ]; then
  37. SUSFS_COMMIT="667368cf274311a62971671035738b154be1c062"
  38. fi
  39. if [ "${{ inputs.kernel_version }}" = "6.1" ]; then
  40. SUSFS_COMMIT="e1c57040136760a57969fc6b1378cc936a257561"
  41. fi
  42. if [ "${{ inputs.kernel_version }}" = "6.6" ]; then
  43. SUSFS_COMMIT="5009b9edee98fbe66b1a3cb22c603690d81b7817"
  44. fi
  45. if [ "${{ inputs.kernel_version }}" = "6.12" ]; then
  46. SUSFS_COMMIT="5c34dec2c3b69af1d72ac4a89b179741fc602a79"
  47. fi
  48. cd $GITHUB_WORKSPACE/susfs4ksu
  49. git checkout "$SUSFS_COMMIT"
  50. - name: Enable KernelSU SUSFS Config
  51. shell: bash
  52. working-directory: ${{ github.workspace }}/kernel
  53. run: |
  54. cat >> "${{ github.workspace }}/wild_gki.fragment" << 'EOF'
  55. # KernelSU SUSFS Configuration
  56. CONFIG_KSU_SUSFS=y
  57. CONFIG_KSU_SUSFS_SUS_PATH=y
  58. CONFIG_KSU_SUSFS_SUS_MOUNT=y
  59. CONFIG_KSU_SUSFS_SUS_KSTAT=y
  60. CONFIG_KSU_SUSFS_SPOOF_UNAME=y
  61. CONFIG_KSU_SUSFS_ENABLE_LOG=y
  62. CONFIG_KSU_SUSFS_HIDE_KSU_SUSFS_SYMBOLS=y
  63. CONFIG_KSU_SUSFS_SPOOF_CMDLINE_OR_BOOTCONFIG=y
  64. CONFIG_KSU_SUSFS_OPEN_REDIRECT=y
  65. CONFIG_KSU_SUSFS_SUS_MAP=y
  66. EOF
  67. - name: Apply KSU SUSFS Patches
  68. shell: bash
  69. working-directory: ${{ github.workspace }}/kernel/KernelSU-Next
  70. run: |
  71. cp ${{ github.workspace }}/kernel_patches/wild/ksun-e6ba52b-susfs-v2.1.0-a14-6.1-e1c57040.patch ./
  72. patch -p1 < ksun-e6ba52b-susfs-v2.1.0-a14-6.1-e1c57040.patch
  73. - name: Apply Kernel SUSFS Patches
  74. shell: bash
  75. working-directory: ${{ github.workspace }}/kernel/common
  76. run: |
  77. # Apply base SUSFS patches
  78. cp "${{ github.workspace }}/susfs4ksu/kernel_patches/fs/"* "${{ github.workspace }}/kernel/common/fs/"
  79. cp "${{ github.workspace }}/susfs4ksu/kernel_patches/include/linux/"* "${{ github.workspace }}/kernel/common/include/linux/"
  80. cp ${{ github.workspace }}/susfs4ksu/kernel_patches/50_add_susfs_in_gki-${{ inputs.android_version }}-${{ inputs.kernel_version }}.patch ./
  81. - name: Apply Android 12 5.10 Fake Patches
  82. shell: bash
  83. if: inputs.kernel_version == '5.10' && inputs.android_version == 'android12'
  84. working-directory: ${{ github.workspace }}/kernel/common
  85. run: |
  86. if [ "${{ inputs.sublevel }}" -le "43" ]; then
  87. echo "Applying base.c Android 12 5.10 Fake Patch"
  88. perl -i -pe 's/(int|size_t)\s+this_len\s*=\s*min_t\s*\(\s*\1\s*,/size_t this_len = min_t(size_t,/;' fs/proc/base.c
  89. fi
  90. if [ "${{ inputs.sublevel }}" -le "117" ]; then
  91. echo "Applying fdinfo.c Android 12 5.10 Fake Patch"
  92. sed -i '/^[[:space:]]*\/\*$/,/^[[:space:]]*u32 mask = mark->mask & IN_ALL_EVENTS;$/d' fs/notify/fdinfo.c
  93. perl -i -pe 's/\bmask,\s*mark->ignored_mask/inotify_mark_user_mask(mark)/g' fs/notify/fdinfo.c
  94. perl -i -pe 's/ignored_mask:%x/ignored_mask:0/g' fs/notify/fdinfo.c
  95. fi
  96. - name: Apply Android 13 5.10 Fake Patches
  97. shell: bash
  98. if: inputs.kernel_version == '5.10' && inputs.android_version == 'android13'
  99. working-directory: ${{ github.workspace }}/kernel/common
  100. run: |
  101. echo "Applying Android 13 5.10 SUSFS fixes"
  102. if [ "${{ inputs.sublevel }}" -le "107" ]; then
  103. echo "Applying fdinfo.c Android 13 5.10 Fake Patch"
  104. sed -i '/^[[:space:]]*\/\*$/,/^[[:space:]]*u32 mask = mark->mask & IN_ALL_EVENTS;$/d' fs/notify/fdinfo.c
  105. perl -i -pe 's/\bmask,\s*mark->ignored_mask/inotify_mark_user_mask(mark)/g' fs/notify/fdinfo.c
  106. perl -i -pe 's/ignored_mask:%x/ignored_mask:0/g' fs/notify/fdinfo.c
  107. fi
  108. - name: Apply Android 13 5.15 Fake Patches
  109. shell: bash
  110. if: inputs.kernel_version == '5.15' && inputs.android_version == 'android13'
  111. working-directory: ${{ github.workspace }}/kernel/common
  112. run: |
  113. echo "Applying Android 13 5.15 SUSFS fixes"
  114. if [ "${{ inputs.sublevel }}" -le "41" ]; then
  115. #echo "Applying base.c Android 13 5.15 Fake Patch"
  116. #sed -i 's/^int this_len = min_t(int, count, PAGE_SIZE);$/size_t this_len = min_t(size_t, count, PAGE_SIZE);/' fs/proc/base.c
  117. echo "Applying namespace.c Android 13 5.15 SUSFS fixes"
  118. sed -i '/^#include <linux\/shmem_fs.h>$/a #include <linux/mnt_idmapping.h>' fs/namespace.c
  119. echo "Applying open.c Android 13 5.15 Fake Patch"
  120. sed -i '/^#include <linux\/compat.h>$/a #include <linux/mnt_idmapping.h>' fs/open.c
  121. echo "Applying fdinfo.c Android 13 5.15 Fake Patch"
  122. sed -i '/^[[:space:]]*\/\*$/,/^[[:space:]]*u32 mask = mark->mask & IN_ALL_EVENTS;$/d' fs/notify/fdinfo.c
  123. perl -i -pe 's/\bmask,\s*mark->ignored_mask/inotify_mark_user_mask(mark)/g' fs/notify/fdinfo.c
  124. perl -i -pe 's/ignored_mask:%x/ignored_mask:0/g' fs/notify/fdinfo.c
  125. fi
  126. - name: Apply Android 14 6.1 Fake Patches
  127. shell: bash
  128. if: inputs.kernel_version == '6.1' && inputs.android_version == 'android14'
  129. working-directory: ${{ github.workspace }}/kernel/common
  130. run: |
  131. if [ "${{ inputs.sublevel }}" -le "25" ]; then
  132. echo "Applying base.c Android 14 6.1 Fake Patch"
  133. sed -i '/^#include <trace\/events\/oom.h>$/a #include <trace/hooks/sched.h>' fs/proc/base.c
  134. fi
  135. if [ "${{ inputs.sublevel }}" -le "141" ]; then
  136. echo "Applying base.c Android 14 6.1 Fake Patch"
  137. sed -i '/^#include <linux\/cpufreq_times.h>$/a #include <linux/dma-buf.h>' fs/proc/base.c
  138. fi
  139. if [ "${{ inputs.sublevel }}" -ge "157" ]; then
  140. echo "Applying namespace.c Android 14 6.1 Fake Patch"
  141. sed -i '/^#include <trace\/hooks\/blk.h>$/d' fs/namespace.c
  142. fi
  143. - name: Apply Android 15 6.6 Fake Patches
  144. shell: bash
  145. if: inputs.kernel_version == '6.6' && inputs.android_version == 'android15'
  146. working-directory: ${{ github.workspace }}/kernel/common
  147. run: |
  148. echo "Applying 6.6 SUSFS fixes"
  149. #if [ "${{ inputs.sublevel }}" -le "46" ]; then
  150. # echo "Applying namespace.c Android 15 6.6 Fake Patch"
  151. # sed -i '/^#include <trace\/hooks\/blk.h>$/a #include <trace/hooks/fs.h>' fs/namespace.c
  152. #fi
  153. if [ "${{ inputs.sublevel }}" -le "58" ]; then
  154. echo "Applying task_mmu.c Android 15 6.6 Fake Patch"
  155. sed -i '/int ret.*= 0, copied.*= 0;/{
  156. /int ret.*= 0, copied.*= 0;/!d
  157. a\
  158. unsigned int nr_subpages = __PAGE_SIZE / PAGE_SIZE;\
  159. pagemap_entry_t *res = NULL;
  160. }' fs/proc/task_mmu.c
  161. fi
  162. cat fs/proc/task_mmu.c
  163. if [ "${{ inputs.sublevel }}" -le "92" ]; then
  164. echo "Applying base.c Android 15 6.6 Fake Patch"
  165. sed -i '/^#include <linux\/cpufreq_times.h>$/a #include <linux/dma-buf.h>' fs/proc/base.c
  166. fi
  167. - name: Apply Android 16 6.12 Fake Patches
  168. shell: bash
  169. if: inputs.kernel_version == '6.12' && inputs.android_version == 'android16'
  170. working-directory: ${{ github.workspace }}/kernel/common
  171. run: |
  172. echo "Applying 6.12 SUSFS fixes"
  173. if [ "${{ inputs.sublevel }}" -le "77" ]; then
  174. echo "Applying exec.c Android 16 6.12 Fake Patch"
  175. sed -i '/^#include <linux\/dma-buf.h>$/d' fs/exec.c
  176. fi
  177. - name: Apply Kernel SUSFS Patches
  178. shell: bash
  179. working-directory: ${{ github.workspace }}/kernel/common
  180. run: |
  181. patch -p1 < 50_add_susfs_in_gki-${{ inputs.android_version }}-${{ inputs.kernel_version }}.patch || true
  182. - name: Revert Android 12 5.10 Fake Patches
  183. shell: bash
  184. if: inputs.kernel_version == '5.10' && inputs.android_version == 'android12'
  185. working-directory: ${{ github.workspace }}/kernel/common
  186. run: |
  187. if [ "${{ inputs.sublevel }}" -le "43" ]; then
  188. echo "Reverting base.c Android 12 5.10 Fake Patch"
  189. sed -i 's/^size_t this_len = min_t(size_t, count, PAGE_SIZE);$/int this_len = min_t(int, count, PAGE_SIZE);/' fs/proc/base.c
  190. fi
  191. if [ "${{ inputs.sublevel }}" -le "117" ]; then
  192. echo "Reverting fdinfo.c Android 12 5.10 Fake Patch"
  193. perl -i -pe 's/^(\s+if \(inode\) \{)/$1\n\t\t\/\*\n\t\t * IN_ALL_EVENTS represents all of the mask bits\n\t\t * that we expose to userspace. There is at\n\t\t * least one bit (FS_EVENT_ON_CHILD) which is\n\t\t * used only internally to the kernel.\n\t\t *\/\n\t\tu32 mask = mark->mask & IN_ALL_EVENTS;/m' fs/notify/fdinfo.c
  194. perl -i -pe 's/\binotify_mark_user_mask\(mark\)/mask, mark->ignored_mask/g' fs/notify/fdinfo.c
  195. perl -i -pe 's/ignored_mask:0/ignored_mask:%x/g' fs/notify/fdinfo.c
  196. fi
  197. - name: Revert Android 13 5.10 Fake Patches
  198. shell: bash
  199. if: inputs.kernel_version == '5.10' && inputs.android_version == 'android13'
  200. working-directory: ${{ github.workspace }}/kernel/common
  201. run: |
  202. if [ "${{ inputs.sublevel }}" -le "107" ]; then
  203. echo "Reverting fdinfo.c Android 13 5.10 Fake Patch"
  204. perl -i -pe 's/^(\s+if \(inode\) \{)/$1\n\t\t\/\*\n\t\t * IN_ALL_EVENTS represents all of the mask bits\n\t\t * that we expose to userspace. There is at\n\t\t * least one bit (FS_EVENT_ON_CHILD) which is\n\t\t * used only internally to the kernel.\n\t\t *\/\n\t\tu32 mask = mark->mask & IN_ALL_EVENTS;/m' fs/notify/fdinfo.c
  205. perl -i -pe 's/\binotify_mark_user_mask\(mark\)/mask, mark->ignored_mask/g' fs/notify/fdinfo.c
  206. perl -i -pe 's/ignored_mask:0/ignored_mask:%x/g' fs/notify/fdinfo.c
  207. fi
  208. - name: Revert Android 13 5.15 Fake Patches
  209. shell: bash
  210. if: inputs.kernel_version == '5.15' && inputs.android_version == 'android13'
  211. working-directory: ${{ github.workspace }}/kernel/common
  212. run: |
  213. if [ "${{ inputs.sublevel }}" -le "41" ]; then
  214. #echo "Reverting base.c Android 13 5.15 Fake Patch"
  215. #sed -i 's/^size_t this_len = min_t(size_t, count, PAGE_SIZE);$/int this_len = min_t(int, count, PAGE_SIZE);/' fs/proc/base.c
  216. echo "Reverting namespace.c Android 13 5.15 Fake Patch"
  217. sed -i '/#include <linux\/mnt_idmapping.h>$/d' fs/namespace.c
  218. echo "Reverting open.c Android 13 5.15 Fake Patch"
  219. sed -i '/#include <linux\/mnt_idmapping.h>$/d' fs/open.c
  220. echo "Reverting fdinfo.c Android 13 5.15 Fake Patch"
  221. perl -i -pe 's/^(\s+if \(inode\) \{)/$1\n\t\t\/\*\n\t\t * IN_ALL_EVENTS represents all of the mask bits\n\t\t * that we expose to userspace. There is at\n\t\t * least one bit (FS_EVENT_ON_CHILD) which is\n\t\t * used only internally to the kernel.\n\t\t *\/\n\t\tu32 mask = mark->mask & IN_ALL_EVENTS;/m' fs/notify/fdinfo.c
  222. perl -i -pe 's/\binotify_mark_user_mask\(mark\)/mask, mark->ignored_mask/g' fs/notify/fdinfo.c
  223. perl -i -pe 's/ignored_mask:0/ignored_mask:%x/g' fs/notify/fdinfo.c
  224. sed -i 's|i_uid_into_mnt(i_user_ns(&fi->inode), &fi->inode).val|i_uid_into_mnt(\&init_user_ns, \&fi->inode).val|g' fs/susfs.c
  225. sed -i 's|i_uid_into_mnt(i_user_ns(inode), inode).val|i_uid_into_mnt(\&init_user_ns, inode).val|g' fs/susfs.c
  226. fi
  227. - name: Revert Android 14 6.1 Fake Patches
  228. shell: bash
  229. if: inputs.kernel_version == '6.1' && inputs.android_version == 'android14'
  230. working-directory: ${{ github.workspace }}/kernel/common
  231. run: |
  232. if [ "${{ inputs.sublevel }}" -le "25" ]; then
  233. sed -i '/^#include <trace\/hooks\/sched.h>$/d' fs/proc/base.c
  234. fi
  235. if [ "${{ inputs.sublevel }}" -le "141" ]; then
  236. echo "Reverting base.c Android 14 6.1 Fake Patch"
  237. sed -i '/^#include <linux\/dma-buf.h>$/d' fs/proc/base.c
  238. fi
  239. if [ "${{ inputs.sublevel }}" -ge "157" ]; then
  240. echo "Reverting namespace.c Android 14 6.1 Fake Patch"
  241. sed -i '/^#include "internal.h"$/a #include <trace/hooks/blk.h>' fs/namespace.c
  242. fi
  243. - name: Revert Android 15 6.6 Fake Patches
  244. shell: bash
  245. if: inputs.kernel_version == '6.6' && inputs.android_version == 'android15'
  246. working-directory: ${{ github.workspace }}/kernel/common
  247. run: |
  248. echo "Reverting 6.6 Fake Patches"
  249. #if [ "${{ inputs.sublevel }}" -le "46" ]; then
  250. # echo "Reverting namespace.c Android 15 6.6 Fake Patch"
  251. # sed -i '/^#include <trace\/hooks\/fs.h>$/d' fs/namespace.c
  252. #fi
  253. if [ "${{ inputs.sublevel }}" -le "58" ]; then
  254. echo "Reverting task_mmu.c Android 15 6.6 Fake Patch"
  255. sed -i '/unsigned int nr_subpages.*__PAGE_SIZE.*PAGE_SIZE/d' fs/proc/task_mmu.c
  256. sed -i '/pagemap_entry_t.*res.*NULL/d' fs/proc/task_mmu.c
  257. fi
  258. if [ "${{ inputs.sublevel }}" -le "92" ]; then
  259. echo "Reverting base.c Android 15 6.6 Fake Patch"
  260. sed -i '/^#include <linux\/dma-buf.h>$/d' fs/proc/base.c
  261. fi
  262. - name: Revert Android 16 6.12 Fake Patches
  263. shell: bash
  264. if: inputs.kernel_version == '6.12' && inputs.android_version == 'android16'
  265. working-directory: ${{ github.workspace }}/kernel/common
  266. run: |
  267. echo "Reverting 6.12 Fake Patches"
  268. if [ "${{ inputs.sublevel }}" -le "77" ]; then
  269. echo "Reverting exec.c Android 16 6.12 Fake Patch"
  270. sed -i '/^#include <linux\/ksh.h>$/a #include <linux/dma-buf.h>' fs/exec.c
  271. fi
  272. - name: Apply Kernel SUSFS Patches
  273. shell: bash
  274. if: true
  275. working-directory: ${{ github.workspace }}/kernel/common
  276. run: |
  277. SHOW_PAD_FIX=0
  278. if [[ "${{ inputs.android_version }}" = "android12" && "${{ inputs.kernel_version }}" = "5.10" && "${{ inputs.sublevel }}" -le 209 ]]; then
  279. SHOW_PAD_FIX=1
  280. elif [[ "${{ inputs.android_version }}" = "android13" && "${{ inputs.kernel_version }}" = "5.10" && "${{ inputs.sublevel }}" -le 209 && "${{ inputs.os_patch_level }}" != "2024-05" ]]; then
  281. SHOW_PAD_FIX=1
  282. elif [[ "${{ inputs.android_version }}" = "android13" && "${{ inputs.kernel_version }}" = "5.15" && "${{ inputs.sublevel }}" -le 148 && "${{ inputs.os_patch_level }}" != "2024-05" ]]; then
  283. SHOW_PAD_FIX=1
  284. elif [[ "${{ inputs.android_version }}" = "android14" && "${{ inputs.kernel_version }}" = "5.15" && "${{ inputs.sublevel }}" -le 148 && "${{ inputs.os_patch_level }}" != "2024-05" ]]; then
  285. SHOW_PAD_FIX=1
  286. elif [[ "${{ inputs.android_version }}" = "android14" && "${{ inputs.kernel_version }}" = "6.1" && "${{ inputs.sublevel }}" -le 75 && "${{ inputs.os_patch_level }}" != "2024-05" ]]; then
  287. SHOW_PAD_FIX=1
  288. fi
  289. if [[ "$SHOW_PAD_FIX" = "1" ]]; then
  290. sed -i -e 's/goto show_pad;/return 0;/' ./fs/proc/task_mmu.c
  291. fi