action.yml 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. name: 'Apply SUSFS Patches'
  2. description: 'Copy base SUSFS patches and apply version-specific fake patches'
  3. inputs:
  4. version:
  5. description: 'Kernel config version (e.g., android15-6.6)'
  6. required: true
  7. sublevel:
  8. description: 'Kernel sublevel'
  9. required: true
  10. os_patch_level:
  11. description: 'OS patch level (e.g., 2024-07)'
  12. required: true
  13. runs:
  14. using: "composite"
  15. steps:
  16. - name: Apply Kernel SUSFS Patches
  17. shell: bash
  18. working-directory: ${{ github.workspace }}/kernel/common
  19. run: |
  20. # Apply base SUSFS patches
  21. cp "${{ github.workspace }}/susfs4ksu/kernel_patches/fs/"* "${{ github.workspace }}/kernel/common/fs/"
  22. cp "${{ github.workspace }}/susfs4ksu/kernel_patches/include/linux/"* "${{ github.workspace }}/kernel/common/include/linux/"
  23. cp ${{ github.workspace }}/susfs4ksu/kernel_patches/50_add_susfs_in_gki-${{ inputs.version }}.patch ./
  24. - name: Apply Android 12 5.10 Fake Patches
  25. shell: bash
  26. if: inputs.version == 'android12-5.10'
  27. working-directory: ${{ github.workspace }}/kernel/common
  28. run: |
  29. if [ "${{ inputs.sublevel }}" -le "43" ]; then
  30. echo "Applying base.c Android 12 5.10 Fake Patch"
  31. 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
  32. fi
  33. if [ "${{ inputs.sublevel }}" -le "117" ]; then
  34. echo "Applying fdinfo.c Android 12 5.10 Fake Patch"
  35. sed -i '/^[[:space:]]*\/\*$\|^[[:space:]]*u32 mask = mark->mask & IN_ALL_EVENTS;$/d' fs/notify/fdinfo.c
  36. perl -i -pe 's/\bmask,\s*mark->ignored_mask/inotify_mark_user_mask(mark)/g' fs/notify/fdinfo.c
  37. perl -i -pe 's/ignored_mask:%x/ignored_mask:0/g' fs/notify/fdinfo.c
  38. fi
  39. - name: Apply Android 13 5.10 Fake Patches
  40. shell: bash
  41. if: inputs.version == 'android13-5.10'
  42. working-directory: ${{ github.workspace }}/kernel/common
  43. run: |
  44. echo "Applying Android 13 5.10 SUSFS fixes"
  45. if [ "${{ inputs.sublevel }}" -le "107" ]; then
  46. echo "Applying fdinfo.c Android 13 5.10 Fake Patch"
  47. sed -i '/^[[:space:]]*\/\*$\|^[[:space:]]*u32 mask = mark->mask & IN_ALL_EVENTS;$/d' fs/notify/fdinfo.c
  48. perl -i -pe 's/\bmask,\s*mark->ignored_mask/inotify_mark_user_mask(mark)/g' fs/notify/fdinfo.c
  49. perl -i -pe 's/ignored_mask:%x/ignored_mask:0/g' fs/notify/fdinfo.c
  50. fi
  51. - name: Apply Android 13 5.15 Fake Patches
  52. shell: bash
  53. if: inputs.version == 'android13-5.15'
  54. working-directory: ${{ github.workspace }}/kernel/common
  55. run: |
  56. echo "Applying Android 13 5.15 SUSFS fixes"
  57. if [ "${{ inputs.sublevel }}" -le "41" ]; then
  58. echo "Applying namespace.c Android 13 5.15 SUSFS fixes"
  59. sed -i '/^#include <linux\/shmem_fs.h>$/a #include <linux/mnt_idmapping.h>' fs/namespace.c
  60. echo "Applying open.c Android 13 5.15 Fake Patch"
  61. sed -i '/^#include <linux\/compat.h>$/a #include <linux/mnt_idmapping.h>' fs/open.c
  62. echo "Applying fdinfo.c Android 13 5.15 Fake Patch"
  63. sed -i '/^[[:space:]]*\/\*$\|^[[:space:]]*u32 mask = mark->mask & IN_ALL_EVENTS;$/d' fs/notify/fdinfo.c
  64. perl -i -pe 's/\bmask,\s*mark->ignored_mask/inotify_mark_user_mask(mark)/g' fs/notify/fdinfo.c
  65. perl -i -pe 's/ignored_mask:%x/ignored_mask:0/g' fs/notify/fdinfo.c
  66. fi
  67. if [ "${{ inputs.sublevel }}" -ge "197" ]; then
  68. echo "Applying namespace.c Android 13 5.15 Fake Patch"
  69. sed -i '/^#include <trace\/hooks\/blk.h>$/d' fs/namespace.c
  70. fi
  71. if [ "${{ inputs.sublevel }}" -ge "197" ]; then
  72. echo "Applying task_mmu.c Android 13 5.15 Fake Patch"
  73. sed -i '/^#include <trace\/hooks\/mm.h>$/d' fs/proc/task_mmu.c
  74. fi
  75. - name: Apply Android 14 6.1 Fake Patches
  76. shell: bash
  77. if: inputs.version == 'android14-6.1'
  78. working-directory: ${{ github.workspace }}/kernel/common
  79. run: |
  80. if [ "${{ inputs.sublevel }}" -le "25" ]; then
  81. echo "Applying base.c Android 14 6.1 Fake Patch"
  82. sed -i '/^#include <trace\/events\/oom.h>$/a #include <trace/hooks/sched.h>' fs/proc/base.c
  83. fi
  84. if [ "${{ inputs.sublevel }}" -le "141" ]; then
  85. echo "Applying base.c Android 14 6.1 Fake Patch"
  86. sed -i '/^#include <linux\/cpufreq_times.h>$/a #include <linux/dma-buf.h>' fs/proc/base.c
  87. fi
  88. if [ "${{ inputs.sublevel }}" -ge "157" ]; then
  89. echo "Applying namespace.c Android 14 6.1 Fake Patch"
  90. sed -i '/^#include <trace\/hooks\/blk.h>$/d' fs/namespace.c
  91. fi
  92. - name: Apply Android 15 6.6 Fake Patches
  93. shell: bash
  94. if: inputs.version == 'android15-6.6'
  95. working-directory: ${{ github.workspace }}/kernel/common
  96. run: |
  97. echo "Applying 6.6 SUSFS fixes"
  98. if [ "${{ inputs.sublevel }}" -le "30" ]; then
  99. echo "Applying taskmmu.c Android 15 6.6 Fake Patch"
  100. sed -i '/smap_gather_stats(vma, &mss, last_vma_end);/a\last_vma_end = vma->vm_end;' fs/proc/task_mmu.c
  101. perl -0777 -i -pe '
  102. @l = split /\n/;
  103. for ($i = $#l; $i >= 0; $i--) {
  104. if ($l[$i] =~ /last_vma_end = vma->vm_end;/) {
  105. $l[$i] = "\t\t\t\t" . $l[$i];
  106. splice(@l, $i + 1, 0, "\t\t\t}");
  107. # add { to the if line above
  108. for ($j = $i; $j >= 0; $j--) {
  109. if ($l[$j] =~ /if\s*\(vma->vm_end > last_vma_end\)/) {
  110. $l[$j] =~ s/\)\s*\$/) {/;
  111. last;
  112. }
  113. }
  114. last;
  115. }
  116. }
  117. $_ = join "\n", @l
  118. ' fs/proc/task_mmu.c
  119. fi
  120. if [ "${{ inputs.sublevel }}" -le "92" ]; then
  121. echo "Applying base.c Android 15 6.6 Fake Patch"
  122. sed -i '/^#include <linux\/cpufreq_times.h>$/a #include <linux/dma-buf.h>' fs/proc/base.c
  123. fi
  124. if [ "${{ inputs.sublevel }}" -le "57" ]; then
  125. echo "Applying base.c Android 15 6.6 Fake Patch"
  126. sed -i '/^#include <linux\/sched\/sysctl.h>$/a #include <linux/zswap.h>' mm/memory.c
  127. fi
  128. - name: Apply Android 16 6.12 Fake Patches
  129. shell: bash
  130. if: inputs.version == 'android16-6.12'
  131. working-directory: ${{ github.workspace }}/kernel/common
  132. run: |
  133. echo "Applying 6.12 SUSFS fixes"
  134. if [ "${{ inputs.sublevel }}" -ge "58" ]; then
  135. echo "Applying exec.c Android 16 6.12 Fake Patch"
  136. sed -i '/^#include <linux\/dma-buf.h>$/d' fs/exec.c
  137. fi
  138. if [ "${{ inputs.sublevel }}" -ge "69" ]; then
  139. echo "Applying task_mmu.c Android 16 6.12 Fake Patch"
  140. sed -i 's/vma_data_pages/vma_pages/g' fs/proc/task_mmu.c
  141. fi
  142. - name: Apply Kernel SUSFS Patches
  143. shell: bash
  144. working-directory: ${{ github.workspace }}/kernel/common
  145. run: |
  146. patch -p1 < 50_add_susfs_in_gki-${{ inputs.version }}.patch