Skip to content

Commit 43e6dd4

Browse files
rhatdanruncom
authored andcommitted
BZ#1421714: If caller specifies label overrides, don't override security options
If a caller specifies an SELinux type or MCS Label and still wants to share an IPC Namespace or the host namespace, we should allow them. Currently we are ignoring the label specification if ipcmod=container or pidmode=host. Signed-off-by: Daniel J Walsh <dwalsh@redhat.com> Signed-off-by: Antonio Murdaca <runcom@redhat.com>
1 parent a093394 commit 43e6dd4

2 files changed

Lines changed: 12 additions & 2 deletions

File tree

daemon/create.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,17 @@ func (daemon *Daemon) create(params types.ContainerCreateConfig, managed bool) (
158158
return container, nil
159159
}
160160

161-
func (daemon *Daemon) generateSecurityOpt(ipcMode containertypes.IpcMode, pidMode containertypes.PidMode, privileged bool) ([]string, error) {
161+
func (daemon *Daemon) generateSecurityOpt(hostConfig *containertypes.HostConfig) ([]string, error) {
162+
for _, opt := range hostConfig.SecurityOpt {
163+
con := strings.Split(opt, "=")
164+
if con[0] == "label" {
165+
// Caller overrode SecurityOpts
166+
return nil, nil
167+
}
168+
}
169+
ipcMode := hostConfig.IpcMode
170+
pidMode := hostConfig.PidMode
171+
privileged := hostConfig.Privileged
162172
if ipcMode.IsHost() || pidMode.IsHost() || privileged {
163173
return label.DisableSecOpt(), nil
164174
}

daemon/daemon_unix.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ func (daemon *Daemon) adaptContainerSettings(hostConfig *containertypes.HostConf
258258
hostConfig.ShmSize = container.DefaultSHMSize
259259
}
260260
var err error
261-
opts, err := daemon.generateSecurityOpt(hostConfig.IpcMode, hostConfig.PidMode, hostConfig.Privileged)
261+
opts, err := daemon.generateSecurityOpt(hostConfig)
262262
if err != nil {
263263
return err
264264
}

0 commit comments

Comments
 (0)