Skip to content

Commit 89f2ac4

Browse files
authored
Expand check for libraries provided by the host (#2077)
* Expand the list of libraries that can be provided by the host nvidia-container-toolkit will provide all of these libraries to a container if the NVIDIA_DRIVER_CAPABILITIES=all environment variable is set. To avoid conflicts with the host let's not generate provides for any of them. The list of libraries was generated by installing nvidia-container-toolkit 1.17.8-1 on an Ubuntu 24.04 system with an NVIDIA GPU and then running the Chainguard bash docker container with `-e NVIDIA_DRIVER_CAPABILITIES=all --gpus all` and checking /usr/lib/ for all libraries with the same version number as the NVIDIA drivers installed on the host.
1 parent 4a077cf commit 89f2ac4

File tree

1 file changed

+47
-5
lines changed

1 file changed

+47
-5
lines changed

pkg/sca/sca.go

Lines changed: 47 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,48 @@ func isInDir(path string, dirs []string) bool {
9999
return false
100100
}
101101

102+
// isHostProvidedLibrary returns true if the library is provided by the host
103+
// system and should not be included in dependency or provides generation.
104+
// These are typically NVIDIA libraries that are installed by the host driver.
105+
func isHostProvidedLibrary(lib string) bool {
106+
hostLibs := []string{
107+
"libEGL_nvidia.so.1",
108+
"libGLESv1_CM_nvidia.so.1",
109+
"libGLESv2_nvidia.so.1",
110+
"libGLX_nvidia.so.1",
111+
"libcuda.so.1",
112+
"libcudadebugger.so.1",
113+
"libnvcuvid.so.1",
114+
"libnvidia-allocator.so.1",
115+
"libnvidia-cfg.so.1",
116+
"libnvidia-eglcore.so.1",
117+
"libnvidia-encode.so.1",
118+
"libnvidia-fbc.so.1",
119+
"libnvidia-glcore.so.1",
120+
"libnvidia-glsi.so.1",
121+
"libnvidia-glvkspirv.so.1",
122+
"libnvidia-gpucomp.so.1",
123+
"libnvidia-ml.so.1",
124+
"libnvidia-ngx.so.1",
125+
"libnvidia-nvvm.so.1",
126+
"libnvidia-opencl.so.1",
127+
"libnvidia-opticalflow.so.1",
128+
"libnvidia-pkcs11-openssl3.so.1",
129+
"libnvidia-pkcs11.so.1",
130+
"libnvidia-ptxjitcompiler.so.1",
131+
"libnvidia-rtcore.so.1",
132+
"libnvidia-tls.so.1",
133+
"libnvoptix.so.1",
134+
}
135+
136+
for _, hostLib := range hostLibs {
137+
if lib == hostLib {
138+
return true
139+
}
140+
}
141+
return false
142+
}
143+
102144
// getLdSoConfDLibPaths will iterate over the files being installed by
103145
// the package and all its subpackages, and for each configuration
104146
// file found under /etc/ld.so.conf.d/ it will parse the file and add
@@ -590,8 +632,8 @@ func generateSharedObjectNameDeps(ctx context.Context, hdl SCAHandle, generated
590632
}
591633

592634
for _, lib := range libs {
593-
// Cuda is a dangling library, which must come from the host
594-
if lib == "libcuda.so.1" {
635+
// These are dangling libraries, which must come from the host
636+
if isHostProvidedLibrary(lib) {
595637
continue
596638
}
597639
if strings.Contains(lib, ".so.") {
@@ -631,9 +673,9 @@ func generateSharedObjectNameDeps(ctx context.Context, hdl SCAHandle, generated
631673
}
632674

633675
for _, soname := range sonames {
634-
// Packages should not provide libcuda.so.1 because they will
635-
// conflict with the driver injected by the host.
636-
if soname == "libcuda.so.1" {
676+
// Packages should not provide these shared objects because they
677+
// will conflict with the driver injected by the host.
678+
if isHostProvidedLibrary(soname) {
637679
continue
638680
}
639681

0 commit comments

Comments
 (0)