Skip to content

fix(dkms): run ./configure on the correct kernel headers - #1787

Merged
robertbaldyga merged 4 commits into
Open-CAS:masterfrom
kaysond:master
Aug 24, 2026
Merged

fix(dkms): run ./configure on the correct kernel headers#1787
robertbaldyga merged 4 commits into
Open-CAS:masterfrom
kaysond:master

Conversation

@kaysond

@kaysond kaysond commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Fixes #1772

This was written by Claude Opus, so it's a little aggressive in preventing the issue from occurring, as coding agents tend to be defensive at paranoid levels. I figured I'd leave it all here in case any of it is desirable for the team.

Please feel free to leave feedback then I'll clean up/update the PR manually.

@kaysond kaysond mentioned this pull request Aug 3, 2026
Comment thread configure Outdated
Comment thread modules/Makefile Outdated
Comment thread configure Outdated
Comment thread configure
Comment thread configure
@robertbaldyga

Copy link
Copy Markdown
Member

The overall idea behind those changes is great, but as it goes with LLM generated code, there is a huge imbalance between paranoid defensiveness and corner case blindness :)

@kaysond
kaysond force-pushed the master branch 3 times, most recently from 56022a4 to 9180411 Compare August 11, 2026 16:37
@kaysond

kaysond commented Aug 11, 2026

Copy link
Copy Markdown
Contributor Author

@robertbaldyga - I took a look at everything and updated the build setup and commit history as requested.

  1. adds a single kernel dir arg to ./configure (the same commit updates the rpm build so we dont break the build now that the env var isnt used at all).
  2. fix the kernel config path. you requested a separate commit for this, so that's what I did. I think it should be squashed into the first, though, because not having it is breaking
  3. fix dkms
  4. add the configure/make kernel version consistency check. not having this doesn't strictly break anything, so i think it's fine to add it at the end

Let me know if you have any more feedback, esp. on whether I should squash the first two commits together

@kaysond

kaysond commented Aug 18, 2026

Copy link
Copy Markdown
Contributor Author

bump. @robertbaldyga - any feedback?

Comment thread configure
@robertbaldyga

robertbaldyga commented Aug 19, 2026

Copy link
Copy Markdown
Member

bump. @robertbaldyga - any feedback?

One small comment + please look at the checkpatch output.
The ruff seems to return false positives, so ignore it for now - we will try to fix it soon.

@kaysond
kaysond force-pushed the master branch 2 times, most recently from ea279c7 to a8caf21 Compare August 19, 2026 23:55
'./configure' always probed the running kernel, which is wrong whenever the
modules are built for a different one. Add '--kernel-dir' to point it at an
explicit kernel, and describe it (and the config file argument) in a new
'--help' message.

The kernel is now taken solely from that option, falling back to the
running kernel. Reading KERNEL_DIR from the environment as well would leave
two ways of saying the same thing, so the RPM spec is updated to pass the
directory it exports for 'make' to './configure' too.

The CONFIG_UNWINDER_ORC check reads its .config from the selected kernel
directory as well; it searched /usr/src/ for a directory named after the
running kernel, which would have had './configure' probe one kernel and
inspect another one's configuration.

Signed-off-by: Aram Akhavan <1147328+kaysond@users.noreply.github.com>
The CONFIG_UNWINDER_ORC check reads the kernel's .config, but header
packages of some distributions ship none, so the check was skipped and the
user was left with the "unable to find kernel config" warning on a
perfectly usable kernel directory.

Such packages still carry the resolved configuration in
include/config/auto.conf, so read that when there is no .config.

Signed-off-by: Aram Akhavan <1147328+kaysond@users.noreply.github.com>
DKMS builds the modules for every installed kernel, but PRE_BUILD ran a
bare './configure', which probed the running kernel. On any kernel other
than the running one the generated header described the wrong kernel API,
so the build either failed or produced modules compiled against mismatched
definitions.

Pass the kernel DKMS is building for to './configure', and pass the same
directory to 'make' so both halves of the build agree on it.

Fixes Open-CAS#1772

Signed-off-by: Aram Akhavan <1147328+kaysond@users.noreply.github.com>
… one

Nothing tied generated_defines.h to the kernel it was generated for, so
running './configure' for one kernel and 'make' for another silently
compiled the modules against an API description that does not match the
kernel headers in use, failing with unrelated-looking compiler errors.

Record the probed kernel in config.out and carry it over into
generated_defines.h as CAS_CONFIGURED_KERNEL_DIR. Keeping it in the config
file rather than a stamp of its own means a header generated from a saved
config states the kernel too, and keeping it in the header means 'make'
needs to know nothing about where the config lives.

modules/Makefile now compares it with the kernel it is about to build
against and stops with an explanation if the two differ. Headers generated
before this change carry no such define and are built as before.

Signed-off-by: Aram Akhavan <1147328+kaysond@users.noreply.github.com>
@robertbaldyga
robertbaldyga merged commit 17148c6 into Open-CAS:master Aug 24, 2026
4 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support linux 7.0

2 participants