-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
libpod: leave thread locked on errors #12404
libpod: leave thread locked on errors #12404
Conversation
if the SELinux label could not be restored correctly, leave the OS thread locked so that it is terminated once it returns to the threads pool. [NO NEW TESTS NEEDED] the failure is hard to reproduce Signed-off-by: Giuseppe Scrivano <[email protected]>
Sounds very reasonable to me. LGTM. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: flouthoc, giuseppe The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
I am not sure what this buys you, but there is other code in oci-conmon-linux that this should apply to also. |
If we unlock the thread on errors then it keeps running with the wrong label and we don't what other tasks it will be running |
/lgtm |
The second call is just setting back the default label, it does only effects any new sockets that get created. If the "" call fails, then Podman will continue creating sockets with the label of the previous container. |
BTW the chance of "" failing and "...container_t..." succeeded is just about impossible. |
if we fail to set it back to |
Sadly these are not thread settings, but process settings. So we only want to set them right before we exec and then setting it back to default right afterwards. we don't set the label confined label on slirp4netns or on conmon.
The labels are not set for the ociruntime either, the OCI runtimes set the label just for the container. |
if that is the case, then don't we need to fork+exec each time we want to set any of those? How can we prevent other threads for using the wrong label while it is set?
right. But if we fail to reset to the default label, then they will inherit the one we set. |
one good news: I've tested it with this program: package main
import (
"time"
"runtime"
"io/ioutil"
"github.com/opencontainers/selinux/go-selinux/label"
)
func main() {
runtime.LockOSThread()
if err := label.SetFileCreateLabel("system_u:system_r:container_t:s0:c285,c463"); err != nil {
panic(err)
}
if err := ioutil.WriteFile("file", []byte(""), 600); err != nil {
panic(err)
}
go func() {
ioutil.WriteFile("file-2", []byte(""), 600)
}()
time.Sleep(time.Second)
} and I get: $ go build && ./test && ls -1Z file*
system_u:system_r:container_t:s0:c285,c463 file
unconfined_u:object_r:user_tmp_t:s0 file-2 I can confirm it by reading all the |
Great, I thought this was per process but having it per thread is much better. |
if the SELinux label could not be restored correctly, leave the OS
thread locked so that it is terminated once it returns to the threads
pool.
[NO NEW TESTS NEEDED] the failure is hard to reproduce
Signed-off-by: Giuseppe Scrivano [email protected]