Skip to content

Commit 6b3dcaf

Browse files
committed
kernel: kmod-nvidia-open packaging hardening + review fixes
- Name subpackage / scriptlets / file list by full driver version (kmod-nvidia-open-<nvidia_open_version>) instead of the branch shortcut, and drop the now-unused %nvidia_open_branch macro. - Add Provides: installonlypkg(kernel-module) so dnf treats multiple kmod-nvidia-open builds as install-only alongside their kernels. - Move the modprobe blacklist from %{_sysconfdir}/modprobe.d (admin config) to %{_modprobedir} (vendor config); drop the hand-rolled depmod.d override (redundant with extra/nvidia path). - prep: use pushd/popd instead of 'cd -'. - sources: switch open-gpu-kernel-modules tarball hash to SHA512. - Refresh locks/kernel.lock input fingerprint.
1 parent 7f5022f commit 6b3dcaf

7 files changed

Lines changed: 43 additions & 60 deletions

File tree

base/comps/kernel/kernel.comp.toml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,10 @@ without = [
1616
# RPM release number for the Azure Linux kernel package
1717
azl_pkgrelease = "2"
1818
# 4th version component from the AZL kernel source (6.18.29.1). Included in specrelease so it appears
19-
# in the RPM Release tag, uname -r, and /lib/modules/ path (e.g. 6.18.29-1.2.azl4.aarch64).
19+
# in the RPM Release tag, uname -r, and /lib/modules/ path (e.g. 6.18.29-%%{kextraversion}.%%{azl_pkgrelease}).
2020
kextraversion = "1"
2121
# NVIDIA open GPU kernel module version (built as a subpackage of the kernel)
2222
nvidia_open_version = "595.58.03"
23-
nvidia_open_branch = "595"
2423

2524
# Download the source tarball from the AzureLinux kernel repo
2625
[[components.kernel.source-files]]
@@ -32,8 +31,8 @@ origin = { type = "download", uri = "https://github.com/microsoft/CBL-Mariner-Li
3231
# Download the NVIDIA open GPU kernel module source tarball
3332
[[components.kernel.source-files]]
3433
filename = "open-gpu-kernel-modules-595.58.03.tar.gz"
35-
hash = "e0c4659ddf15e4f4e19cee05b49f88c9ba08ef3add0dfe08249798f58d0fe75e"
36-
hash-type = "SHA256"
34+
hash = "a422b6935209d590f57fa6766f59bb207d9130f8a6777af9245c4ff8cd0f4c4ccef4602a0b26d543e1e8efba24241180992fdb749ea4e5d2aa5218a584b85101"
35+
hash-type = "SHA512"
3736
origin = { type = "download", uri = "https://github.com/NVIDIA/open-gpu-kernel-modules/archive/refs/tags/595.58.03.tar.gz" }
3837

3938
# Insert version and release information from the component defines into the spec file, and update the source URL to match the AzureLinux kernel source structure

base/comps/kernel/kmod-nvidia-open.inc

Lines changed: 19 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -14,30 +14,32 @@
1414
%if "%{_kmod_phase}" == "package" && %{with_up_base}
1515

1616
%ifarch x86_64 aarch64
17-
%package -n kmod-%{_kmod_name}-%{nvidia_open_branch}
17+
%package -n kmod-%{_kmod_name}-%{nvidia_open_version}
1818
Summary: NVIDIA open GPU kernel modules (driver %{nvidia_open_version})
1919
AutoReq: no
2020
# NOTE: Version is inherited from kernel (%{version}), NOT nvidia_open_version.
2121
# Track the actual NVIDIA driver version via Provides for dependency resolution.
2222
Provides: nvidia-open-kmod-version = %{nvidia_open_version}
2323
provides: nvidia-kmod = %{nvidia_open_version}
2424
Provides: kmod-%{_kmod_name} = %{version}-%{release}
25+
# Mark this kmod as install-only so multiple versions can coexist alongside
26+
# their matching kernels (dnf/dnf5 default installonlypkgs includes the
27+
# 'installonlypkg(kernel-module)' token).
28+
Provides: installonlypkg(kernel-module)
2529
Requires: %{name}-core-uname-r = %{KVERREL}
2630
Requires(post): kmod
2731
Requires(postun): kmod
2832
Conflicts: nvidia-closed-kmod
2933

30-
%description -n kmod-%{_kmod_name}-%{nvidia_open_branch}
34+
%description -n kmod-%{_kmod_name}-%{nvidia_open_version}
3135
Open-source NVIDIA GPU kernel modules (driver version %{nvidia_open_version})
3236
built from the official NVIDIA/open-gpu-kernel-modules repository for
3337
kernel %{KVERREL}.
3438

3539
These modules support CUDA workloads on NVIDIA GPUs (Turing and later).
36-
Modules: nvidia.ko, nvidia-modeset.ko, nvidia-drm.ko, nvidia-uvm.ko,
37-
nvidia-peermem.ko.
3840

3941
Each kernel version produces a separate kmod package
40-
(kmod-nvidia-open-<nvidia_branch>-<KVERREL>) so that multiple kernel versions
42+
(kmod-nvidia-open-<nvidia_driver_version>-<KVERREL>) so that multiple kernel versions
4143
can coexist with their own NVIDIA modules.
4244
Use 'Requires: nvidia-open-kmod-version = %{nvidia_open_version}' to depend on a
4345
specific NVIDIA driver version, or 'Requires: kmod-nvidia-open' for any version.
@@ -51,9 +53,9 @@ specific NVIDIA driver version, or 'Requires: kmod-nvidia-open' for any version.
5153
%if "%{_kmod_phase}" == "prep" && %{with_up_base}
5254

5355
%ifarch x86_64 aarch64
54-
cd %{_builddir}
56+
pushd %{_builddir}
5557
tar -xf %{SOURCE6000}
56-
cd -
58+
popd
5759
%endif
5860

5961
%endif
@@ -105,20 +107,13 @@ for mod in nvidia nvidia-modeset nvidia-drm nvidia-uvm nvidia-peermem; do
105107
ko="%{_builddir}/open-gpu-kernel-modules-%{nvidia_open_version}/kernel-open/${mod}.ko"
106108
install -m 0644 "${ko}" %{buildroot}/lib/modules/%{KVERREL}/extra/nvidia/
107109
done
108-
# Install modprobe config to blacklist conflicting modules
109-
install -D -m 0644 %{SOURCE6001} %{buildroot}%{_sysconfdir}/modprobe.d/kmod-%{_kmod_name}-%{nvidia_open_branch}.conf
110-
# Install depmod override config
111-
install -d %{buildroot}%{_sysconfdir}/depmod.d
112-
cat > %{buildroot}%{_sysconfdir}/depmod.d/kmod-%{_kmod_name}-%{nvidia_open_branch}.conf << 'DEPMOD_EOF'
113-
override nvidia %{KVERREL} extra/nvidia
114-
override nvidia-modeset %{KVERREL} extra/nvidia
115-
override nvidia-drm %{KVERREL} extra/nvidia
116-
override nvidia-uvm %{KVERREL} extra/nvidia
117-
override nvidia-peermem %{KVERREL} extra/nvidia
118-
DEPMOD_EOF
110+
# Install modprobe config to blacklist conflicting modules. Lives under
111+
# %{_modprobedir} (/usr/lib/modprobe.d) — vendor-supplied config, not
112+
# admin-editable, so it is owned by the package without %config(noreplace).
113+
install -D -m 0644 %{SOURCE6001} %{buildroot}%{_modprobedir}/kmod-%{_kmod_name}-%{nvidia_open_version}.conf
119114
# Install NVIDIA license file
120115
install -D -m 0644 %{_builddir}/open-gpu-kernel-modules-%{nvidia_open_version}/COPYING \
121-
%{buildroot}%{_datadir}/licenses/kmod-%{_kmod_name}-%{nvidia_open_branch}/COPYING
116+
%{buildroot}%{_datadir}/licenses/kmod-%{_kmod_name}-%{nvidia_open_version}/COPYING
122117
%endif
123118

124119
%endif
@@ -129,21 +124,20 @@ install -D -m 0644 %{_builddir}/open-gpu-kernel-modules-%{nvidia_open_version}/C
129124
%if "%{_kmod_phase}" == "files" && %{with_up_base}
130125

131126
%ifarch x86_64 aarch64
132-
%post -n kmod-%{_kmod_name}-%{nvidia_open_branch}
127+
%post -n kmod-%{_kmod_name}-%{nvidia_open_version}
133128
%{_sbindir}/depmod -a %{KVERREL} || :
134129

135-
%postun -n kmod-%{_kmod_name}-%{nvidia_open_branch}
130+
%postun -n kmod-%{_kmod_name}-%{nvidia_open_version}
136131
%{_sbindir}/depmod -a %{KVERREL} || :
137132

138-
%files -n kmod-%{_kmod_name}-%{nvidia_open_branch}
139-
%license %{_datadir}/licenses/kmod-%{_kmod_name}-%{nvidia_open_branch}/COPYING
133+
%files -n kmod-%{_kmod_name}-%{nvidia_open_version}
134+
%license %{_datadir}/licenses/kmod-%{_kmod_name}-%{nvidia_open_version}/COPYING
140135
/lib/modules/%{KVERREL}/extra/nvidia/nvidia.ko.%{compext}
141136
/lib/modules/%{KVERREL}/extra/nvidia/nvidia-modeset.ko.%{compext}
142137
/lib/modules/%{KVERREL}/extra/nvidia/nvidia-drm.ko.%{compext}
143138
/lib/modules/%{KVERREL}/extra/nvidia/nvidia-uvm.ko.%{compext}
144139
/lib/modules/%{KVERREL}/extra/nvidia/nvidia-peermem.ko.%{compext}
145-
%config(noreplace) %{_sysconfdir}/modprobe.d/kmod-%{_kmod_name}-%{nvidia_open_branch}.conf
146-
%{_sysconfdir}/depmod.d/kmod-%{_kmod_name}-%{nvidia_open_branch}.conf
140+
%{_modprobedir}/kmod-%{_kmod_name}-%{nvidia_open_version}.conf
147141
%endif
148142

149143
%endif

docs/oss-kmod-packaging-strategy.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ consider kmod-nvidia-open as an example:
99
```
1010
kernel.comp.toml
1111
├── build.defines.nvidia_open_version = "595.58.03"
12-
├── build.defines.nvidia_open_branch = "595"
1312
├── source-files[] → kernel tarball, NVIDIA tarball
1413
├── overlays
1514
│ ├── [nvidia-open sources] .inc, modprobe.conf (Source6000-6002)
@@ -64,8 +63,6 @@ This allows a single `.inc` file to contain all phases of a kmod's lifecycle whi
6463

6564
## Naming and Versioning Strategy
6665

67-
Kmod subpackages include a **branch** suffix derived from the driver's major version: `kmod-<name>-<branch>`. For example, NVIDIA driver `595.58.03` with `nvidia_open_branch = "595"` produces `kmod-nvidia-open-595`.
68-
6966
This allows **multiple driver branches to coexist** — e.g., `kmod-nvidia-open-595` and a future `kmod-nvidia-open-600` can be installed side by side for different kernel versions or workloads.
7067

7168
The RPM Version/Release is inherited from the **kernel** (e.g., `kmod-nvidia-open-595-6.18.5-1.8.azl4.x86_64.rpm`). The actual driver version is tracked via virtual Provides:

locks/kernel.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
version = 1
33
import-commit = '5271a1b047ef402ddee40242e02eda23fc273044'
44
upstream-commit = '5271a1b047ef402ddee40242e02eda23fc273044'
5-
input-fingerprint = 'sha256:f292b1b40de5b622186952a120f8824b27b5e1d8c5fcca14a91ed67bf5e073f5'
5+
input-fingerprint = 'sha256:b48d19f3f3b1a5592444d00feddc1000025437330c052a57ae13c4d67d2322a5'
66
resolution-input-hash = 'sha256:466421704711c4fd3c71f0b2ed715a0e61d49e3e26f3a2637fee755795849c8e'

specs/k/kernel/kernel.azl.macros

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,4 @@
44
%_without_selftests 1
55
%azl_pkgrelease 2
66
%kextraversion 1
7-
%nvidia_open_branch 595
87
%nvidia_open_version 595.58.03

specs/k/kernel/kmod-nvidia-open.inc

Lines changed: 19 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -14,30 +14,32 @@
1414
%if "%{_kmod_phase}" == "package" && %{with_up_base}
1515

1616
%ifarch x86_64 aarch64
17-
%package -n kmod-%{_kmod_name}-%{nvidia_open_branch}
17+
%package -n kmod-%{_kmod_name}-%{nvidia_open_version}
1818
Summary: NVIDIA open GPU kernel modules (driver %{nvidia_open_version})
1919
AutoReq: no
2020
# NOTE: Version is inherited from kernel (%{version}), NOT nvidia_open_version.
2121
# Track the actual NVIDIA driver version via Provides for dependency resolution.
2222
Provides: nvidia-open-kmod-version = %{nvidia_open_version}
2323
provides: nvidia-kmod = %{nvidia_open_version}
2424
Provides: kmod-%{_kmod_name} = %{version}-%{release}
25+
# Mark this kmod as install-only so multiple versions can coexist alongside
26+
# their matching kernels (dnf/dnf5 default installonlypkgs includes the
27+
# 'installonlypkg(kernel-module)' token).
28+
Provides: installonlypkg(kernel-module)
2529
Requires: %{name}-core-uname-r = %{KVERREL}
2630
Requires(post): kmod
2731
Requires(postun): kmod
2832
Conflicts: nvidia-closed-kmod
2933

30-
%description -n kmod-%{_kmod_name}-%{nvidia_open_branch}
34+
%description -n kmod-%{_kmod_name}-%{nvidia_open_version}
3135
Open-source NVIDIA GPU kernel modules (driver version %{nvidia_open_version})
3236
built from the official NVIDIA/open-gpu-kernel-modules repository for
3337
kernel %{KVERREL}.
3438

3539
These modules support CUDA workloads on NVIDIA GPUs (Turing and later).
36-
Modules: nvidia.ko, nvidia-modeset.ko, nvidia-drm.ko, nvidia-uvm.ko,
37-
nvidia-peermem.ko.
3840

3941
Each kernel version produces a separate kmod package
40-
(kmod-nvidia-open-<nvidia_branch>-<KVERREL>) so that multiple kernel versions
42+
(kmod-nvidia-open-<nvidia_driver_version>-<KVERREL>) so that multiple kernel versions
4143
can coexist with their own NVIDIA modules.
4244
Use 'Requires: nvidia-open-kmod-version = %{nvidia_open_version}' to depend on a
4345
specific NVIDIA driver version, or 'Requires: kmod-nvidia-open' for any version.
@@ -51,9 +53,9 @@ specific NVIDIA driver version, or 'Requires: kmod-nvidia-open' for any version.
5153
%if "%{_kmod_phase}" == "prep" && %{with_up_base}
5254

5355
%ifarch x86_64 aarch64
54-
cd %{_builddir}
56+
pushd %{_builddir}
5557
tar -xf %{SOURCE6000}
56-
cd -
58+
popd
5759
%endif
5860

5961
%endif
@@ -105,20 +107,13 @@ for mod in nvidia nvidia-modeset nvidia-drm nvidia-uvm nvidia-peermem; do
105107
ko="%{_builddir}/open-gpu-kernel-modules-%{nvidia_open_version}/kernel-open/${mod}.ko"
106108
install -m 0644 "${ko}" %{buildroot}/lib/modules/%{KVERREL}/extra/nvidia/
107109
done
108-
# Install modprobe config to blacklist conflicting modules
109-
install -D -m 0644 %{SOURCE6001} %{buildroot}%{_sysconfdir}/modprobe.d/kmod-%{_kmod_name}-%{nvidia_open_branch}.conf
110-
# Install depmod override config
111-
install -d %{buildroot}%{_sysconfdir}/depmod.d
112-
cat > %{buildroot}%{_sysconfdir}/depmod.d/kmod-%{_kmod_name}-%{nvidia_open_branch}.conf << 'DEPMOD_EOF'
113-
override nvidia %{KVERREL} extra/nvidia
114-
override nvidia-modeset %{KVERREL} extra/nvidia
115-
override nvidia-drm %{KVERREL} extra/nvidia
116-
override nvidia-uvm %{KVERREL} extra/nvidia
117-
override nvidia-peermem %{KVERREL} extra/nvidia
118-
DEPMOD_EOF
110+
# Install modprobe config to blacklist conflicting modules. Lives under
111+
# %{_modprobedir} (/usr/lib/modprobe.d) — vendor-supplied config, not
112+
# admin-editable, so it is owned by the package without %config(noreplace).
113+
install -D -m 0644 %{SOURCE6001} %{buildroot}%{_modprobedir}/kmod-%{_kmod_name}-%{nvidia_open_version}.conf
119114
# Install NVIDIA license file
120115
install -D -m 0644 %{_builddir}/open-gpu-kernel-modules-%{nvidia_open_version}/COPYING \
121-
%{buildroot}%{_datadir}/licenses/kmod-%{_kmod_name}-%{nvidia_open_branch}/COPYING
116+
%{buildroot}%{_datadir}/licenses/kmod-%{_kmod_name}-%{nvidia_open_version}/COPYING
122117
%endif
123118

124119
%endif
@@ -129,21 +124,20 @@ install -D -m 0644 %{_builddir}/open-gpu-kernel-modules-%{nvidia_open_version}/C
129124
%if "%{_kmod_phase}" == "files" && %{with_up_base}
130125

131126
%ifarch x86_64 aarch64
132-
%post -n kmod-%{_kmod_name}-%{nvidia_open_branch}
127+
%post -n kmod-%{_kmod_name}-%{nvidia_open_version}
133128
%{_sbindir}/depmod -a %{KVERREL} || :
134129

135-
%postun -n kmod-%{_kmod_name}-%{nvidia_open_branch}
130+
%postun -n kmod-%{_kmod_name}-%{nvidia_open_version}
136131
%{_sbindir}/depmod -a %{KVERREL} || :
137132

138-
%files -n kmod-%{_kmod_name}-%{nvidia_open_branch}
139-
%license %{_datadir}/licenses/kmod-%{_kmod_name}-%{nvidia_open_branch}/COPYING
133+
%files -n kmod-%{_kmod_name}-%{nvidia_open_version}
134+
%license %{_datadir}/licenses/kmod-%{_kmod_name}-%{nvidia_open_version}/COPYING
140135
/lib/modules/%{KVERREL}/extra/nvidia/nvidia.ko.%{compext}
141136
/lib/modules/%{KVERREL}/extra/nvidia/nvidia-modeset.ko.%{compext}
142137
/lib/modules/%{KVERREL}/extra/nvidia/nvidia-drm.ko.%{compext}
143138
/lib/modules/%{KVERREL}/extra/nvidia/nvidia-uvm.ko.%{compext}
144139
/lib/modules/%{KVERREL}/extra/nvidia/nvidia-peermem.ko.%{compext}
145-
%config(noreplace) %{_sysconfdir}/modprobe.d/kmod-%{_kmod_name}-%{nvidia_open_branch}.conf
146-
%{_sysconfdir}/depmod.d/kmod-%{_kmod_name}-%{nvidia_open_branch}.conf
140+
%{_modprobedir}/kmod-%{_kmod_name}-%{nvidia_open_version}.conf
147141
%endif
148142

149143
%endif

specs/k/kernel/sources

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ SHA512 (linux-6.18.13.tar.xz) = a1d1b27391ed55ae2b17dd25841037d3399e4d87900eb098
22
SHA512 (kernel-abi-stablelists-6.18.13.tar.xz) = 69bbcdd86ae7999b19de306c29bc5cef442e309a8b033900c10a206a97d61b8b4e6d7c6baf6d356daf14e85766bd6a31120b54cfd1eb1c773450e44bae5d2d9b
33
SHA512 (kernel-kabi-dw-6.18.13.tar.xz) = 6473ea636d813e602a59d7332255c4b4597032501a2ed0507985800500451065618a0b6909663e3dc8db2b75c6f4ba10d498dbc41a3b42758cae38f30ca13115
44
SHA512 (kernel-6.18.29.1.tar.gz) = 9c71dec3ea3897107c176c89014134ab31aba0c3a669af549993e1134cf2896c7d6f6b751bbef5dbd260da514a7b8a2b1ad89067b748efc90cf6096e43e5b246
5-
SHA256 (open-gpu-kernel-modules-595.58.03.tar.gz) = e0c4659ddf15e4f4e19cee05b49f88c9ba08ef3add0dfe08249798f58d0fe75e
5+
SHA512 (open-gpu-kernel-modules-595.58.03.tar.gz) = a422b6935209d590f57fa6766f59bb207d9130f8a6777af9245c4ff8cd0f4c4ccef4602a0b26d543e1e8efba24241180992fdb749ea4e5d2aa5218a584b85101

0 commit comments

Comments
 (0)