action.yml 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. name: apply susfs patches
  2. description: apply susfs patches
  3. inputs:
  4. flavor:
  5. description: 'root flavor (kernelsu, next, resukisu) - pershoot commits only apply to next'
  6. required: false
  7. default: ""
  8. susfs_commit:
  9. description: 'pinned SUSFS commit (empty = latest tip)'
  10. required: false
  11. default: ""
  12. runs:
  13. using: composite
  14. steps:
  15. - name: clone susfs
  16. shell: bash
  17. run: |
  18. SUSFS_BRANCH="gki-$ANDROID_VER-$KERNEL_VER"
  19. git clone https://gitlab.com/simonpunk/susfs4ksu.git -b "$SUSFS_BRANCH"
  20. if [ -n "${{ inputs.susfs_commit }}" ]; then
  21. echo "Checking out pinned SUSFS ${{ inputs.susfs_commit }}"
  22. git -C susfs4ksu fetch --depth 1 origin "${{ inputs.susfs_commit }}" || git -C susfs4ksu fetch origin "${{ inputs.susfs_commit }}"
  23. git -C susfs4ksu checkout "${{ inputs.susfs_commit }}"
  24. fi
  25. git config --global user.name "github-actions[bot]"
  26. git config --global user.email "41898282+github-actions[bot]@://github.com"
  27. cd susfs4ksu
  28. # Pershoot's gki-android14-6.1-dev commits only apply to KernelSU-Next
  29. # (dev-susfs fork). Other flavors use the simonpunk checkout as-is.
  30. if [ "${{ inputs.flavor }}" = "next" ]; then
  31. git fetch https://gitlab.com/pershoot/susfs4ksu.git gki-android14-6.1-dev || true
  32. git log ..FETCH_HEAD --oneline -n 2 | awk '{print $1}' | tac | xargs git cherry-pick 2>/dev/null || true
  33. fi
  34. SUSFS4KSU="$ROOT/susfs4ksu"
  35. echo "SUSFS4KSU=$SUSFS4KSU" >> $GITHUB_ENV
  36. echo "SUSFS_COMMIT=$(git -C "$ROOT/susfs4ksu" rev-parse HEAD)" >> $GITHUB_ENV
  37. - name: Apply to KSUN
  38. shell: bash
  39. run: |
  40. # Tiann KernelSU does not ship SUSFS: apply the enable patch to the
  41. # root checkout. Next and ReSukiSU already include SUSFS, skip them.
  42. if [ "${{ inputs.flavor }}" = "kernelsu" ]; then
  43. PATCH="$SUSFS4KSU/kernel_patches/KernelSU/10_enable_susfs_for_ksu.patch"
  44. if [ ! -f "$PATCH" ]; then
  45. echo "Missing 10_enable_susfs_for_ksu.patch at $PATCH" >&2
  46. exit 1
  47. fi
  48. echo "Applying SUSFS enable patch to KernelSU checkout at $ROOT_DIR"
  49. git -C "$ROOT_DIR" apply --check "$PATCH"
  50. git -C "$ROOT_DIR" apply "$PATCH"
  51. else
  52. echo "SUSFS prepared at $SUSFS4KSU (flavor ${{ inputs.flavor }} ships its own SUSFS)"
  53. fi
  54. - name: Copy required files
  55. shell: bash
  56. run: |
  57. cd "$COMMON"
  58. cp "$SUSFS4KSU/kernel_patches/fs/"* ./fs/
  59. cp "$SUSFS4KSU/kernel_patches/include/linux/"* ./include/linux/
  60. cp "$SUSFS4KSU/kernel_patches/50_add_susfs_in_gki-$ANDROID_VER-$KERNEL_VER.patch" ./
  61. - name: prepare namespace and open.c for susfs patch because scamsung
  62. shell: bash
  63. run: |
  64. cd "$COMMON"
  65. sed -i '/#ifdef CONFIG_SECURITY_DEFEX/,/^#endif/d' fs/open.c
  66. sed -i '/copy_flags = CL_COPY_UNBINDABLE | CL_EXPIRE;/,/#endif/ {
  67. /#ifdef CONFIG_KDP_NS/,/#endif/ {
  68. /#else/,/#endif/!d
  69. /#else/d
  70. /#endif/d
  71. }
  72. }' fs/namespace.c
  73. - name: apply susfs patch and fix if necessary
  74. shell: bash
  75. run: |
  76. cd "$COMMON"
  77. patch -p1 < 50_add_susfs_in_gki-$ANDROID_VER-$KERNEL_VER.patch
  78. rm -rf 50_add_susfs_in_gki-$ANDROID_VER-$KERNEL_VER.patch
  79. shopt -s nullglob
  80. patches=("$KERNEL_PATCHES/samsung/$BRANCH"/*.patch)
  81. if [ ${#patches[@]} -gt 0 ]; then
  82. echo "Patches found, applying..."
  83. cp "${patches[@]}" ./
  84. for p in *.patch; do
  85. patch -p1 < "$p"
  86. rm -f "$p"
  87. done
  88. shopt -u nullglob
  89. else
  90. echo "No patch file found, skipping"
  91. fi
  92. if grep -q 'VMA_PAD_START(' fs/proc/task_mmu.c && ! grep -qE '#include <linux/pgsize_migration(_inline)?\.h>|define VMA_PAD_START' fs/proc/task_mmu.c; then
  93. sed -i '1a #ifndef VMA_PAD_START\n#define VMA_PAD_START(vma) ((vma)->vm_end)\n#endif' fs/proc/task_mmu.c
  94. echo "Added VMA_PAD_START fallback"
  95. fi
  96. if grep -q '__fold_filemap_fixup_entry' fs/proc/task_mmu.c && ! grep -q '#include <linux/page_size_compat.h>' fs/proc/task_mmu.c; then
  97. sed -i '/#include <linux\/pkeys.h>/a #include <linux/page_size_compat.h>' fs/proc/task_mmu.c
  98. echo "Added page_size_compat.h include"
  99. fi
  100. - name: fix with_policy static on 6.6+ (port from GKI)
  101. shell: bash
  102. run: |
  103. if [ "$(printf '%s\n' "6.6" "$KERNEL_VER" | sort -V | head -n1)" = "6.6" ]; then
  104. echo "[*] KVER $KERNEL_VER >= 6.6, stripping static from with_policy helpers"
  105. for f in $(find "$COMMON" -name selinux_hide.c 2>/dev/null); do
  106. if grep -q "^static int security_context_to_sid_with_policy" "$f"; then
  107. echo "[*] Stripping static from $f helpers"
  108. sed -i 's/^static int security_context_to_sid_with_policy/int security_context_to_sid_with_policy/g' "$f"
  109. sed -i 's/^static int security_sid_to_context_with_policy/int security_sid_to_context_with_policy/g' "$f"
  110. sed -i 's/^static void security_compute_av_user_with_policy/void security_compute_av_user_with_policy/g' "$f"
  111. echo "[+] Stripped static from $f"
  112. fi
  113. done
  114. else
  115. echo "[-] KVER $KERNEL_VER < 6.6, skipping"
  116. fi
  117. - name: add ksu-susfs to config
  118. shell: bash
  119. run: |
  120. "$COMMON/scripts/config" --file "$GKI_DEFCONFIG" \
  121. --enable CONFIG_KSU_SUSFS \
  122. --enable CONFIG_KSU_SUSFS_SUS_PATH \
  123. --enable CONFIG_KSU_SUSFS_SUS_MOUNT \
  124. --enable CONFIG_KSU_SUSFS_SUS_KSTAT \
  125. --enable CONFIG_KSU_SUSFS_SPOOF_UNAME \
  126. --enable CONFIG_KSU_SUSFS_ENABLE_LOG \
  127. --enable CONFIG_KSU_SUSFS_HIDE_KSU_SUSFS_SYMBOLS \
  128. --enable CONFIG_KSU_SUSFS_SPOOF_CMDLINE_OR_BOOTCONFIG \
  129. --enable CONFIG_KSU_SUSFS_SUS_MAP \
  130. --enable CONFIG_KSU_SUSFS_OPEN_REDIRECT