| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158 |
- name: 'Apply SUSFS Patches'
- description: 'Copy base SUSFS patches and apply version-specific fake patches'
- inputs:
- version:
- description: 'Kernel config version (e.g., android15-6.6)'
- required: true
- sublevel:
- description: 'Kernel sublevel'
- required: true
- os_patch_level:
- description: 'OS patch level (e.g., 2024-07)'
- required: true
- runs:
- using: "composite"
- steps:
- - name: Apply Kernel SUSFS Patches
- shell: bash
- working-directory: ${{ github.workspace }}/kernel/common
- run: |
- # Apply base SUSFS patches
- cp "${{ github.workspace }}/susfs4ksu/kernel_patches/fs/"* "${{ github.workspace }}/kernel/common/fs/"
- cp "${{ github.workspace }}/susfs4ksu/kernel_patches/include/linux/"* "${{ github.workspace }}/kernel/common/include/linux/"
- cp ${{ github.workspace }}/susfs4ksu/kernel_patches/50_add_susfs_in_gki-${{ inputs.version }}.patch ./
- - name: Apply Android 12 5.10 Fake Patches
- shell: bash
- if: inputs.version == 'android12-5.10'
- working-directory: ${{ github.workspace }}/kernel/common
- run: |
- if [ "${{ inputs.sublevel }}" -le "43" ]; then
- echo "Applying base.c Android 12 5.10 Fake Patch"
- perl -i -pe 's/(int|size_t)\s+this_len\s*=\s*min_t\s*\(\s*\1\s*,/size_t this_len = min_t(size_t,/;' fs/proc/base.c
- fi
- if [ "${{ inputs.sublevel }}" -le "117" ]; then
- echo "Applying fdinfo.c Android 12 5.10 Fake Patch"
- sed -i '/^[[:space:]]*\/\*$\|^[[:space:]]*u32 mask = mark->mask & IN_ALL_EVENTS;$/d' fs/notify/fdinfo.c
- perl -i -pe 's/\bmask,\s*mark->ignored_mask/inotify_mark_user_mask(mark)/g' fs/notify/fdinfo.c
- perl -i -pe 's/ignored_mask:%x/ignored_mask:0/g' fs/notify/fdinfo.c
- fi
- - name: Apply Android 13 5.10 Fake Patches
- shell: bash
- if: inputs.version == 'android13-5.10'
- working-directory: ${{ github.workspace }}/kernel/common
- run: |
- echo "Applying Android 13 5.10 SUSFS fixes"
- if [ "${{ inputs.sublevel }}" -le "107" ]; then
- echo "Applying fdinfo.c Android 13 5.10 Fake Patch"
- sed -i '/^[[:space:]]*\/\*$\|^[[:space:]]*u32 mask = mark->mask & IN_ALL_EVENTS;$/d' fs/notify/fdinfo.c
- perl -i -pe 's/\bmask,\s*mark->ignored_mask/inotify_mark_user_mask(mark)/g' fs/notify/fdinfo.c
- perl -i -pe 's/ignored_mask:%x/ignored_mask:0/g' fs/notify/fdinfo.c
- fi
- - name: Apply Android 13 5.15 Fake Patches
- shell: bash
- if: inputs.version == 'android13-5.15'
- working-directory: ${{ github.workspace }}/kernel/common
- run: |
- echo "Applying Android 13 5.15 SUSFS fixes"
- if [ "${{ inputs.sublevel }}" -le "41" ]; then
- echo "Applying namespace.c Android 13 5.15 SUSFS fixes"
- sed -i '/^#include <linux\/shmem_fs.h>$/a #include <linux/mnt_idmapping.h>' fs/namespace.c
- echo "Applying open.c Android 13 5.15 Fake Patch"
- sed -i '/^#include <linux\/compat.h>$/a #include <linux/mnt_idmapping.h>' fs/open.c
- echo "Applying fdinfo.c Android 13 5.15 Fake Patch"
- sed -i '/^[[:space:]]*\/\*$\|^[[:space:]]*u32 mask = mark->mask & IN_ALL_EVENTS;$/d' fs/notify/fdinfo.c
- perl -i -pe 's/\bmask,\s*mark->ignored_mask/inotify_mark_user_mask(mark)/g' fs/notify/fdinfo.c
- perl -i -pe 's/ignored_mask:%x/ignored_mask:0/g' fs/notify/fdinfo.c
- fi
- if [ "${{ inputs.sublevel }}" -ge "197" ]; then
- echo "Applying namespace.c Android 13 5.15 Fake Patch"
- sed -i '/^#include <trace\/hooks\/blk.h>$/d' fs/namespace.c
- fi
- if [ "${{ inputs.sublevel }}" -ge "197" ]; then
- echo "Applying task_mmu.c Android 13 5.15 Fake Patch"
- sed -i '/^#include <trace\/hooks\/mm.h>$/d' fs/proc/task_mmu.c
- fi
- - name: Apply Android 14 6.1 Fake Patches
- shell: bash
- if: inputs.version == 'android14-6.1'
- working-directory: ${{ github.workspace }}/kernel/common
- run: |
- if [ "${{ inputs.sublevel }}" -le "25" ]; then
- echo "Applying base.c Android 14 6.1 Fake Patch"
- sed -i '/^#include <trace\/events\/oom.h>$/a #include <trace/hooks/sched.h>' fs/proc/base.c
- fi
- if [ "${{ inputs.sublevel }}" -le "141" ]; then
- echo "Applying base.c Android 14 6.1 Fake Patch"
- sed -i '/^#include <linux\/cpufreq_times.h>$/a #include <linux/dma-buf.h>' fs/proc/base.c
- fi
- if [ "${{ inputs.sublevel }}" -ge "157" ]; then
- echo "Applying namespace.c Android 14 6.1 Fake Patch"
- sed -i '/^#include <trace\/hooks\/blk.h>$/d' fs/namespace.c
- fi
- - name: Apply Android 15 6.6 Fake Patches
- shell: bash
- if: inputs.version == 'android15-6.6'
- working-directory: ${{ github.workspace }}/kernel/common
- run: |
- echo "Applying 6.6 SUSFS fixes"
- if [ "${{ inputs.sublevel }}" -le "30" ]; then
- echo "Applying taskmmu.c Android 15 6.6 Fake Patch"
- python3 -c 'import re;c=open("fs/proc/task_mmu.c").read();c=re.sub(r"(\t+\t\tif\s*\(\s*vma->vm_end\s*>\s*last_vma_end\s*\))\n(\t+\t\t\tsmap_gather_stats\(vma,\s*&mss,\s*last_vma_end\);)\n(\t+)\}",lambda m:m.group(1)+" {\n"+m.group(2)+"\n"+m.group(3)+"\t\tlast_vma_end = vma->vm_end;\n"+m.group(3)+"\t}\n"+m.group(3)+"}",c,count=1);open("fs/proc/task_mmu.c","w").write(c)'
- fi
- if [ "${{ inputs.sublevel }}" -le "30" ] && [ "${{ inputs.os_patch_level }}" = "2024-07" ]; then
- echo "Adding __fold_filemap_fixup_entry stub for 2024-07 kernels"
- sed -i '/^#include <asm\/elf.h>$/i #ifndef __fold_filemap_fixup_entry\nstatic inline void __fold_filemap_fixup_entry(struct vma_iterator *iter, unsigned long *end) { }\n#endif /* __fold_filemap_fixup_entry */\n' fs/proc/task_mmu.c
- fi
- if [ "${{ inputs.sublevel }}" -le "92" ]; then
- echo "Applying base.c Android 15 6.6 Fake Patch"
- sed -i '/^#include <linux\/cpufreq_times.h>$/a #include <linux/dma-buf.h>' fs/proc/base.c
- fi
- if [ "${{ inputs.sublevel }}" -le "57" ]; then
- echo "Applying base.c Android 15 6.6 Fake Patch"
- sed -i '/^#include <linux\/sched\/sysctl.h>$/a #include <linux/zswap.h>' mm/memory.c
- fi
- - name: Apply Android 16 6.12 Fake Patches
- shell: bash
- if: inputs.version == 'android16-6.12'
- working-directory: ${{ github.workspace }}/kernel/common
- run: |
- echo "Applying 6.12 SUSFS fixes"
- if [ "${{ inputs.sublevel }}" -ge "58" ]; then
- echo "Applying exec.c Android 16 6.12 Fake Patch"
- sed -i '/^#include <linux\/dma-buf.h>$/d' fs/exec.c
- fi
- if [ "${{ inputs.sublevel }}" -ge "69" ]; then
- echo "Applying task_mmu.c Android 16 6.12 Fake Patch"
- sed -i 's/vma_data_pages/vma_pages/g' fs/proc/task_mmu.c
- fi
- - name: Apply Kernel SUSFS Patches
- shell: bash
- working-directory: ${{ github.workspace }}/kernel/common
- run: |
- patch -p1 < 50_add_susfs_in_gki-${{ inputs.version }}.patch
- # SUSFS's OPEN_REDIRECT code unconditionally calls VMA_PAD_START(), which
- # only exists on GKI branches that carry Google's page-size-migration
- # feature (added to each android version's kernel/common branch at a
- # different, sometime later, os_patch_level). Older os_patch_levels in
- # our build matrix predate it, so fall back to a no-padding definition
- # when the real header/macro isn't present. This is version-agnostic and
- # a no-op wherever the real header already provides it.
- 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
- sed -i '1a #ifndef VMA_PAD_START\n#define VMA_PAD_START(vma) ((vma)->vm_end)\n#endif' fs/proc/task_mmu.c
- echo "Added VMA_PAD_START fallback definition to fs/proc/task_mmu.c"
- fi
- # Same story for __fold_filemap_fixup_entry(), declared in page_size_compat.h.
- 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
- sed -i '/#include <linux\/pkeys.h>/a #include <linux/page_size_compat.h>' fs/proc/task_mmu.c
- echo "Added page_size_compat.h include to fs/proc/task_mmu.c"
- fi
|