| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131 |
- name: 'Kernel Fixes'
- description: 'Applies compatibility fixes based on android/kernel/sublevel'
- inputs:
- version:
- required: true
- type: string
- android_version:
- required: true
- type: string
- kernel_version:
- required: true
- type: string
- sublevel:
- required: true
- type: string
- os_patch_level:
- required: true
- type: string
- runs:
- using: composite
- steps:
- - name: 'Apply Makefile and parse-options.c fixes for GLIBC >= 2.38'
- working-directory: ${{ github.workspace }}/kernel/common
- shell: bash
- run: |
- set -euo pipefail
- GLIBC_VERSION="$(ldd --version 2>/dev/null | head -n 1 | awk '{print $NF}')"
- echo "[INFO] Detected GLIBC version: $GLIBC_VERSION"
- if [ "$(printf '%s\n' "2.38" "$GLIBC_VERSION" | sort -V | head -n 1)" = "2.38" ]; then
- echo "[INFO] GLIBC >= 2.38, attempting Makefile fix."
- # Check if the pattern that needs fixing actually exists
- if grep -q '\$(Q)\$(MAKE) -C \$(SUBCMD_SRC) OUTPUT=\$(abspath \$(dir \$@))\/ \$(abspath \$@)' tools/bpf/resolve_btfids/Makefile; then
- echo "[INFO] Found pattern to fix, applying sed."
- 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
- MAKEFILE_FIXED="true"
- elif grep -q 'EXTRA_CFLAGS' tools/bpf/resolve_btfids/Makefile; then
- echo "[INFO] EXTRA_CFLAGS already present, no fix needed."
- MAKEFILE_FIXED="already_fixed"
- else
- echo "[WARN] Neither pattern found in Makefile."
- MAKEFILE_FIXED="false"
- fi
- echo "MAKEFILE_FIXED=$MAKEFILE_FIXED" >> $GITHUB_ENV
- if [[ "${{ inputs.version }}" == "android13-5.10" && "${{ inputs.sublevel }}" -le 186 ]] || \
- [[ "${{ inputs.version }}" == "android13-5.15" && "${{ inputs.sublevel }}" -le 119 ]] || \
- [[ "${{ inputs.version }}" == "android14-5.15" && "${{ inputs.sublevel }}" -le 110 ]]; then
- echo "[INFO] Applying parse-options.c fixes."
- sed -i '/char \*buf = NULL;/a int i;' tools/lib/subcmd/parse-options.c 2>/dev/null || true
- 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
- sed -i '/if (subcommands) {/a int i;' tools/lib/subcmd/parse-options.c 2>/dev/null || true
- 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
- echo "PARSE_OPTIONS_FIXED=true" >> $GITHUB_ENV
- else
- echo "PARSE_OPTIONS_FIXED=false" >> $GITHUB_ENV
- fi
- else
- echo "[SKIP] GLIBC version < 2.38, skipping Makefile fix."
- fi
- - name: 'Apply mmap.c fix for specific versions'
- shell: bash
- if: ${{ inputs.version == 'android15-6.6' && inputs.sublevel <= '58' }}
- working-directory: ${{ github.workspace }}/kernel/common
- run: |
- echo "[INFO] Checking for android15 + kernel 6.6 include fix..."
- if [[ "${{ inputs.android_version }}" == "android15" && "${{ inputs.kernel_version }}" == "6.6" ]]; then
- echo "[MATCH] android15 + 6.6, checking for fs.h include."
- cd "${{ github.workspace }}/kernel/common"
- if ! grep -qxF '#include <trace/hooks/fs.h>' ./fs/namespace.c; then
- echo "[INFO] Adding missing #include <trace/hooks/fs.h> to fs/namespace.c."
- sed -i '/#include <trace\/hooks\/blk.h>/a #include <trace\/hooks\/fs.h>' ./fs/namespace.c
- echo "MMAP_NAMESPACE_FIX=true" >> "$GITHUB_ENV"
- else
- echo "[INFO] #include <trace/hooks/fs.h> already present."
- echo "MMAP_NAMESPACE_FIX=already_present" >> "$GITHUB_ENV"
- fi
- fi
- - name: 'Apply mmap.c fix for specific versions'
- shell: bash
- if: ${{ (inputs.version == 'android12-5.10' && inputs.sublevel == 226) || (inputs.version == 'android13-5.10' && inputs.sublevel == 223) || (inputs.version == 'android13-5.15' && inputs.sublevel == 167) || (inputs.version == 'android14-5.15' && inputs.sublevel == 167) }}
- working-directory: ${{ github.workspace }}/kernel/common
- run: |
- echo "[INFO] Applying mmap.c fix for specific version combo."
- sed -i 's/\s*vm_flags_clear(new_vma, VM_PAD_MASK);/ new_vma->vm_flags \&= ~VM_PAD_MASK;/' mm/mmap.c
- echo "MMAP_VM_FLAGS_FIX=true" >> "$GITHUB_ENV"
- - name: 'Final Kernel Fixes Summary'
- shell: bash
- run: |
- SUMMARY_FILE="/tmp/kernel-fixes-summary.md"
- echo "## Final Kernel Fixes Summary" >> "$SUMMARY_FILE"
- echo "" >> "$SUMMARY_FILE"
- echo "**Kernel Version:** ${{ inputs.android_version }} + ${{ inputs.kernel_version }} (sublevel ${{ inputs.sublevel }})" >> "$SUMMARY_FILE"
- echo "" >> "$SUMMARY_FILE"
- echo "### Fix Status" >> "$SUMMARY_FILE"
- GLIBC_VERSION="$(ldd --version 2>/dev/null | head -n 1 | awk '{print $NF}')"
- if [ "$(printf '%s\n' "2.38" "$GLIBC_VERSION" | sort -V | head -n 1)" = "2.38" ]; then
- if [ "${MAKEFILE_FIXED:-false}" = "true" ]; then
- echo "- Makefile EXTRA_CFLAGS fix: applied" >> "$SUMMARY_FILE"
- elif [ "${MAKEFILE_FIXED:-false}" = "already_fixed" ]; then
- echo "- Makefile EXTRA_CFLAGS fix: already present" >> "$SUMMARY_FILE"
- else
- echo "- Makefile EXTRA_CFLAGS fix: pattern not found" >> "$SUMMARY_FILE"
- fi
- if [ "${PARSE_OPTIONS_FIXED:-false}" = "true" ]; then
- echo "- parse-options.c fix: applied" >> "$SUMMARY_FILE"
- else
- echo "- parse-options.c fix: not applicable" >> "$SUMMARY_FILE"
- fi
- else
- echo "- Makefile EXTRA_CFLAGS fix: skipped because GLIBC < 2.38" >> "$SUMMARY_FILE"
- echo "- parse-options.c fix: skipped because GLIBC < 2.38" >> "$SUMMARY_FILE"
- fi
- if [ "${MMAP_NAMESPACE_FIX:-not_applicable}" = "true" ]; then
- echo "- fs/namespace.c include fix: applied" >> "$SUMMARY_FILE"
- elif [ "${MMAP_NAMESPACE_FIX:-not_applicable}" = "already_present" ]; then
- echo "- fs/namespace.c include fix: already present" >> "$SUMMARY_FILE"
- else
- echo "- fs/namespace.c include fix: not applicable" >> "$SUMMARY_FILE"
- fi
- if [ "${MMAP_VM_FLAGS_FIX:-not_applicable}" = "true" ]; then
- echo "- mm/mmap.c VM_PAD_MASK fix: applied" >> "$SUMMARY_FILE"
- else
- echo "- mm/mmap.c VM_PAD_MASK fix: not applicable" >> "$SUMMARY_FILE"
- fi
|