| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101 |
- name: 'Kernel Fixes'
- description: 'Applies compatibility fixes based on android/kernel/sublevel'
- inputs:
- 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, applying Makefile fix."
- 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 2>/dev/null || true
- if [[ "${{ inputs.android_version }}" == "android13" && "${{ inputs.kernel_version }}" == "5.10" && "${{ inputs.sublevel }}" -le 186 ]] || \
- [[ "${{ inputs.android_version }}" == "android13" && "${{ inputs.kernel_version }}" == "5.15" && "${{ inputs.sublevel }}" -le 119 ]] || \
- [[ "${{ inputs.android_version }}" == "android14" && "${{ inputs.kernel_version }}" == "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
- fi
- else
- echo "[SKIP] GLIBC version < 2.38, skipping Makefile fix."
- fi
- - name: 'Create GitHub Summary for Makefile changes'
- shell: bash
- working-directory: ${{ github.workspace }}/kernel/common
- run: |
- echo "## Makefile and parse-options.c Fixes Applied" >> $GITHUB_STEP_SUMMARY
- echo "" >> $GITHUB_STEP_SUMMARY
- echo "### GLIBC Check" >> $GITHUB_STEP_SUMMARY
- GLIBC_VERSION="$(ldd --version 2>/dev/null | head -n 1 | awk '{print $NF}')"
- echo "- Detected GLIBC Version: **$GLIBC_VERSION**" >> $GITHUB_STEP_SUMMARY
- echo "" >> $GITHUB_STEP_SUMMARY
-
- if [ "$(printf '%s\n' "2.38" "$GLIBC_VERSION" | sort -V | head -n 1)" = "2.38" ]; then
- echo "### Changes Made" >> $GITHUB_STEP_SUMMARY
-
- # Check if Makefile was modified
- if grep -q "EXTRA_CFLAGS" tools/bpf/resolve_btfids/Makefile; then
- echo "✅ **Makefile Modified**: Added EXTRA_CFLAGS to MAKE command" >> $GITHUB_STEP_SUMMARY
- echo '```' >> $GITHUB_STEP_SUMMARY
- grep "EXTRA_CFLAGS" tools/bpf/resolve_btfids/Makefile | head -n 1 >> $GITHUB_STEP_SUMMARY
- echo '```' >> $GITHUB_STEP_SUMMARY
- else
- echo "⚠️ **Makefile Not Modified**: Pattern not found or sed failed" >> $GITHUB_STEP_SUMMARY
- fi
- echo "" >> $GITHUB_STEP_SUMMARY
-
- # Check parse-options.c changes
- if grep -q "^int i;" tools/lib/subcmd/parse-options.c; then
- echo "✅ **parse-options.c Modified**: Added variable declarations and fixed loop syntax" >> $GITHUB_STEP_SUMMARY
- else
- echo "⚠️ **parse-options.c Not Modified**: Conditions not met or sed failed" >> $GITHUB_STEP_SUMMARY
- fi
- else
- echo "### No Changes" >> $GITHUB_STEP_SUMMARY
- echo "- GLIBC < 2.38, skipping all fixes" >> $GITHUB_STEP_SUMMARY
- fi
-
- - name: 'Apply mmap.c fix for specific versions'
- shell: bash
- if: ${{ inputs.kernel_version == '6.6' && inputs.android_version == 'android15' && 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
- else
- echo "[INFO] #include <trace/hooks/fs.h> already present."
- fi
- fi
- - name: 'Apply mmap.c fix for specific versions'
- shell: bash
- 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) }}
- working-directory: ${{ github.workspace }}/kernel/common
- run: |
- sed -i 's/\s*vm_flags_clear(new_vma, VM_PAD_MASK);/ new_vma->vm_flags \&= ~VM_PAD_MASK;/' mm/mmap.c
|