mirror of
https://github.com/opencontainers/runc.git
synced 2026-07-11 06:03:57 +08:00
Merge pull request #3287 from cyphar/netlink-embedded-nulls
specconv: do not permit null bytes in mount fields
This commit is contained in:
@@ -2195,6 +2195,9 @@ func (c *linuxContainer) bootstrapData(cloneFlags uintptr, nsMaps map[configs.Na
|
||||
var mounts []byte
|
||||
for _, m := range c.config.Mounts {
|
||||
if m.IsBind() {
|
||||
if strings.IndexByte(m.Source, 0) >= 0 {
|
||||
return nil, fmt.Errorf("mount source string contains null byte: %q", m.Source)
|
||||
}
|
||||
mounts = append(mounts, []byte(m.Source)...)
|
||||
}
|
||||
mounts = append(mounts, byte(0))
|
||||
|
||||
@@ -407,6 +407,18 @@ func createLibcontainerMount(cwd string, m specs.Mount) (*configs.Mount, error)
|
||||
mnt.Source = filepath.Join(cwd, m.Source)
|
||||
}
|
||||
}
|
||||
|
||||
// None of the mount arguments can contain a null byte. Normally such
|
||||
// strings would either cause some other failure or would just be truncated
|
||||
// when we hit the null byte, but because we serialise these strings as
|
||||
// netlink messages (which don't have special null-byte handling) we need
|
||||
// to block this as early as possible.
|
||||
if strings.IndexByte(mnt.Source, 0) >= 0 ||
|
||||
strings.IndexByte(mnt.Destination, 0) >= 0 ||
|
||||
strings.IndexByte(mnt.Device, 0) >= 0 {
|
||||
return nil, errors.New("mount field contains null byte")
|
||||
}
|
||||
|
||||
return mnt, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user