action.yml 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. name: 'Kernel Fixes'
  2. description: 'Applies compatibility fixes based on android/kernel/sublevel'
  3. inputs:
  4. android_version:
  5. required: true
  6. type: string
  7. kernel_version:
  8. required: true
  9. type: string
  10. sublevel:
  11. required: true
  12. type: string
  13. os_patch_level:
  14. required: true
  15. type: string
  16. runs:
  17. using: composite
  18. steps:
  19. - name: 'Apply Makefile and parse-options.c fixes for GLIBC >= 2.38'
  20. working-directory: ${{ github.workspace }}/kernel/common
  21. shell: bash
  22. run: |
  23. set -euo pipefail
  24. GLIBC_VERSION="$(ldd --version 2>/dev/null | head -n 1 | awk '{print $NF}')"
  25. echo "[INFO] Detected GLIBC version: $GLIBC_VERSION"
  26. if [ "$(printf '%s\n' "2.38" "$GLIBC_VERSION" | sort -V | head -n 1)" = "2.38" ]; then
  27. echo "[INFO] GLIBC >= 2.38, attempting Makefile fix."
  28. # Check if the pattern that needs fixing actually exists
  29. if grep -q '\$(Q)\$(MAKE) -C \$(SUBCMD_SRC) OUTPUT=\$(abspath \$(dir \$@))\/ \$(abspath \$@)' tools/bpf/resolve_btfids/Makefile; then
  30. echo "[INFO] Found pattern to fix, applying sed."
  31. sed -i '/\$(Q)\$(MAKE) -C \$(SUBCMD_SRC) OUTPUT=\$(abspath \$(dir \$@))\/ \$(abspath \$@)/s//$(Q)$(MAKE) -C $(SUBCMD_SRC) EXTRA_CFLAGS="$(CFLAGS)" OUTPUT=$(abspath $(dir $@))\/ $(abspath $@)/' tools/bpf/resolve_btfids/Makefile
  32. MAKEFILE_FIXED="true"
  33. elif grep -q 'EXTRA_CFLAGS' tools/bpf/resolve_btfids/Makefile; then
  34. echo "[INFO] EXTRA_CFLAGS already present, no fix needed."
  35. MAKEFILE_FIXED="already_fixed"
  36. else
  37. echo "[WARN] Neither pattern found in Makefile."
  38. MAKEFILE_FIXED="false"
  39. fi
  40. echo "MAKEFILE_FIXED=$MAKEFILE_FIXED" >> $GITHUB_ENV
  41. if [[ "${{ inputs.android_version }}" == "android13" && "${{ inputs.kernel_version }}" == "5.10" && "${{ inputs.sublevel }}" -le 186 ]] || \
  42. [[ "${{ inputs.android_version }}" == "android13" && "${{ inputs.kernel_version }}" == "5.15" && "${{ inputs.sublevel }}" -le 119 ]] || \
  43. [[ "${{ inputs.android_version }}" == "android14" && "${{ inputs.kernel_version }}" == "5.15" && "${{ inputs.sublevel }}" -le 110 ]]; then
  44. echo "[INFO] Applying parse-options.c fixes."
  45. sed -i '/char \*buf = NULL;/a int i;' tools/lib/subcmd/parse-options.c 2>/dev/null || true
  46. sed -i 's/for (int i = 0; subcommands\[i\]; i++) {/for (i = 0; subcommands[i]; i++) {/' tools/lib/subcmd/parse-options.c 2>/dev/null || true
  47. sed -i '/if (subcommands) {/a int i;' tools/lib/subcmd/parse-options.c 2>/dev/null || true
  48. sed -i 's/for (int i = 0; subcommands\[i\]; i++)/for (i = 0; subcommands[i]; i++)/' tools/lib/subcmd/parse-options.c 2>/dev/null || true
  49. echo "PARSE_OPTIONS_FIXED=true" >> $GITHUB_ENV
  50. else
  51. echo "PARSE_OPTIONS_FIXED=false" >> $GITHUB_ENV
  52. fi
  53. else
  54. echo "[SKIP] GLIBC version < 2.38, skipping Makefile fix."
  55. fi
  56. - name: 'Apply mmap.c fix for specific versions'
  57. shell: bash
  58. if: ${{ inputs.kernel_version == '6.6' && inputs.android_version == 'android15' && inputs.sublevel <= '58' }}
  59. working-directory: ${{ github.workspace }}/kernel/common
  60. run: |
  61. echo "[INFO] Checking for android15 + kernel 6.6 include fix..."
  62. if [[ "${{ inputs.android_version }}" == "android15" && "${{ inputs.kernel_version }}" == "6.6" ]]; then
  63. echo "[MATCH] android15 + 6.6, checking for fs.h include."
  64. cd "$GITHUB_WORKSPACE/kernel/common"
  65. if ! grep -qxF '#include <trace/hooks/fs.h>' ./fs/namespace.c; then
  66. echo "[INFO] Adding missing #include <trace/hooks/fs.h> to fs/namespace.c."
  67. sed -i '/#include <trace\/hooks\/blk.h>/a #include <trace\/hooks\/fs.h>' ./fs/namespace.c
  68. echo "MMAP_NAMESPACE_FIX=true" >> "$GITHUB_ENV"
  69. else
  70. echo "[INFO] #include <trace/hooks/fs.h> already present."
  71. echo "MMAP_NAMESPACE_FIX=already_present" >> "$GITHUB_ENV"
  72. fi
  73. fi
  74. - name: 'Apply mmap.c fix for specific versions'
  75. shell: bash
  76. if: ${{ (inputs.kernel_version == '5.10' && inputs.android_version == 'android12' && inputs.sublevel == 226) || (inputs.kernel_version == '5.10' && inputs.android_version == 'android13' && inputs.sublevel == 223) || (inputs.kernel_version == '5.15' && inputs.android_version == 'android13' && inputs.sublevel == 167) || (inputs.kernel_version == '5.10' && inputs.android_version == 'android13' && inputs.sublevel == 223) || (inputs.kernel_version == '5.15' && inputs.android_version == 'android14' && inputs.sublevel == 167) }}
  77. working-directory: ${{ github.workspace }}/kernel/common
  78. run: |
  79. echo "[INFO] Applying mmap.c fix for specific version combo."
  80. sed -i 's/\s*vm_flags_clear(new_vma, VM_PAD_MASK);/ new_vma->vm_flags \&= ~VM_PAD_MASK;/' mm/mmap.c
  81. echo "MMAP_VM_FLAGS_FIX=true" >> "$GITHUB_ENV"
  82. - name: 'Final Kernel Fixes Summary'
  83. shell: bash
  84. run: |
  85. echo "## Final Kernel Fixes Summary" >> "$GITHUB_STEP_SUMMARY"
  86. echo "" >> "$GITHUB_STEP_SUMMARY"
  87. echo "**Kernel Version:** ${{ inputs.android_version }} + ${{ inputs.kernel_version }} (sublevel ${{ inputs.sublevel }})" >> "$GITHUB_STEP_SUMMARY"
  88. echo "" >> "$GITHUB_STEP_SUMMARY"
  89. echo "### Fix Status" >> "$GITHUB_STEP_SUMMARY"
  90. GLIBC_VERSION="$(ldd --version 2>/dev/null | head -n 1 | awk '{print $NF}')"
  91. if [ "$(printf '%s\n' "2.38" "$GLIBC_VERSION" | sort -V | head -n 1)" = "2.38" ]; then
  92. if [ "${MAKEFILE_FIXED:-false}" = "true" ]; then
  93. echo "- Makefile EXTRA_CFLAGS fix: applied" >> "$GITHUB_STEP_SUMMARY"
  94. elif [ "${MAKEFILE_FIXED:-false}" = "already_fixed" ]; then
  95. echo "- Makefile EXTRA_CFLAGS fix: already present" >> "$GITHUB_STEP_SUMMARY"
  96. else
  97. echo "- Makefile EXTRA_CFLAGS fix: pattern not found" >> "$GITHUB_STEP_SUMMARY"
  98. fi
  99. if [ "${PARSE_OPTIONS_FIXED:-false}" = "true" ]; then
  100. echo "- parse-options.c fix: applied" >> "$GITHUB_STEP_SUMMARY"
  101. else
  102. echo "- parse-options.c fix: not applicable" >> "$GITHUB_STEP_SUMMARY"
  103. fi
  104. else
  105. echo "- Makefile EXTRA_CFLAGS fix: skipped because GLIBC < 2.38" >> "$GITHUB_STEP_SUMMARY"
  106. echo "- parse-options.c fix: skipped because GLIBC < 2.38" >> "$GITHUB_STEP_SUMMARY"
  107. fi
  108. if [ "${MMAP_NAMESPACE_FIX:-not_applicable}" = "true" ]; then
  109. echo "- fs/namespace.c include fix: applied" >> "$GITHUB_STEP_SUMMARY"
  110. elif [ "${MMAP_NAMESPACE_FIX:-not_applicable}" = "already_present" ]; then
  111. echo "- fs/namespace.c include fix: already present" >> "$GITHUB_STEP_SUMMARY"
  112. else
  113. echo "- fs/namespace.c include fix: not applicable" >> "$GITHUB_STEP_SUMMARY"
  114. fi
  115. if [ "${MMAP_VM_FLAGS_FIX:-not_applicable}" = "true" ]; then
  116. echo "- mm/mmap.c VM_PAD_MASK fix: applied" >> "$GITHUB_STEP_SUMMARY"
  117. else
  118. echo "- mm/mmap.c VM_PAD_MASK fix: not applicable" >> "$GITHUB_STEP_SUMMARY"
  119. fi