Skip to content

Commit 5cc25d0

Browse files
committed
Add Linux personality support
A lot of people use the Linux `personality` support to allow a 64 bit machine to emulate a 32 bit machine. In particular if you just run 32 bit binaries, many build processes will fail as `uname` will still return a value appropriate for a 64 bit system. Including the personality syscall wil change this to reflect the value from a 32 bit system, such as `i686` rather than `x86_64`. Note that this patch only supports the base 32 bit/64 bit calls. The other options are largely obsolete and rarely used. I left flexibility to add other base domains and to add flags in future, but I am not sure there is any demand for them. The only use case I found in the recent past was the `ADDR_NO_RANDOMIZE` option that disables ASLR, which older versions of Emacs required, but generally they set this themselves, so it is not needed as a Runc option, and it is a serious security reduction. The 32 bit option is different as if you are running 32 bit containers for build, they generally do not know they are "supposed" to run 32 bit, and so this option allows you do do the equivalent of running a `chroot` with `linux32` as is often done on non containerised build systems. Signed-off-by: Justin Cormack <[email protected]>
1 parent 5b71a03 commit 5cc25d0

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

config-linux.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -684,6 +684,23 @@ The following parameters can be specified to set up seccomp:
684684
"mountLabel": "system_u:object_r:svirt_sandbox_file_t:s0:c715,c811"
685685
```
686686

687+
## <a name="configLinuxPersonality" />Personality
688+
689+
**`personality`** (object, OPTIONAL) sets the Linux execution personality. For more information
690+
see the [personality](personality.2) syscall documentation. As most of the options are
691+
obsolete and rarely used, and some reduce security, the currently supported set is a small
692+
subset of the available options.
693+
694+
* **`domain`** *(string, REQUIRED)* - the execution domain.
695+
The valid list of constants is shown below. `LINUX32` will set the `uname` system call to show
696+
a 32 bit CPU type, such as `i686`.
697+
698+
* `LINUX`
699+
* `LINUX32`
700+
701+
* **`flags`** *(array of strings, OPTIONAL)* - the additional flags to apply.
702+
Currently no flag values are supported.
703+
687704

688705
[cgroup-v1]: https://www.kernel.org/doc/Documentation/cgroup-v1/cgroups.txt
689706
[cgroup-v1-blkio]: https://www.kernel.org/doc/Documentation/cgroup-v1/blkio-controller.txt
@@ -711,6 +728,7 @@ The following parameters can be specified to set up seccomp:
711728
[mknod.2]: http://man7.org/linux/man-pages/man2/mknod.2.html
712729
[namespaces.7_2]: http://man7.org/linux/man-pages/man7/namespaces.7.html
713730
[null.4]: http://man7.org/linux/man-pages/man4/null.4.html
731+
[personality.2]: http://man7.org/linux/man-pages/man2/personality.2.html
714732
[pts.4]: http://man7.org/linux/man-pages/man4/pts.4.html
715733
[random.4]: http://man7.org/linux/man-pages/man4/random.4.html
716734
[sysctl.8]: http://man7.org/linux/man-pages/man8/sysctl.8.html

specs-go/config.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,8 @@ type Linux struct {
165165
// IntelRdt contains Intel Resource Director Technology (RDT) information for
166166
// handling resource constraints (e.g., L3 cache, memory bandwidth) for the container
167167
IntelRdt *LinuxIntelRdt `json:"intelRdt,omitempty"`
168+
// Personality contains configuration for the Linux personality syscall
169+
Personality *LinuxPersonality `json:"personality,omitempty"`
168170
}
169171

170172
// LinuxNamespace is the configuration for a Linux namespace
@@ -386,6 +388,28 @@ type LinuxDeviceCgroup struct {
386388
Access string `json:"access,omitempty"`
387389
}
388390

391+
// LinuxPersonalityDomain refers to a personality domain.
392+
type LinuxPersonalityDomain string
393+
394+
// LinuxPersonalityFlag refers to an additional personality flag. None are currently defined.
395+
type LinuxPersonalityFlag string
396+
397+
// Define domain and flags for Personality
398+
const (
399+
// PerLinux is the standard Linux personality
400+
PerLinux LinuxPersonalityDomain = "LINUX"
401+
// PerLinux32 sets personality to 32 bit
402+
PerLinux32 LinuxPersonalityDomain = "LINUX32"
403+
)
404+
405+
// LinuxPersonality represents the Linux personality syscall input
406+
type LinuxPersonality struct {
407+
// Domain for the personality
408+
Domain LinuxPersonalityDomain `json:"domain"`
409+
// Additional flags
410+
Flags []LinuxPersonalityFlag `json:"flags,omitempty"`
411+
}
412+
389413
// Solaris contains platform-specific configuration for Solaris application containers.
390414
type Solaris struct {
391415
// SMF FMRI which should go "online" before we start the container process.

0 commit comments

Comments
 (0)