From 811e89e4c3c378aa3131b10e7438e05c1a1f6a43 Mon Sep 17 00:00:00 2001 From: ClozyA <133191303+ClozyA@users.noreply.github.com> Date: Mon, 30 Nov 2026 11:28:56 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20KernelSU=20observer=20?= =?UTF-8?q?=E5=AF=BC=E8=87=B4=E7=9A=84=20/data=20=E5=8D=B8=E8=BD=BD?= =?UTF-8?q?=E8=B6=85=E6=97=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 在 fsnotify 注册后释放路径引用,保留包变更监听。该分支在个人 fork 构建未钉值的上机验证产物。 Refs ModAVD/ModAVD#309 --- .github/workflows/build-ksu-lkm.yml | 3 ++ .../observer-release-mount-reference.patch | 53 +++++++++++++++++++ targets.json | 7 +-- 3 files changed, 60 insertions(+), 3 deletions(-) create mode 100644 patches/observer-release-mount-reference.patch diff --git a/.github/workflows/build-ksu-lkm.yml b/.github/workflows/build-ksu-lkm.yml index d39f6a7..87e90e2 100644 --- a/.github/workflows/build-ksu-lkm.yml +++ b/.github/workflows/build-ksu-lkm.yml @@ -1,6 +1,9 @@ name: Build KernelSU LKM on: + push: + branches: + - codex/issue-309-observer-unmount workflow_dispatch: inputs: target: diff --git a/patches/observer-release-mount-reference.patch b/patches/observer-release-mount-reference.patch new file mode 100644 index 0000000..390c0bf --- /dev/null +++ b/patches/observer-release-mount-reference.patch @@ -0,0 +1,53 @@ +diff --git a/kernel/manager/pkg_observer.c b/kernel/manager/pkg_observer.c +--- a/kernel/manager/pkg_observer.c ++++ b/kernel/manager/pkg_observer.c +@@ -16,8 +16,6 @@ + struct watch_dir { + const char *path; + u32 mask; +- struct path kpath; +- struct inode *inode; + struct fsnotify_mark *mark; + }; + +@@ -93,20 +91,18 @@ + + static int watch_one_dir(struct watch_dir *wd) + { +- int ret = kern_path(wd->path, LOOKUP_FOLLOW, &wd->kpath); ++ struct path path; ++ int ret = kern_path(wd->path, LOOKUP_FOLLOW, &path); + if (ret) { + pr_info("path not ready: %s (%d)\n", wd->path, ret); + return ret; + } +- wd->inode = d_inode(wd->kpath.dentry); +- ihold(wd->inode); + +- ret = add_mark_on_inode(wd->inode, wd->mask, &wd->mark); ++ // The fsnotify mark owns the inode reference. Do not pin the mount. ++ ret = add_mark_on_inode(d_inode(path.dentry), wd->mask, &wd->mark); ++ path_put(&path); + if (ret) { + pr_err("Add mark failed for %s (%d)\n", wd->path, ret); +- path_put(&wd->kpath); +- iput(wd->inode); +- wd->inode = NULL; + return ret; + } + pr_info("watching %s\n", wd->path); +@@ -119,14 +115,6 @@ + fsnotify_destroy_mark(wd->mark, g); + fsnotify_put_mark(wd->mark); + wd->mark = NULL; +- } +- if (wd->inode) { +- iput(wd->inode); +- wd->inode = NULL; +- } +- if (wd->kpath.dentry) { +- path_put(&wd->kpath); +- memset(&wd->kpath, 0, sizeof(wd->kpath)); + } + } + diff --git a/targets.json b/targets.json index 2d1c936..8ecacc1 100644 --- a/targets.json +++ b/targets.json @@ -12,15 +12,16 @@ "patches": [ "x86_64-seccomp-skip.patch", "x86_64-do_syscall_64-fallback.patch", - "disable-module-unload.patch" + "disable-module-unload.patch", + "observer-release-mount-reference.patch" ], "kernel_sha256": "b1e5cd842220175a4c07be9a2bcf5beb7b336794b00cf9b7b53abf35557b24df", "kernel_commit": "7e35917775b8b3e3346a87f294e334e258bf15e6", "ksu_version": "v3.3.1", "ksu_commit": "0c0fdb960178fa12d80d6cbcfdcb6ad8be6a865d", "ddk_image": "ghcr.io/ylarod/ddk-min@sha256:1dd6ac340b627a90a4031d6d0df6b129d8cc949b139fb56032c898f023d3d5d3", - "lkm_sha256": "309e048bc2aebcfa493c2b43274f4298c9105438c3be48d23be50b93aa4557c6", - "lkm_size": 259976, + "lkm_sha256": null, + "lkm_size": null, "ksu_commit_count": 2680 } ] From 078d7074cb7fd520b74d4c0e738526f21b5ecbac Mon Sep 17 00:00:00 2001 From: ClozyA <133191303+ClozyA@users.noreply.github.com> Date: Mon, 30 Nov 2026 11:34:22 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E9=94=81=E5=AE=9A=20#309=20=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E6=A8=A1=E5=9D=97=E7=9A=84=E6=9E=84=E5=BB=BA=E5=93=88?= =?UTF-8?q?=E5=B8=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- targets.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/targets.json b/targets.json index 8ecacc1..3b33812 100644 --- a/targets.json +++ b/targets.json @@ -20,8 +20,8 @@ "ksu_version": "v3.3.1", "ksu_commit": "0c0fdb960178fa12d80d6cbcfdcb6ad8be6a865d", "ddk_image": "ghcr.io/ylarod/ddk-min@sha256:1dd6ac340b627a90a4031d6d0df6b129d8cc949b139fb56032c898f023d3d5d3", - "lkm_sha256": null, - "lkm_size": null, + "lkm_sha256": "c7d4b83f60cb7b0b873ab3b56624de45777620af9a1c66fe64fdbb18be7090f4", + "lkm_size": 259360, "ksu_commit_count": 2680 } ] From bc7d401540abebbb9dc5fbd787a8225edbcd0460 Mon Sep 17 00:00:00 2001 From: ClozyA <133191303+ClozyA@users.noreply.github.com> Date: Mon, 30 Nov 2026 11:39:12 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E6=92=A4=E5=9B=9E=20fork=20=E5=80=99?= =?UTF-8?q?=E9=80=89=E6=9E=84=E5=BB=BA=E7=9A=84=E4=B8=B4=E6=97=B6=E8=A7=A6?= =?UTF-8?q?=E5=8F=91=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/build-ksu-lkm.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/build-ksu-lkm.yml b/.github/workflows/build-ksu-lkm.yml index 87e90e2..d39f6a7 100644 --- a/.github/workflows/build-ksu-lkm.yml +++ b/.github/workflows/build-ksu-lkm.yml @@ -1,9 +1,6 @@ name: Build KernelSU LKM on: - push: - branches: - - codex/issue-309-observer-unmount workflow_dispatch: inputs: target: