Skip to content

Commit 91df9a7

Browse files
Optimize android safe mode, apply some optimizations, introduce dependabot 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 <[email protected]> * kernel: Add a few bp hot path Signed-off-by: GarfieldHan <[email protected]> * userspace: Apply optimizations Signed-off-by: GarfieldHan <[email protected]> * workflows: Upgrade to ndk r26d Signed-off-by: GarfieldHan <[email protected]> * github: Introduce dependabot Signed-off-by: GarfieldHan <[email protected]> * 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 <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
1 parent 57f87f2 commit 91df9a7

File tree

11 files changed

+113
-87
lines changed

11 files changed

+113
-87
lines changed

.github/dependabot.yml

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: github-actions
4+
target-branch: main
5+
directory: /
6+
schedule:
7+
interval: daily
8+
groups:
9+
action-dependencies:
10+
patterns:
11+
- "*"

.github/workflows/build.yml

+16-16
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
contents: write
1212
steps:
1313
- name: Check out
14-
uses: actions/checkout@v3
14+
uses: actions/checkout@v4
1515
with:
1616
submodules: "recursive"
1717
fetch-depth: 0
@@ -65,15 +65,15 @@ jobs:
6565
mv syscallhook.kpm demo-syscallhook.kpm
6666
6767
- name: Upload elf
68-
uses: actions/upload-artifact@v3
68+
uses: actions/upload-artifact@v4
6969
with:
7070
path: |
7171
kernel/kpimg.elf-linux
7272
kernel/kpimg.elf-android
7373
name: kpimg.elf
7474

7575
- name: Release
76-
uses: ncipollo/release-action@v1.12.0
76+
uses: ncipollo/release-action@v1.14.0
7777
with:
7878
token: ${{ secrets.GITHUB_TOKEN }}
7979
tag: ${{ steps.parse_version.outputs.VERSION }}
@@ -95,7 +95,7 @@ jobs:
9595
contents: write
9696
steps:
9797
- name: Check out
98-
uses: actions/checkout@v3
98+
uses: actions/checkout@v4
9999
- name: Generate version
100100
id: parse_version
101101
run: |
@@ -115,7 +115,7 @@ jobs:
115115
zip -r kpuser.zip user
116116
117117
- name: Release
118-
uses: ncipollo/release-action@v1.12.0
118+
uses: ncipollo/release-action@v1.14.0
119119
with:
120120
token: ${{ secrets.GITHUB_TOKEN }}
121121
tag: ${{ steps.parse_version.outputs.VERSION }}
@@ -131,7 +131,7 @@ jobs:
131131
contents: write
132132
steps:
133133
- name: Check out
134-
uses: actions/checkout@v3
134+
uses: actions/checkout@v4
135135
with:
136136
submodules: "recursive"
137137
fetch-depth: 0
@@ -149,7 +149,7 @@ jobs:
149149
uses: nttld/setup-ndk@v1
150150
id: setup-ndk
151151
with:
152-
ndk-version: r26b
152+
ndk-version: r26d
153153
add-to-path: true
154154

155155
- name: Make hdr
@@ -187,7 +187,7 @@ jobs:
187187
mv kptools kptools-android
188188
189189
- name: Release
190-
uses: ncipollo/release-action@v1.12.0
190+
uses: ncipollo/release-action@v1.14.0
191191
with:
192192
token: ${{ secrets.GITHUB_TOKEN }}
193193
tag: ${{ steps.parse_version.outputs.VERSION }}
@@ -205,7 +205,7 @@ jobs:
205205
contents: write
206206
steps:
207207
- name: Check out
208-
uses: actions/checkout@v3
208+
uses: actions/checkout@v4
209209
- name: Generate version
210210
id: parse_version
211211
run: |
@@ -232,7 +232,7 @@ jobs:
232232
mv kptools kptools-linux
233233
234234
- name: Release
235-
uses: ncipollo/release-action@v1.12.0
235+
uses: ncipollo/release-action@v1.14.0
236236
with:
237237
token: ${{ secrets.GITHUB_TOKEN }}
238238
tag: ${{ steps.parse_version.outputs.VERSION }}
@@ -248,7 +248,7 @@ jobs:
248248
contents: write
249249
steps:
250250
- name: Checkout
251-
uses: actions/checkout@v3
251+
uses: actions/checkout@v4
252252
- name: Generate version
253253
shell: pwsh
254254
run: |
@@ -286,7 +286,7 @@ jobs:
286286
cp .\tools\kptools.exe .\tools\kptools-msys2.exe
287287
7z a kptools-msys2-win .\tools\kptools-msys2.exe D:\a\_temp\msys64\usr\bin\msys-2.0.dll
288288
- name: Release
289-
uses: ncipollo/release-action@v1.12.0
289+
uses: ncipollo/release-action@v1.14.0
290290
with:
291291
token: ${{ secrets.GITHUB_TOKEN }}
292292
tag: ${{ env.VERSION }}
@@ -301,7 +301,7 @@ jobs:
301301
contents: write
302302
steps:
303303
- name: Check out
304-
uses: actions/checkout@v3
304+
uses: actions/checkout@v4
305305
- name: Install mingw32 cross toolchains
306306
run: |
307307
MINGW_LLVM_URL="https://github.com/mstorsjo/llvm-mingw/releases/download/20231128/llvm-mingw-20231128-msvcrt-ubuntu-20.04-x86_64.tar.xz"
@@ -332,7 +332,7 @@ jobs:
332332
done
333333
7za a kptools-llvm-win.zip -tZIP *.exe
334334
- name: Release
335-
uses: ncipollo/release-action@v1.12.0
335+
uses: ncipollo/release-action@v1.14.0
336336
with:
337337
token: ${{ secrets.GITHUB_TOKEN }}
338338
tag: ${{ steps.parse_version.outputs.VERSION }}
@@ -348,7 +348,7 @@ jobs:
348348
contents: write
349349
steps:
350350
- name: Check out
351-
uses: actions/checkout@v3
351+
uses: actions/checkout@v4
352352
- name: Generate version
353353
id: parse_version
354354
run: |
@@ -374,7 +374,7 @@ jobs:
374374
make
375375
mv kptools kptools-mac
376376
- name: Release
377-
uses: ncipollo/release-action@v1.12.0
377+
uses: ncipollo/release-action@v1.14.0
378378
with:
379379
token: ${{ secrets.GITHUB_TOKEN }}
380380
tag: ${{ steps.parse_version.outputs.VERSION }}

.github/workflows/build_dev.yml

+12-12
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
contents: write
2828
steps:
2929
- name: Check out
30-
uses: actions/checkout@v3
30+
uses: actions/checkout@v4
3131
with:
3232
submodules: "recursive"
3333
fetch-depth: 0
@@ -73,15 +73,15 @@ jobs:
7373
mv syscallhook.kpm demo-syscallhook.kpm
7474
7575
- name: Upload elf
76-
uses: actions/upload-artifact@v3
76+
uses: actions/upload-artifact@v4
7777
with:
7878
path: |
7979
kernel/kpimg.elf-linux
8080
kernel/kpimg.elf-android
8181
name: kpimg.elf
8282

8383
- name: Release
84-
uses: ncipollo/release-action@v1.12.0
84+
uses: ncipollo/release-action@v1.14.0
8585
with:
8686
token: ${{ secrets.GITHUB_TOKEN }}
8787
tag: ${{ steps.parse_version.outputs.VERSION }}-dev
@@ -103,7 +103,7 @@ jobs:
103103
contents: write
104104
steps:
105105
- name: Check out
106-
uses: actions/checkout@v3
106+
uses: actions/checkout@v4
107107
- name: Generate version
108108
id: parse_version
109109
run: |
@@ -123,7 +123,7 @@ jobs:
123123
zip -r kpuser.zip user
124124
125125
- name: Release
126-
uses: ncipollo/release-action@v1.12.0
126+
uses: ncipollo/release-action@v1.14.0
127127
with:
128128
token: ${{ secrets.GITHUB_TOKEN }}
129129
tag: ${{ steps.parse_version.outputs.VERSION }}-dev
@@ -140,7 +140,7 @@ jobs:
140140
contents: write
141141
steps:
142142
- name: Check out
143-
uses: actions/checkout@v3
143+
uses: actions/checkout@v4
144144
with:
145145
submodules: "recursive"
146146
fetch-depth: 0
@@ -158,7 +158,7 @@ jobs:
158158
uses: nttld/setup-ndk@v1
159159
id: setup-ndk
160160
with:
161-
ndk-version: r26b
161+
ndk-version: r26d
162162
add-to-path: true
163163

164164
- name: Make hdr
@@ -196,7 +196,7 @@ jobs:
196196
mv kptools kptools-android
197197
198198
- name: Release
199-
uses: ncipollo/release-action@v1.12.0
199+
uses: ncipollo/release-action@v1.14.0
200200
with:
201201
token: ${{ secrets.GITHUB_TOKEN }}
202202
tag: ${{ steps.parse_version.outputs.VERSION }}-dev
@@ -215,7 +215,7 @@ jobs:
215215
contents: write
216216
steps:
217217
- name: Check out
218-
uses: actions/checkout@v3
218+
uses: actions/checkout@v4
219219
- name: Generate version
220220
id: parse_version
221221
run: |
@@ -242,7 +242,7 @@ jobs:
242242
mv kptools kptools-linux
243243
244244
- name: Release
245-
uses: ncipollo/release-action@v1.12.0
245+
uses: ncipollo/release-action@v1.14.0
246246
with:
247247
token: ${{ secrets.GITHUB_TOKEN }}
248248
tag: ${{ steps.parse_version.outputs.VERSION }}-dev
@@ -259,7 +259,7 @@ jobs:
259259
contents: write
260260
steps:
261261
- name: Check out
262-
uses: actions/checkout@v3
262+
uses: actions/checkout@v4
263263
- name: Generate version
264264
id: parse_version
265265
run: |
@@ -285,7 +285,7 @@ jobs:
285285
make
286286
mv kptools kptools-mac
287287
- name: Release
288-
uses: ncipollo/release-action@v1.12.0
288+
uses: ncipollo/release-action@v1.14.0
289289
with:
290290
token: ${{ secrets.GITHUB_TOKEN }}
291291
tag: ${{ steps.parse_version.outputs.VERSION }}-dev

kernel/Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,4 +75,4 @@ hdr:
7575
clean:
7676
rm -rf *.elf
7777
rm -rf kpimg
78-
find . -name *.o | xargs rm -f
78+
find . -name *.o | xargs rm -f

kernel/base/start.c

+2-8
Original file line numberDiff line numberDiff line change
@@ -436,22 +436,16 @@ static void start_init(uint64_t kimage_voff, uint64_t linear_voff)
436436

437437
static int nice_zone()
438438
{
439-
int err = 0;
440-
441-
err = patch();
442-
443-
return err;
439+
return patch();
444440
}
445441

446442
int __attribute__((section(".start.text"))) __noinline start(uint64_t kimage_voff, uint64_t linear_voff)
447443
{
448-
int rc = 0;
449444
start_init(kimage_voff, linear_voff);
450445
prot_myself();
451446
restore_map();
452447
log_regs();
453448
predata_init();
454449
symbol_init();
455-
rc = nice_zone();
456-
return rc;
450+
return nice_zone();
457451
}

kernel/patch/android/sucompat.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -408,9 +408,9 @@ static void handle_before_execve(hook_local_t *hook_local, char **__user u_filen
408408
char __user *ufilename = *u_filename_p;
409409
char filename[SU_PATH_MAX_LEN];
410410
int flen = compat_strncpy_from_user(filename, ufilename, sizeof(filename));
411-
if (flen <= 0) return;
411+
if (unlikely(flen <= 0)) return;
412412

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

487-
} else if (!strcmp(SUPERCMD, filename)) {
487+
} else if (unlikely(!strcmp(SUPERCMD, filename))) {
488488
// key
489489
const char __user *p1 = get_user_arg_ptr(is_compact, *uargv, 1);
490490
if (!p1 || IS_ERR(p1)) return;

0 commit comments

Comments
 (0)