Skip to content

fix: support Linux 7 DKMS builds#217

Merged
lzwind merged 2 commits into
linuxdeepin:develop/snipefrom
guanzi008:fix-snipe-kernel-7-dkms
Jun 4, 2026
Merged

fix: support Linux 7 DKMS builds#217
lzwind merged 2 commits into
linuxdeepin:develop/snipefrom
guanzi008:fix-snipe-kernel-7-dkms

Conversation

@guanzi008

@guanzi008 guanzi008 commented May 22, 2026

Copy link
Copy Markdown

Summary

This is the develop/snipe-based replacement for #216.

The Linux 7.0 kernel changed the VFS helper prototypes used by vfs_monitor. In particular, vfs_create() now passes the target struct dentry * as the second argument. The old probe code still read the third argument, which is umode_t on 7.0, and then dereferenced it as a dentry. That causes on_vfs_create_ent to hit a kernel Oops shortly after the module is loaded.

This patch adds a Linux 7.0+ probe mapping for the changed VFS signatures and handles vfs_mkdir() returning either an int status or a dentry pointer, depending on the kernel version.

It also keeps the DKMS build compatible with clang-built kernels by selecting the matching clang/lld toolchain from include/generated/compile.h. The compiler feature probe now uses mktemp so parallel DKMS builds do not share a fixed temporary object file.

The timer-based startup delay from #216 is intentionally not included; the LightDM hang was a symptom of the kernel Oops, not a service ordering issue.

Validation

Tested on deepin 25 with 7.0.8-cachyos-x64v3:

  • vfs_monitor.ko builds with clang/lld selected from the kernel headers
  • manual insmod succeeds
  • creating and removing a test directory/file does not trigger a new Oops
  • rmmod vfs_monitor succeeds and logs vfs_monitor: clearup ok

Build checks on the same machine:

  • 6.12.65-amd64-desktop-rolling: build ok
  • 6.18.19-amd64-desktop-rolling: build ok
  • 7.0.8-cachyos-x64v3: build ok
  • sh -n src/kernelmod/dkms-make.sh
  • git diff --check origin/develop/snipe..HEAD

Summary by Sourcery

Add support for Linux 7.x VFS API changes and DKMS builds on clang-built kernels.

New Features:

  • Add kretprobe mappings for Linux 7.x VFS helper prototypes, including handling vfs_mkdir() returning either an int or a dentry pointer.
  • Introduce a DKMS helper script to build the kernel module using the kernel's clang/LLD toolchain when applicable.

Enhancements:

  • Install the DKMS helper script as an executable alongside the kernel module sources.
  • Guard VFS kretprobe handling against error return values to avoid kernel oops on failed operations.

Build:

  • Add a dkms-make.sh script that auto-detects clang/LLD from the kernel's compile.h and configures the module build accordingly.

@deepin-ci-robot

Copy link
Copy Markdown

Hi @guanzi008. Thanks for your PR.

I'm waiting for a linuxdeepin member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@sourcery-ai

sourcery-ai Bot commented May 22, 2026

Copy link
Copy Markdown

Reviewer's Guide

Updates vfs_monitor kretprobes to handle Linux 7.x VFS helper signature changes (including vfs_mkdir returning int-or-pointer) and adds a DKMS helper script plus install wiring that selects the kernel’s clang/LLD toolchain and uses mktemp for safe compiler feature probing.

Sequence diagram for updated vFS vfs_mkdir kretprobe handling (int-or-pointer return)

sequenceDiagram
    participant Kernel
    participant vfs_mkdir
    participant vfs_mkdir_krp
    participant common_vfs_ent
    participant common_vfs_ret_int_or_ptr
    participant vfs_changed_entry
    participant vfs_event_free

    Kernel->>vfs_mkdir: call
    activate vfs_mkdir
    vfs_mkdir-->>vfs_mkdir_krp: entry_handler on_vfs_mkdir_ent
    activate vfs_mkdir_krp
    vfs_mkdir_krp->>common_vfs_ent: common_vfs_ent(event_ptr, dentry)
    common_vfs_ent-->>vfs_mkdir_krp: event stored in ri->data
    deactivate vfs_mkdir_krp

    vfs_mkdir-->>Kernel: return (int or dentry *)
    deactivate vfs_mkdir

    Kernel-->>vfs_mkdir_krp: handler on_vfs_mkdir_ret
    activate vfs_mkdir_krp
    vfs_mkdir_krp->>common_vfs_ret_int_or_ptr: common_vfs_ret_int_or_ptr(event_ptr, regs, ACT_NEW_FOLDER)
    alt [regs_return_value is not error]
        common_vfs_ret_int_or_ptr->>vfs_changed_entry: vfs_changed_entry(event)
        vfs_changed_entry-->>common_vfs_ret_int_or_ptr: ok
    else [regs_return_value is error]
        common_vfs_ret_int_or_ptr->>vfs_event_free: vfs_event_free(event)
        vfs_event_free-->>common_vfs_ret_int_or_ptr: freed
    end
    common_vfs_ret_int_or_ptr-->>vfs_mkdir_krp: return 0
    deactivate vfs_mkdir_krp
Loading

File-Level Changes

Change Details Files
Handle Linux 7.x VFS helper signature changes and mixed int-or-pointer return types in vfs_monitor kretprobes without crashing the kernel.
  • Include <linux/err.h> and add common_vfs_ret_int_or_ptr to process kretprobe return values that may be error-encoded pointers or success values.
  • Introduce DECL_VFS_INT_OR_PTR_RET_KRP macro to share entry/return handlers for VFS functions whose return type can be int or struct dentry * across kernel versions.
  • Add a Linux >= 7.0.0 branch that maps vfs_* and security_inode_create kretprobes to the updated argument positions, including vfs_create dentry as arg 2 and vfs_mkdir dentry as arg 3.
  • Switch pre-5.12 and 5.12–7.0 vfs_mkdir probes to use the new INT_OR_PTR_RET macro so return handling is correct for all supported kernels.
src/kernelmod/vfs_kretprobes.c
Install a DKMS helper build script and teach it to honor the kernel’s clang/LLD configuration, including safe feature detection under parallel builds.
  • Install dkms-make.sh as an executable alongside kernel module sources via CMake so DKMS can call it directly.
  • Add dkms-make.sh script that normalizes kernel_source_dir/build_dir, maps dkms {build,modules,clean} actions to make targets, and falls back to a plain Kbuild invocation when not using clang.
  • Parse include/generated/compile.h to detect clang-built kernels, select a matching clang/ld.lld binary (versioned if available), and fail with a clear error if the required tools are missing.
  • Use mktemp for the temporary object in the clang feature probe so concurrent DKMS builds do not race on a fixed filename, and set LLVM=1/CC/LD appropriately when invoking make.
src/kernelmod/CMakeLists.txt
src/kernelmod/dkms-make.sh
src/kernelmod/deepin-anything-dkms.dkms.in
src/kernelmod/dkms.conf.in

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@guanzi008 guanzi008 force-pushed the fix-snipe-kernel-7-dkms branch from bc84222 to 586b303 Compare May 22, 2026 17:21
@guanzi008 guanzi008 marked this pull request as ready for review May 22, 2026 17:31

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@deepin-bot

deepin-bot Bot commented May 28, 2026

Copy link
Copy Markdown
Contributor

TAG Bot

New tag: 7.0.42
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #219

guanzi008 added 2 commits May 28, 2026 17:49
Linux 7 changed the VFS helper prototypes used by vfs_monitor. The existing kretprobe mapping still reads the vfs_create dentry from the old argument position, so the module can dereference an integer mode value as a dentry and trigger a kernel Oops.

Add a Linux 7 probe mapping for the new signatures and handle vfs_mkdir return values that may be either status codes or dentry pointers across supported kernels.
Some supported kernels are built with clang and LLD. Building their DKMS module with the default compiler can fail when the kernel expects the LLVM toolchain.

Add a DKMS build wrapper that detects the kernel compiler from compile.h, selects a matching clang and ld.lld when needed, and uses a mktemp-based compiler probe so parallel builds do not share a fixed temporary object file.
@guanzi008 guanzi008 force-pushed the fix-snipe-kernel-7-dkms branch from 586b303 to 8a25134 Compare May 28, 2026 09:50
@guanzi008

Copy link
Copy Markdown
Author

@Johnson-zs @wangrong1069 麻烦帮忙看下这个 OBS 失败。

#217 rebase 到 7.0.42 之后,kernelmod 这边的改动和 #219 的 analyzer/searcher 改动没有文件重叠。不过现在 deepin_develop 的 x86_64 和 aarch64 都在同一个地方编译失败:

src/daemon/src/analyzers/LowerCaseNGramAnalyzer.cpp:9:10: fatal error: lucene++/NGramTokenizer.h: No such file or directory

后面也会继续报:

NGramTokenizerPtr does not name a type
NGramTokenizer was not declared in this scope

OBS 里安装的是 liblucene++-dev 3.0.8-deepin4 / liblucene++-contrib0v5 3.0.8-deepin4,这个版本看起来没有提供 lucene++/NGramTokenizer.h。所以这个失败应该不是 #217 的 Linux 7 DKMS 改动导致的,而是 #219 引入 LowerCaseNGramAnalyzer 后依赖了当前构建环境里不存在的 Lucene++ API。

另外 debian/x86_64unresolvablelibselinux-dev / libselinux1-dev 二选一问题,应该是单独的仓库依赖解析问题。

@Johnson-zs

Copy link
Copy Markdown

liblucene++

CI的liblucene++版本未更新,可忽略此编译失败

@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: guanzi008, lzwind, wangrong1069

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@lzwind lzwind merged commit 1f6c124 into linuxdeepin:develop/snipe Jun 4, 2026
19 of 21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants