mirror of
https://github.com/NVIDIA/nvidia-container-toolkit
synced 2024-11-29 07:21:46 +00:00
Merge branch 'ipc-rw' into 'main'
Mount IPC sockets with noexec flag See merge request nvidia/container-toolkit/container-toolkit!234
This commit is contained in:
commit
59bf7607ce
@ -209,7 +209,17 @@ func (m command) generateSpec() (*specs.Spec, error) {
|
|||||||
return nil, fmt.Errorf("failed to locate driver IPC sockets: %v", err)
|
return nil, fmt.Errorf("failed to locate driver IPC sockets: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
spec.ContainerEdits.Mounts = generateMountsForPaths(libraries, binaries, ipcs)
|
libOptions := []string{
|
||||||
|
"ro",
|
||||||
|
"nosuid",
|
||||||
|
"nodev",
|
||||||
|
"bind",
|
||||||
|
}
|
||||||
|
ipcOptions := append(libOptions, "noexec")
|
||||||
|
spec.ContainerEdits.Mounts = append(
|
||||||
|
generateMountsForPaths(libOptions, libraries, binaries),
|
||||||
|
generateMountsForPaths(ipcOptions, ipcs)...,
|
||||||
|
)
|
||||||
|
|
||||||
ldcacheUpdateHook := m.generateUpdateLdCacheHook(libraries)
|
ldcacheUpdateHook := m.generateUpdateLdCacheHook(libraries)
|
||||||
|
|
||||||
@ -352,7 +362,7 @@ func (m command) findIPC() ([]string, error) {
|
|||||||
return ipcs, nil
|
return ipcs, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func generateMountsForPaths(pathSets ...[]string) []*specs.Mount {
|
func generateMountsForPaths(options []string, pathSets ...[]string) []*specs.Mount {
|
||||||
var mounts []*specs.Mount
|
var mounts []*specs.Mount
|
||||||
for _, paths := range pathSets {
|
for _, paths := range pathSets {
|
||||||
for _, p := range paths {
|
for _, p := range paths {
|
||||||
@ -361,12 +371,7 @@ func generateMountsForPaths(pathSets ...[]string) []*specs.Mount {
|
|||||||
// We may want to adjust the container path
|
// We may want to adjust the container path
|
||||||
ContainerPath: p,
|
ContainerPath: p,
|
||||||
Type: "bind",
|
Type: "bind",
|
||||||
Options: []string{
|
Options: options,
|
||||||
"ro",
|
|
||||||
"nosuid",
|
|
||||||
"nodev",
|
|
||||||
"bind",
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
mounts = append(mounts, &mount)
|
mounts = append(mounts, &mount)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user