action.yml 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. name: 'Revert SUSFS Fake Patches'
  2. description: 'Revert version-specific fake patches after kernel patch application'
  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: Revert Android 12 5.10 Fake Patches
  17. shell: bash
  18. if: inputs.version == 'android12-5.10'
  19. working-directory: ${{ github.workspace }}/kernel/common
  20. run: |
  21. if [ "${{ inputs.sublevel }}" -le "43" ]; then
  22. echo "Reverting base.c Android 12 5.10 Fake Patch"
  23. 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
  24. fi
  25. if [ "${{ inputs.sublevel }}" -le "117" ]; then
  26. echo "Reverting fdinfo.c Android 12 5.10 Fake Patch"
  27. 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
  28. perl -i -pe 's/\\binotify_mark_user_mask\\(mark\\)/mask, mark->ignored_mask/g' fs/notify/fdinfo.c
  29. perl -i -pe 's/ignored_mask:0/ignored_mask:%x/g' fs/notify/fdinfo.c
  30. fi
  31. - name: Revert Android 13 5.10 Fake Patches
  32. shell: bash
  33. if: inputs.version == 'android13-5.10'
  34. working-directory: ${{ github.workspace }}/kernel/common
  35. run: |
  36. if [ "${{ inputs.sublevel }}" -le "107" ]; then
  37. echo "Reverting fdinfo.c Android 13 5.10 Fake Patch"
  38. 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
  39. perl -i -pe 's/\\binotify_mark_user_mask\\(mark\\)/mask, mark->ignored_mask/g' fs/notify/fdinfo.c
  40. perl -i -pe 's/ignored_mask:0/ignored_mask:%x/g' fs/notify/fdinfo.c
  41. fi
  42. - name: Revert Android 13 5.15 Fake Patches
  43. shell: bash
  44. if: inputs.version == 'android13-5.15'
  45. working-directory: ${{ github.workspace }}/kernel/common
  46. run: |
  47. if [ "${{ inputs.sublevel }}" -le "41" ]; then
  48. echo "Reverting namespace.c Android 13 5.15 Fake Patch"
  49. sed -i '/#include <linux\/mnt_idmapping.h>$/d' fs/namespace.c
  50. echo "Reverting open.c Android 13 5.15 Fake Patch"
  51. sed -i '/#include <linux\/mnt_idmapping.h>$/d' fs/open.c
  52. echo "Reverting fdinfo.c Android 13 5.15 Fake Patch"
  53. 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
  54. perl -i -pe 's/\\binotify_mark_user_mask\\(mark\\)/mask, mark->ignored_mask/g' fs/notify/fdinfo.c
  55. perl -i -pe 's/ignored_mask:0/ignored_mask:%x/g' fs/notify/fdinfo.c
  56. 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
  57. 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
  58. fi
  59. if [ "${{ inputs.sublevel }}" -ge "197" ]; then
  60. echo "Reverting namespace.c Android 13 5.15 Fake Patch"
  61. sed -i '/^#include "internal.h"$/a #include <trace/hooks/blk.h>' fs/namespace.c
  62. fi
  63. if [ "${{ inputs.sublevel }}" -ge "206" ]; then
  64. echo "Reverting task_mmu.c Android 13 5.15 Fake Patch"
  65. sed -i '/^#include <linux\/pkeys.h>$/a #include <trace/hooks/mm.h>' fs/proc/task_mmu.c
  66. fi
  67. - name: Revert Android 14 6.1 Fake Patches
  68. shell: bash
  69. if: inputs.version == 'android14-6.1'
  70. working-directory: ${{ github.workspace }}/kernel/common
  71. run: |
  72. if [ "${{ inputs.sublevel }}" -le "25" ]; then
  73. sed -i '/^#include <trace\/hooks\/sched.h>$/d' fs/proc/base.c
  74. fi
  75. if [ "${{ inputs.sublevel }}" -le "141" ]; then
  76. echo "Reverting base.c Android 14 6.1 Fake Patch"
  77. sed -i '/^#include <linux\/dma-buf.h>$/d' fs/proc/base.c
  78. fi
  79. if [ "${{ inputs.sublevel }}" -ge "157" ]; then
  80. echo "Reverting namespace.c Android 14 6.1 Fake Patch"
  81. sed -i '/^#include "internal.h"$/a #include <trace/hooks/blk.h>' fs/namespace.c
  82. fi
  83. - name: Revert Android 15 6.6 Fake Patches
  84. shell: bash
  85. if: inputs.version == 'android15-6.6'
  86. working-directory: ${{ github.workspace }}/kernel/common
  87. run: |
  88. echo "Reverting 6.6 Fake Patches"
  89. if [ "${{ inputs.sublevel }}" -le "92" ]; then
  90. echo "Reverting base.c Android 15 6.6 Fake Patch"
  91. sed -i '/^#include <linux\/dma-buf.h>$/d' fs/proc/base.c
  92. fi
  93. if [ "${{ inputs.sublevel }}" -le "57" ]; then
  94. echo "Reverting memory.c Android 15 6.6 Fake Patch"
  95. sed -i '/^#include <linux\/zswap.h>$/d' mm/memory.c
  96. fi
  97. - name: Revert Android 16 6.12 Fake Patches
  98. shell: bash
  99. if: inputs.version == 'android16-6.12'
  100. working-directory: ${{ github.workspace }}/kernel/common
  101. run: |
  102. echo "Reverting 6.12 Fake Patches"
  103. if [ "${{ inputs.sublevel }}" -ge "58" ]; then
  104. echo "Reverting exec.c Android 16 6.12 Fake Patch"
  105. sed -i '/^#include /a #include <linux/dma-buf.h>' fs/exec.c
  106. fi
  107. if [ "${{ inputs.sublevel }}" -ge "69" ]; then
  108. echo "Reverting task_mmu.c Android 16 6.12 Fake Patch"
  109. sed -i 's/vma_pages/vma_data_pages/g' fs/proc/task_mmu.c
  110. fi
  111. - name: Apply show_pad Fix
  112. shell: bash
  113. if: true
  114. working-directory: ${{ github.workspace }}/kernel/common
  115. run: |
  116. SHOW_PAD_FIX=0
  117. if [[ "${{ inputs.version }}" = "android12-5.10" && "${{ inputs.sublevel }}" -le 209 ]]; then
  118. SHOW_PAD_FIX=1
  119. elif [[ "${{ inputs.version }}" = "android13-5.10" && "${{ inputs.sublevel }}" -le 209 && "${{ inputs.os_patch_level }}" != "2024-05" ]]; then
  120. SHOW_PAD_FIX=1
  121. elif [[ "${{ inputs.version }}" = "android13-5.15" && "${{ inputs.sublevel }}" -le 148 && "${{ inputs.os_patch_level }}" != "2024-05" ]]; then
  122. SHOW_PAD_FIX=1
  123. elif [[ "${{ inputs.version }}" = "android14-5.15" && "${{ inputs.sublevel }}" -le 148 && "${{ inputs.os_patch_level }}" != "2024-05" ]]; then
  124. SHOW_PAD_FIX=1
  125. elif [[ "${{ inputs.version }}" = "android14-6.1" && "${{ inputs.sublevel }}" -le 75 && "${{ inputs.os_patch_level }}" != "2024-05" ]]; then
  126. SHOW_PAD_FIX=1
  127. fi
  128. if [[ "$SHOW_PAD_FIX" = "1" ]]; then
  129. sed -i -e 's/goto show_pad;/return 0;/' ./fs/proc/task_mmu.c
  130. fi