Browse Source

Split susfs action into susfs-setup, susfs-config, susfs-patches, and susfs-revert-patches sub-actions

TheWildJames 1 month ago
parent
commit
7e0dcd0d16

+ 20 - 0
.github/actions/susfs-config/action.yml

@@ -0,0 +1,20 @@
+name: 'Enable SUSFS Kernel Configs'
+description: 'Enable SUSFS-related kernel configuration options'
+
+runs:
+  using: "composite"
+  steps:
+    - name: Enable Kernel Configs
+      uses: ./.github/actions/set-kernel-config
+      with:
+        config_list: |
+          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

+ 156 - 0
.github/actions/susfs-patches/action.yml

@@ -0,0 +1,156 @@
+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"
+          sed -i '/smap_gather_stats(vma, &mss, last_vma_end);/a\last_vma_end = vma->vm_end;' fs/proc/task_mmu.c
+          perl -0777 -i -pe '
+          @l = split /\n/;
+          for ($i = $#l; $i >= 0; $i--) {
+              if ($l[$i] =~ /last_vma_end = vma->vm_end;/) {
+                  $l[$i] = "\t\t\t\t" . $l[$i];
+                  splice(@l, $i + 1, 0, "\t\t\t}");
+
+                  # add { to the if line above
+                  for ($j = $i; $j >= 0; $j--) {
+                      if ($l[$j] =~ /if\s*\(vma->vm_end > last_vma_end\)/) {
+                          $l[$j] =~ s/\)\s*\$/) {/;
+                          last;
+                      }
+                  }
+
+                  last;
+              }
+          }
+          $_ = join "\n", @l
+          ' 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

+ 138 - 0
.github/actions/susfs-revert-patches/action.yml

@@ -0,0 +1,138 @@
+name: 'Revert SUSFS Fake Patches'
+description: 'Revert version-specific fake patches after kernel patch application'
+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: Revert 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 "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.version == 'android13-5.10'
+      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.version == 'android13-5.15'
+      working-directory: ${{ github.workspace }}/kernel/common
+      run: |
+        if [ "${{ inputs.sublevel }}" -le "41" ]; then
+          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
+        if [ "${{ inputs.sublevel }}" -ge "197" ]; then
+          echo "Reverting namespace.c Android 13 5.15 Fake Patch"
+          sed -i '/^#include "internal.h"$/a #include <trace/hooks/blk.h>' fs/namespace.c
+        fi
+        if [ "${{ inputs.sublevel }}" -ge "206" ]; then
+          echo "Reverting task_mmu.c Android 13 5.15 Fake Patch"
+          sed -i '/^#include <linux\\/pkeys.h>$/a #include <trace/hooks/mm.h>' fs/proc/task_mmu.c
+        fi
+
+    - name: Revert 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
+          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.version == 'android15-6.6'
+      working-directory: ${{ github.workspace }}/kernel/common
+      run: |
+        echo "Reverting 6.6 Fake Patches"
+        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
+        if [ "${{ inputs.sublevel }}" -le "57" ]; then
+          echo "Reverting memory.c Android 15 6.6 Fake Patch"
+          sed -i '/^#include <linux\\/zswap.h>$/d' mm/memory.c
+        fi
+
+    - name: Revert Android 16 6.12 Fake Patches
+      shell: bash
+      if: inputs.version == 'android16-6.12'
+      working-directory: ${{ github.workspace }}/kernel/common
+      run: |
+        echo "Reverting 6.12 Fake Patches"
+        if [ "${{ inputs.sublevel }}" -ge "58" ]; then
+          echo "Reverting exec.c Android 16 6.12 Fake Patch"
+          sed -i '/^#include /a #include <linux/dma-buf.h>' fs/exec.c
+        fi
+        if [ "${{ inputs.sublevel }}" -ge "69" ]; then
+          echo "Reverting task_mmu.c Android 16 6.12 Fake Patch"
+          sed -i 's/vma_pages/vma_data_pages/g' fs/proc/task_mmu.c
+        fi
+
+    - name: Apply show_pad Fix
+      shell: bash
+      if: true
+      working-directory: ${{ github.workspace }}/kernel/common
+      run: |
+        SHOW_PAD_FIX=0
+        if [[ "${{ inputs.version }}" = "android12-5.10" && "${{ inputs.sublevel }}" -le 209 ]]; then
+          SHOW_PAD_FIX=1
+        elif [[ "${{ inputs.version }}" = "android13-5.10" && "${{ inputs.sublevel }}" -le 209 && "${{ inputs.os_patch_level }}" != "2024-05" ]]; then
+          SHOW_PAD_FIX=1
+        elif [[ "${{ inputs.version }}" = "android13-5.15" && "${{ inputs.sublevel }}" -le 148 && "${{ inputs.os_patch_level }}" != "2024-05" ]]; then
+          SHOW_PAD_FIX=1
+        elif [[ "${{ inputs.version }}" = "android14-5.15" && "${{ inputs.sublevel }}" -le 148 && "${{ inputs.os_patch_level }}" != "2024-05" ]]; then
+          SHOW_PAD_FIX=1
+        elif [[ "${{ inputs.version }}" = "android14-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

+ 42 - 0
.github/actions/susfs-setup/action.yml

@@ -0,0 +1,42 @@
+name: 'Setup SUSFS Branch'
+description: 'Clone SUSFS repo and cherry-pick commits'
+inputs:
+  susfs_commit:
+    description: 'SUSFS commit hash (empty = latest on auto-derived gki-{version} branch)'
+    required: false
+    default: ""
+  version:
+    description: 'Kernel config version (e.g., android15-6.6)'
+    required: true
+
+runs:
+  using: "composite"
+  steps:
+    - name: Clone SUSFS Branch
+      shell: bash
+      run: |
+        set -euo pipefail
+
+        SUSFS_BRANCH="gki-${{ inputs.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 [ -n "${{ inputs.susfs_commit }}" ]; then
+          echo "Checking out SUSFS commit: ${{ inputs.susfs_commit }}"
+          cd ${{ github.workspace }}/susfs4ksu
+          git checkout "${{ inputs.susfs_commit }}"
+        fi
+
+        cd susfs4ksu
+
+        COMMIT1="8d2420be13e43d4cc0d80215d08ed475081a1404"
+        COMMIT2="ee71ca33d08710d686f2bdba27cacefe9e615fb9"
+
+        git remote add pershoot https://gitlab.com/pershoot/susfs4ksu.git
+        git fetch pershoot gki-android14-6.1-dev
+
+        git cherry-pick "$COMMIT1"
+        git cherry-pick "$COMMIT2"

+ 20 - 309
.github/actions/susfs/action.yml

@@ -1,5 +1,5 @@
-name: Setup SUSFS
-description: Clone and apply SUSFS patches with version-specific fixes
+name: 'Setup SUSFS'
+description: 'Clone and apply SUSFS patches with version-specific fixes'
 inputs:
   susfs_commit:
     description: 'SUSFS commit hash (empty = latest on auto-derived gki-{version} branch)'
@@ -22,316 +22,27 @@ inputs:
     required: true
 
 runs:
-  using: composite
+  using: "composite"
   steps:
     - name: Setup SUSFS Branch
-      shell: bash
-      run: |
-        set -euo pipefail
-
-        SUSFS_BRANCH="gki-${{ inputs.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 [ -n "${{ inputs.susfs_commit }}" ]; then
-          echo "Checking out SUSFS commit: ${{ inputs.susfs_commit }}"
-          cd ${{ github.workspace }}/susfs4ksu
-          git checkout "${{ inputs.susfs_commit }}"
-        fi
-
-        cd susfs4ksu
-        
-        COMMIT1="8d2420be13e43d4cc0d80215d08ed475081a1404"                    # fill in
-        COMMIT2="ee71ca33d08710d686f2bdba27cacefe9e615fb9"                    # fill in
-
-        git remote add pershoot https://gitlab.com/pershoot/susfs4ksu.git
-        git fetch pershoot gki-android14-6.1-dev
-
-        git cherry-pick "$COMMIT1"
-        git cherry-pick "$COMMIT2"
-
-    - name: Enable Kernel Configs
-      uses: ./.github/actions/set-kernel-config
+      uses: ./.github/actions/susfs-setup
       with:
-        config_list: |
-          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
-
-    - 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 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
-        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
+        susfs_commit: ${{ inputs.susfs_commit }}
+        version: ${{ inputs.version }}
 
-    - 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"
-          sed -i '/smap_gather_stats(vma, &mss, last_vma_end);/a\last_vma_end = vma->vm_end;' fs/proc/task_mmu.c
-          perl -0777 -i -pe '
-          @l = split /\n/;
-          for ($i = $#l; $i >= 0; $i--) {
-              if ($l[$i] =~ /last_vma_end = vma->vm_end;/) {
-                  $l[$i] = "\t\t\t\t" . $l[$i];
-                  splice(@l, $i + 1, 0, "\t\t\t}");
+    - name: Enable SUSFS Kernel Configs
+      uses: ./.github/actions/susfs-config
 
-                  # add { to the if line above
-                  for ($j = $i; $j >= 0; $j--) {
-                      if ($l[$j] =~ /if\s*\(vma->vm_end > last_vma_end\)/) {
-                          $l[$j] =~ s/\)\s*$/) {/;
-                          last;
-                      }
-                  }
-
-                  last;
-              }
-          }
-          $_ = join "\n", @l
-          ' 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
-
-    - name: Revert 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 "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.version == 'android13-5.10'
-      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.version == 'android13-5.15'
-      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
-        if [ "${{ inputs.sublevel }}" -ge "197" ]; then
-          echo "Reverting namespace.c Android 13 5.15 Fake Patch"
-          sed -i '/^#include "internal.h"$/a #include <trace/hooks/blk.h>' fs/namespace.c
-        fi
-        if [ "${{ inputs.sublevel }}" -ge "206" ]; then
-          echo "Reverting task_mmu.c Android 13 5.15 Fake Patch"
-          sed -i '/^#include <linux\/pkeys.h>$/a #include <trace/hooks/mm.h>' fs/proc/task_mmu.c
-        fi
-
-    - name: Revert 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
-          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.version == 'android15-6.6'
-      working-directory: ${{ github.workspace }}/kernel/common
-      run: |
-        echo "Reverting 6.6 Fake Patches"
-        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
-        if [ "${{ inputs.sublevel }}" -le "57" ]; then
-          echo "Reverting memory.c Android 15 6.6 Fake Patch"
-          sed -i '/^#include <linux\/zswap.h>$/d' mm/memory.c
-        fi
-
-    - name: Revert Android 16 6.12 Fake Patches
-      shell: bash
-      if: inputs.version == 'android16-6.12'
-      working-directory: ${{ github.workspace }}/kernel/common
-      run: |
-        echo "Reverting 6.12 Fake Patches"
-        if [ "${{ inputs.sublevel }}" -ge "58" ]; then
-          echo "Reverting exec.c Android 16 6.12 Fake Patch"
-          sed -i '/^#include /a #include <linux/dma-buf.h>' fs/exec.c
-        fi
-        if [ "${{ inputs.sublevel }}" -ge "69" ]; then
-          echo "Reverting task_mmu.c Android 16 6.12 Fake Patch"
-          sed -i 's/vma_pages/vma_data_pages/g' fs/proc/task_mmu.c
-        fi
-
-    - name: Apply Kernel SUSFS Patches
-      shell: bash
-      if: true
-      working-directory: ${{ github.workspace }}/kernel/common
-      run: |
-        SHOW_PAD_FIX=0
-        if [[ "${{ inputs.version }}" = "android12-5.10" && "${{ inputs.sublevel }}" -le 209 ]]; then
-          SHOW_PAD_FIX=1
-        elif [[ "${{ inputs.version }}" = "android13-5.10" && "${{ inputs.sublevel }}" -le 209 && "${{ inputs.os_patch_level }}" != "2024-05" ]]; then
-          SHOW_PAD_FIX=1
-        elif [[ "${{ inputs.version }}" = "android13-5.15" && "${{ inputs.sublevel }}" -le 148 && "${{ inputs.os_patch_level }}" != "2024-05" ]]; then
-          SHOW_PAD_FIX=1
-        elif [[ "${{ inputs.version }}" = "android14-5.15" && "${{ inputs.sublevel }}" -le 148 && "${{ inputs.os_patch_level }}" != "2024-05" ]]; then
-          SHOW_PAD_FIX=1
-        elif [[ "${{ inputs.version }}" = "android14-6.1" && "${{ inputs.sublevel }}" -le 75 && "${{ inputs.os_patch_level }}" != "2024-05" ]]; then
-          SHOW_PAD_FIX=1
-        fi
+    - name: Apply SUSFS Patches
+      uses: ./.github/actions/susfs-patches
+      with:
+        version: ${{ inputs.version }}
+        sublevel: ${{ inputs.sublevel }}
+        os_patch_level: ${{ inputs.os_patch_level }}
 
-        if [[ "$SHOW_PAD_FIX" = "1" ]]; then
-          sed -i -e 's/goto show_pad;/return 0;/' ./fs/proc/task_mmu.c
-        fi
+    - name: Revert SUSFS Fake Patches
+      uses: ./.github/actions/susfs-revert-patches
+      with:
+        version: ${{ inputs.version }}
+        sublevel: ${{ inputs.sublevel }}
+        os_patch_level: ${{ inputs.os_patch_level }}