R0rt1z2 / mtk-bpf-patcher

GNU General Public License v3.0
38 stars 5 forks source link

MediaTek BPF kernel patcher

License GitHub Issues

What is this?

This is a simple Python script that applies a binary patch to the given kernel image. Its purpose is to revert the BPF commit introduced by MTK, which indirectly broke arraymap while attempting to fix ubsan errors. The specified commit, caused connectivity issues on Android 12 based ROMs.

How does it work?

The patch applied by this script is quite simple. It just NOPs the offending code, in order to allow the memcpy() call to be executed.

Supported kernel(s)

Installation

Linux

sudo apt install python3-pip
pip3 install --upgrade git+https://github.com/R0rt1z2/mtk-bpf-patcher

Windows

Requires Windows Terminal or PowerShell.

# (Requires privileges - start Terminal/PowerShell as administrator)
Invoke-WebRequest https://raw.githubusercontent.com/R0rt1z2/mtk-bpf-patcher/master/Install.ps1 -OutFile .\Install.ps1; .\Install.ps1

Usage

usage: mtk-bpf-patcher [-h] [-l LOG_FILE] [-d] input_file output_file

positional arguments:
  input_file            The input file
  output_file           The output file

options:
  -h, --help            show this help message and exit
  -l LOG_FILE, --log_file LOG_FILE
                        The log file
  -d, --debug           Enable debug mode