Skip to content

Commit

Permalink
Optimize android safe mode, apply some optimizations, introduce depen…
Browse files Browse the repository at this point in the history
…dabot and upgrade deps (#84)

* userd: Optimize android safe mode

1. Fix input_handle_event hook
2. Split safemode write operation
3. Add more point to trigger writting

Signed-off-by: GarfieldHan <2652609017@qq.com>

* kernel: Add a few bp hot path

Signed-off-by: GarfieldHan <2652609017@qq.com>

* userspace: Apply optimizations

Signed-off-by: GarfieldHan <2652609017@qq.com>

* workflows: Upgrade to ndk r26d

Signed-off-by: GarfieldHan <2652609017@qq.com>

* github: Introduce dependabot

Signed-off-by: GarfieldHan <2652609017@qq.com>

* Bump the action-dependencies group with 3 updates

Bumps the action-dependencies group with 3 updates: [actions/checkout](https://github.com/actions/checkout), [actions/upload-artifact](https://github.com/actions/upload-artifact) and [ncipollo/release-action](https://github.com/ncipollo/release-action).

Updates `actions/checkout` from 3 to 4
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](actions/checkout@v3...v4)

Updates `actions/upload-artifact` from 3 to 4
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](actions/upload-artifact@v3...v4)

Updates `ncipollo/release-action` from 1.12.0 to 1.14.0
- [Release notes](https://github.com/ncipollo/release-action/releases)
- [Commits](ncipollo/release-action@v1.12.0...v1.14.0)

---------

Signed-off-by: GarfieldHan <2652609017@qq.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
  • Loading branch information
pomelohan and dependabot[bot] committed May 1, 2024
1 parent 57f87f2 commit 91df9a7
Show file tree
Hide file tree
Showing 11 changed files with 113 additions and 87 deletions.
11 changes: 11 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version: 2
updates:
- package-ecosystem: github-actions
target-branch: main
directory: /
schedule:
interval: daily
groups:
action-dependencies:
patterns:
- "*"
32 changes: 16 additions & 16 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
contents: write
steps:
- name: Check out
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
submodules: "recursive"
fetch-depth: 0
Expand Down Expand Up @@ -65,15 +65,15 @@ jobs:
mv syscallhook.kpm demo-syscallhook.kpm
- name: Upload elf
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
path: |
kernel/kpimg.elf-linux
kernel/kpimg.elf-android
name: kpimg.elf

- name: Release
uses: ncipollo/release-action@v1.12.0
uses: ncipollo/release-action@v1.14.0
with:
token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ steps.parse_version.outputs.VERSION }}
Expand All @@ -95,7 +95,7 @@ jobs:
contents: write
steps:
- name: Check out
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Generate version
id: parse_version
run: |
Expand All @@ -115,7 +115,7 @@ jobs:
zip -r kpuser.zip user
- name: Release
uses: ncipollo/release-action@v1.12.0
uses: ncipollo/release-action@v1.14.0
with:
token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ steps.parse_version.outputs.VERSION }}
Expand All @@ -131,7 +131,7 @@ jobs:
contents: write
steps:
- name: Check out
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
submodules: "recursive"
fetch-depth: 0
Expand All @@ -149,7 +149,7 @@ jobs:
uses: nttld/setup-ndk@v1
id: setup-ndk
with:
ndk-version: r26b
ndk-version: r26d
add-to-path: true

- name: Make hdr
Expand Down Expand Up @@ -187,7 +187,7 @@ jobs:
mv kptools kptools-android
- name: Release
uses: ncipollo/release-action@v1.12.0
uses: ncipollo/release-action@v1.14.0
with:
token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ steps.parse_version.outputs.VERSION }}
Expand All @@ -205,7 +205,7 @@ jobs:
contents: write
steps:
- name: Check out
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Generate version
id: parse_version
run: |
Expand All @@ -232,7 +232,7 @@ jobs:
mv kptools kptools-linux
- name: Release
uses: ncipollo/release-action@v1.12.0
uses: ncipollo/release-action@v1.14.0
with:
token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ steps.parse_version.outputs.VERSION }}
Expand All @@ -248,7 +248,7 @@ jobs:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Generate version
shell: pwsh
run: |
Expand Down Expand Up @@ -286,7 +286,7 @@ jobs:
cp .\tools\kptools.exe .\tools\kptools-msys2.exe
7z a kptools-msys2-win .\tools\kptools-msys2.exe D:\a\_temp\msys64\usr\bin\msys-2.0.dll
- name: Release
uses: ncipollo/release-action@v1.12.0
uses: ncipollo/release-action@v1.14.0
with:
token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ env.VERSION }}
Expand All @@ -301,7 +301,7 @@ jobs:
contents: write
steps:
- name: Check out
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Install mingw32 cross toolchains
run: |
MINGW_LLVM_URL="https://github.com/mstorsjo/llvm-mingw/releases/download/20231128/llvm-mingw-20231128-msvcrt-ubuntu-20.04-x86_64.tar.xz"
Expand Down Expand Up @@ -332,7 +332,7 @@ jobs:
done
7za a kptools-llvm-win.zip -tZIP *.exe
- name: Release
uses: ncipollo/release-action@v1.12.0
uses: ncipollo/release-action@v1.14.0
with:
token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ steps.parse_version.outputs.VERSION }}
Expand All @@ -348,7 +348,7 @@ jobs:
contents: write
steps:
- name: Check out
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Generate version
id: parse_version
run: |
Expand All @@ -374,7 +374,7 @@ jobs:
make
mv kptools kptools-mac
- name: Release
uses: ncipollo/release-action@v1.12.0
uses: ncipollo/release-action@v1.14.0
with:
token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ steps.parse_version.outputs.VERSION }}
Expand Down
24 changes: 12 additions & 12 deletions .github/workflows/build_dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
contents: write
steps:
- name: Check out
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
submodules: "recursive"
fetch-depth: 0
Expand Down Expand Up @@ -73,15 +73,15 @@ jobs:
mv syscallhook.kpm demo-syscallhook.kpm
- name: Upload elf
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
path: |
kernel/kpimg.elf-linux
kernel/kpimg.elf-android
name: kpimg.elf

- name: Release
uses: ncipollo/release-action@v1.12.0
uses: ncipollo/release-action@v1.14.0
with:
token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ steps.parse_version.outputs.VERSION }}-dev
Expand All @@ -103,7 +103,7 @@ jobs:
contents: write
steps:
- name: Check out
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Generate version
id: parse_version
run: |
Expand All @@ -123,7 +123,7 @@ jobs:
zip -r kpuser.zip user
- name: Release
uses: ncipollo/release-action@v1.12.0
uses: ncipollo/release-action@v1.14.0
with:
token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ steps.parse_version.outputs.VERSION }}-dev
Expand All @@ -140,7 +140,7 @@ jobs:
contents: write
steps:
- name: Check out
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
submodules: "recursive"
fetch-depth: 0
Expand All @@ -158,7 +158,7 @@ jobs:
uses: nttld/setup-ndk@v1
id: setup-ndk
with:
ndk-version: r26b
ndk-version: r26d
add-to-path: true

- name: Make hdr
Expand Down Expand Up @@ -196,7 +196,7 @@ jobs:
mv kptools kptools-android
- name: Release
uses: ncipollo/release-action@v1.12.0
uses: ncipollo/release-action@v1.14.0
with:
token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ steps.parse_version.outputs.VERSION }}-dev
Expand All @@ -215,7 +215,7 @@ jobs:
contents: write
steps:
- name: Check out
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Generate version
id: parse_version
run: |
Expand All @@ -242,7 +242,7 @@ jobs:
mv kptools kptools-linux
- name: Release
uses: ncipollo/release-action@v1.12.0
uses: ncipollo/release-action@v1.14.0
with:
token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ steps.parse_version.outputs.VERSION }}-dev
Expand All @@ -259,7 +259,7 @@ jobs:
contents: write
steps:
- name: Check out
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Generate version
id: parse_version
run: |
Expand All @@ -285,7 +285,7 @@ jobs:
make
mv kptools kptools-mac
- name: Release
uses: ncipollo/release-action@v1.12.0
uses: ncipollo/release-action@v1.14.0
with:
token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ steps.parse_version.outputs.VERSION }}-dev
Expand Down
2 changes: 1 addition & 1 deletion kernel/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,4 @@ hdr:
clean:
rm -rf *.elf
rm -rf kpimg
find . -name *.o | xargs rm -f
find . -name *.o | xargs rm -f
10 changes: 2 additions & 8 deletions kernel/base/start.c
Original file line number Diff line number Diff line change
Expand Up @@ -436,22 +436,16 @@ static void start_init(uint64_t kimage_voff, uint64_t linear_voff)

static int nice_zone()
{
int err = 0;

err = patch();

return err;
return patch();
}

int __attribute__((section(".start.text"))) __noinline start(uint64_t kimage_voff, uint64_t linear_voff)
{
int rc = 0;
start_init(kimage_voff, linear_voff);
prot_myself();
restore_map();
log_regs();
predata_init();
symbol_init();
rc = nice_zone();
return rc;
return nice_zone();
}
6 changes: 3 additions & 3 deletions kernel/patch/android/sucompat.c
Original file line number Diff line number Diff line change
Expand Up @@ -408,9 +408,9 @@ static void handle_before_execve(hook_local_t *hook_local, char **__user u_filen
char __user *ufilename = *u_filename_p;
char filename[SU_PATH_MAX_LEN];
int flen = compat_strncpy_from_user(filename, ufilename, sizeof(filename));
if (flen <= 0) return;
if (unlikely(flen <= 0)) return;

if (!strcmp(current_su_path, filename)) {
if (unlikely(!strcmp(current_su_path, filename))) {
uid_t uid = current_uid();
if (!is_su_allow_uid(uid)) return;
struct su_profile profile = profile_su_allow_uid(uid);
Expand Down Expand Up @@ -484,7 +484,7 @@ static void handle_before_execve(hook_local_t *hook_local, char **__user u_filen
logkfi("call apd uid: %d, to_uid: %d, sctx: %s, cplen: %d, %d\n", uid, to_uid, sctx, cplen, argv_cplen);
}

} else if (!strcmp(SUPERCMD, filename)) {
} else if (unlikely(!strcmp(SUPERCMD, filename))) {
// key
const char __user *p1 = get_user_arg_ptr(is_compact, *uargv, 1);
if (!p1 || IS_ERR(p1)) return;
Expand Down
Loading

0 comments on commit 91df9a7

Please sign in to comment.