| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310 |
- name: Setup SUSFS
- description: Clone and apply SUSFS patches with version-specific fixes
- inputs:
- android_version:
- description: 'Android version (e.g., android15)'
- required: true
- kernel_version:
- description: 'Kernel version (e.g., 6.6)'
- required: true
- os_patch_level:
- description: 'OS patch level (e.g., 2024-07)'
- required: true
- sublevel:
- description: 'Kernel sublevel'
- required: true
- runs:
- using: composite
- steps:
- - name: Setup SUSFS Branch
- shell: bash
- run: |
- SUSFS_BRANCH="gki-${{ inputs.android_version }}-${{ inputs.kernel_version }}"
- SUSFS_REPO="https://gitlab.com/simonpunk/susfs4ksu.git"
- echo "Preparing SUSFS for branch: $SUSFS_BRANCH"
- echo "Cloning latest from $SUSFS_BRANCH..."
- git clone "$SUSFS_REPO" -b "$SUSFS_BRANCH" susfs4ksu
- if [ "${{ inputs.kernel_version }}" = "5.10" ] && [ "${{ inputs.android_version }}" = "android12" ]; then
- SUSFS_COMMIT="e2b0f05ccca5f8fdfc33991c036672235ce48f05"
- fi
- if [ "${{ inputs.kernel_version }}" = "5.10" ] && [ "${{ inputs.android_version }}" = "android13" ]; then
- SUSFS_COMMIT="97234f8e35cdc3b8ea22d05c98ab9829f6421d67"
- fi
- if [ "${{ inputs.kernel_version }}" = "5.15" ] && [ "${{ inputs.android_version }}" = "android13" ]; then
- SUSFS_COMMIT="bf9bf0091bcd4d0072d845ea62484f3011f8d5a8"
- fi
- if [ "${{ inputs.kernel_version }}" = "5.15" ] && [ "${{ inputs.android_version }}" = "android14" ]; then
- SUSFS_COMMIT="667368cf274311a62971671035738b154be1c062"
- fi
- if [ "${{ inputs.kernel_version }}" = "6.1" ]; then
- SUSFS_COMMIT="e1c57040136760a57969fc6b1378cc936a257561"
- fi
- if [ "${{ inputs.kernel_version }}" = "6.6" ]; then
- SUSFS_COMMIT="5009b9edee98fbe66b1a3cb22c603690d81b7817"
- fi
- if [ "${{ inputs.kernel_version }}" = "6.12" ]; then
- SUSFS_COMMIT="5c34dec2c3b69af1d72ac4a89b179741fc602a79"
- fi
- cd $GITHUB_WORKSPACE/susfs4ksu
- git checkout "$SUSFS_COMMIT"
- - name: Enable KernelSU SUSFS Config
- shell: bash
- working-directory: ${{ github.workspace }}/kernel
- run: |
- cat >> "${{ github.workspace }}/wild_gki.fragment" << 'EOF'
- # KernelSU SUSFS Configuration
- CONFIG_KSU_SUSFS=y
- CONFIG_KSU_SUSFS_SUS_PATH=y
- CONFIG_KSU_SUSFS_SUS_MOUNT=y
- CONFIG_KSU_SUSFS_SUS_KSTAT=y
- CONFIG_KSU_SUSFS_SPOOF_UNAME=y
- CONFIG_KSU_SUSFS_ENABLE_LOG=y
- CONFIG_KSU_SUSFS_HIDE_KSU_SUSFS_SYMBOLS=y
- CONFIG_KSU_SUSFS_SPOOF_CMDLINE_OR_BOOTCONFIG=y
- CONFIG_KSU_SUSFS_OPEN_REDIRECT=y
- CONFIG_KSU_SUSFS_SUS_MAP=y
- EOF
- - name: Apply KSU SUSFS Patches
- shell: bash
- working-directory: ${{ github.workspace }}/kernel/KernelSU-Next
- run: |
- cp ${{ github.workspace }}/kernel_patches/wild/ksun-e6ba52b-susfs-v2.1.0-a14-6.1-e1c57040.patch ./
- patch -p1 < ksun-e6ba52b-susfs-v2.1.0-a14-6.1-e1c57040.patch
- - 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.android_version }}-${{ inputs.kernel_version }}.patch ./
- - name: Apply Android 12 5.10 Fake Patches
- shell: bash
- if: inputs.kernel_version == '5.10' && inputs.android_version == 'android12'
- 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.kernel_version == '5.10' && inputs.android_version == 'android13'
- 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.kernel_version == '5.15' && inputs.android_version == 'android13'
- working-directory: ${{ github.workspace }}/kernel/common
- run: |
- echo "Applying Android 13 5.15 SUSFS fixes"
- if [ "${{ inputs.sublevel }}" -le "41" ]; then
- #echo "Applying base.c Android 13 5.15 Fake Patch"
- #sed -i 's/^int this_len = min_t(int, count, PAGE_SIZE);$/size_t this_len = min_t(size_t, count, PAGE_SIZE);/' fs/proc/base.c
- 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
- - name: Apply Android 14 6.1 Fake Patches
- shell: bash
- if: inputs.kernel_version == '6.1' && inputs.android_version == 'android14'
- 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.kernel_version == '6.6' && inputs.android_version == 'android15' && false
- working-directory: ${{ github.workspace }}/kernel/common
- run: |
- echo "Applying 6.6 SUSFS fixes"
- if [ "${{ inputs.sublevel }}" -le "46" ]; then
- echo "Applying namespace.c Android 15 6.6 Fake Patch"
- sed -i '/^#include <trace\/hooks\/blk.h>$/a #include <trace/hooks/fs.h>' fs/namespace.c
- fi
- if [ "${{ inputs.sublevel }}" -le "58" ]; then
- echo "Applying task_mmu.c Android 15 6.6 Fake Patch"
- sed -i '/int ret.*= 0, copied.*= 0;/{
- /int ret.*= 0, copied.*= 0;/!d
- a\
- unsigned int nr_subpages = __PAGE_SIZE / PAGE_SIZE;\
- pagemap_entry_t *res = NULL;
- }' 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
- - name: Apply Android 16 6.12 Fake Patches
- shell: bash
- if: inputs.kernel_version == '6.12' && inputs.android_version == 'android16'
- working-directory: ${{ github.workspace }}/kernel/common
- run: |
- echo "Applying 6.12 SUSFS fixes"
- if [ "${{ inputs.sublevel }}" -le "77" ]; then
- echo "Applying exec.c Android 16 6.12 Fake Patch"
- sed -i '/^#include <linux\/dma-buf.h>$/d' fs/exec.c
- fi
- - name: Apply Kernel SUSFS Patches
- shell: bash
- working-directory: ${{ github.workspace }}/kernel/common
- run: |
- patch -p1 < 50_add_susfs_in_gki-${{ inputs.android_version }}-${{ inputs.kernel_version }}.patch || true
- - name: Revert Android 12 5.10 Fake Patches
- shell: bash
- if: inputs.kernel_version == '5.10' && inputs.android_version == 'android12'
- working-directory: ${{ github.workspace }}/kernel/common
- run: |
- if [ "${{ inputs.sublevel }}" -le "43" ]; then
- echo "Reverting base.c Android 12 5.10 Fake Patch"
- 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
- fi
- if [ "${{ inputs.sublevel }}" -le "117" ]; then
- echo "Reverting fdinfo.c Android 12 5.10 Fake Patch"
- 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
- perl -i -pe 's/\binotify_mark_user_mask\(mark\)/mask, mark->ignored_mask/g' fs/notify/fdinfo.c
- perl -i -pe 's/ignored_mask:0/ignored_mask:%x/g' fs/notify/fdinfo.c
- fi
- - name: Revert Android 13 5.10 Fake Patches
- shell: bash
- if: inputs.kernel_version == '5.10' && inputs.android_version == 'android13'
- working-directory: ${{ github.workspace }}/kernel/common
- run: |
- if [ "${{ inputs.sublevel }}" -le "107" ]; then
- echo "Reverting fdinfo.c Android 13 5.10 Fake Patch"
- 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
- perl -i -pe 's/\binotify_mark_user_mask\(mark\)/mask, mark->ignored_mask/g' fs/notify/fdinfo.c
- perl -i -pe 's/ignored_mask:0/ignored_mask:%x/g' fs/notify/fdinfo.c
- fi
- - name: Revert Android 13 5.15 Fake Patches
- shell: bash
- if: inputs.kernel_version == '5.15' && inputs.android_version == 'android13'
- working-directory: ${{ github.workspace }}/kernel/common
- run: |
- if [ "${{ inputs.sublevel }}" -le "41" ]; then
- #echo "Reverting base.c Android 13 5.15 Fake Patch"
- #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
- echo "Reverting namespace.c Android 13 5.15 Fake Patch"
- sed -i '/#include <linux\/mnt_idmapping.h>$/d' fs/namespace.c
- echo "Reverting open.c Android 13 5.15 Fake Patch"
- sed -i '/#include <linux\/mnt_idmapping.h>$/d' fs/open.c
- echo "Reverting fdinfo.c Android 13 5.15 Fake Patch"
- 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
- perl -i -pe 's/\binotify_mark_user_mask\(mark\)/mask, mark->ignored_mask/g' fs/notify/fdinfo.c
- perl -i -pe 's/ignored_mask:0/ignored_mask:%x/g' fs/notify/fdinfo.c
- 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
- 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
- fi
- - name: Revert Android 14 6.1 Fake Patches
- shell: bash
- if: inputs.kernel_version == '6.1' && inputs.android_version == 'android14'
- working-directory: ${{ github.workspace }}/kernel/common
- run: |
- if [ "${{ inputs.sublevel }}" -le "25" ]; then
- sed -i '/^#include <trace\/hooks\/sched.h>$/d' fs/proc/base.c
- fi
- if [ "${{ inputs.sublevel }}" -le "141" ]; then
- echo "Reverting base.c Android 14 6.1 Fake Patch"
- sed -i '/^#include <linux\/dma-buf.h>$/d' fs/proc/base.c
- fi
- if [ "${{ inputs.sublevel }}" -ge "157" ]; then
- echo "Reverting namespace.c Android 14 6.1 Fake Patch"
- sed -i '/^#include "internal.h"$/a #include <trace/hooks/blk.h>' fs/namespace.c
- fi
- - name: Revert Android 15 6.6 Fake Patches
- shell: bash
- if: inputs.kernel_version == '6.6' && inputs.android_version == 'android15' && false
- working-directory: ${{ github.workspace }}/kernel/common
- run: |
- echo "Reverting 6.6 Fake Patches"
- if [ "${{ inputs.sublevel }}" -le "46" ]; then
- echo "Reverting namespace.c Android 15 6.6 Fake Patch"
- sed -i '/^#include <trace\/hooks\/fs.h>$/d' fs/namespace.c
- fi
- if [ "${{ inputs.sublevel }}" -le "58" ]; then
- echo "Reverting task_mmu.c Android 15 6.6 Fake Patch"
- sed -i '/unsigned int nr_subpages.*__PAGE_SIZE.*PAGE_SIZE/d' fs/proc/task_mmu.c
- sed -i '/pagemap_entry_t.*res.*NULL/d' fs/proc/task_mmu.c
- fi
- if [ "${{ inputs.sublevel }}" -le "92" ]; then
- echo "Reverting base.c Android 15 6.6 Fake Patch"
- sed -i '/^#include <linux\/dma-buf.h>$/d' fs/proc/base.c
- fi
- - name: Revert Android 16 6.12 Fake Patches
- shell: bash
- if: inputs.kernel_version == '6.12' && inputs.android_version == 'android16'
- working-directory: ${{ github.workspace }}/kernel/common
- run: |
- echo "Reverting 6.12 Fake Patches"
- if [ "${{ inputs.sublevel }}" -le "77" ]; then
- echo "Reverting exec.c Android 16 6.12 Fake Patch"
- sed -i '/^#include <linux\/ksh.h>$/a #include <linux/dma-buf.h>' fs/exec.c
- fi
- - name: Apply Kernel SUSFS Patches
- shell: bash
- if: true
- working-directory: ${{ github.workspace }}/kernel/common
- run: |
- SHOW_PAD_FIX=0
- if [[ "${{ inputs.android_version }}" = "android12" && "${{ inputs.kernel_version }}" = "5.10" && "${{ inputs.sublevel }}" -le 209 ]]; then
- SHOW_PAD_FIX=1
- elif [[ "${{ inputs.android_version }}" = "android13" && "${{ inputs.kernel_version }}" = "5.10" && "${{ inputs.sublevel }}" -le 209 && "${{ inputs.os_patch_level }}" != "2024-05" ]]; then
- SHOW_PAD_FIX=1
- elif [[ "${{ inputs.android_version }}" = "android13" && "${{ inputs.kernel_version }}" = "5.15" && "${{ inputs.sublevel }}" -le 148 && "${{ inputs.os_patch_level }}" != "2024-05" ]]; then
- SHOW_PAD_FIX=1
- elif [[ "${{ inputs.android_version }}" = "android14" && "${{ inputs.kernel_version }}" = "5.15" && "${{ inputs.sublevel }}" -le 148 && "${{ inputs.os_patch_level }}" != "2024-05" ]]; then
- SHOW_PAD_FIX=1
- elif [[ "${{ inputs.android_version }}" = "android14" && "${{ inputs.kernel_version }}" = "6.1" && "${{ inputs.sublevel }}" -le 75 && "${{ inputs.os_patch_level }}" != "2024-05" ]]; then
- SHOW_PAD_FIX=1
- fi
- if [[ "$SHOW_PAD_FIX" = "1" ]]; then
- sed -i -e 's/goto show_pad;/return 0;/' ./fs/proc/task_mmu.c
- fi
|