File tree Expand file tree Collapse file tree 3 files changed +33
-12
lines changed Expand file tree Collapse file tree 3 files changed +33
-12
lines changed Original file line number Diff line number Diff line change @@ -80,6 +80,14 @@ func (l *linuxSetnsInit) Init() error {
8080 if err := setupIOPriority (l .config ); err != nil {
8181 return err
8282 }
83+
84+ // Set personality if specified.
85+ if l .config .Config .Personality != nil {
86+ if err := setupPersonality (l .config .Config ); err != nil {
87+ return err
88+ }
89+ }
90+
8391 // Tell our parent that we're ready to exec. This must be done before the
8492 // Seccomp rules have been applied, because we need to be able to read and
8593 // write to a socket.
@@ -110,11 +118,6 @@ func (l *linuxSetnsInit) Init() error {
110118 if err := apparmor .ApplyProfile (l .config .AppArmorProfile ); err != nil {
111119 return err
112120 }
113- if l .config .Config .Personality != nil {
114- if err := setupPersonality (l .config .Config ); err != nil {
115- return err
116- }
117- }
118121 // Check for the arg early to make sure it exists.
119122 name , err := exec .LookPath (l .config .Args [0 ])
120123 if err != nil {
Original file line number Diff line number Diff line change @@ -164,6 +164,13 @@ func (l *linuxStandardInit) Init() error {
164164 return err
165165 }
166166
167+ // Set personality if specified.
168+ if l .config .Config .Personality != nil {
169+ if err := setupPersonality (l .config .Config ); err != nil {
170+ return err
171+ }
172+ }
173+
167174 // Tell our parent that we're ready to exec. This must be done before the
168175 // Seccomp rules have been applied, because we need to be able to read and
169176 // write to a socket.
@@ -238,13 +245,6 @@ func (l *linuxStandardInit) Init() error {
238245 }
239246 }
240247
241- // Set personality if specified.
242- if l .config .Config .Personality != nil {
243- if err := setupPersonality (l .config .Config ); err != nil {
244- return err
245- }
246- }
247-
248248 // Close the pipe to signal that we have completed our init.
249249 logrus .Debugf ("init: closing the pipe to signal completion" )
250250 _ = l .pipe .Close ()
Original file line number Diff line number Diff line change @@ -62,3 +62,21 @@ function teardown() {
6262 [ " $status " -eq 0 ]
6363 [[ " $output " == * " x86_64" * ]]
6464}
65+
66+ # check that personality can be set when the personality syscall is blocked by seccomp
67+ @test " runc run with personality syscall blocked by seccomp" {
68+ update_config '
69+ .linux.personality = {
70+ "domain": "LINUX",
71+ }
72+ | .linux.seccomp = {
73+ "defaultAction":"SCMP_ACT_ALLOW",
74+ "syscalls":[{"names":["personality"], "action":"SCMP_ACT_ERRNO"}]
75+ }'
76+
77+ runc run -d --console-socket " $CONSOLE_SOCKET " test_busybox
78+ [ " $status " -eq 0 ]
79+ runc exec test_busybox /bin/sh -c " uname -a"
80+ [ " $status " -eq 0 ]
81+ [[ " $output " == * " x86_64" * ]]
82+ }
You can’t perform that action at this time.
0 commit comments