Skip to content
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

Reserve one Category for the privileged containers to use #143

Merged
merged 1 commit into from
May 10, 2021

Conversation

rhatdan
Copy link
Collaborator

@rhatdan rhatdan commented Mar 30, 2021

Currently each privileged container is reserving a different category
to make sure that other containers can not see their content. This
wastes container categories. This PR will reserve one category for
all privileged containers (s0:c1023,c1024), and free all of the
other categories for confined containers.

Signed-off-by: Daniel J Walsh dwalsh@redhat.com

@rhatdan rhatdan force-pushed the version branch 3 times, most recently from 7e3c75b to 396422d Compare March 30, 2021 20:38
@@ -12,8 +12,9 @@ const (
// Disabled constant to indicate SELinux is disabled
Disabled = -1

MAX_CATEGORY = 1024
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be MaxCategory or maxCategory

Is this intended to be used externally? or only to initialize DefaultCategoryRange ? If the latter, could you un-export the const (maxCategory)?

If this is meant for external use, and must be exported, could you add a GoDoc comment to this (linters may fail on this otherwise)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yikes, quite the brain fart.

Fixed.

@@ -47,7 +47,8 @@ func InitLabels(options []string) (plabel string, mlabel string, retErr error) {
}
for _, opt := range options {
if opt == "disable" {
return "", mountLabel, nil
selinux.ReleaseLabel(mountLabel)
return "", selinux.PrivContainerMountLabel(), nil
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This always returns PrivContaienrMountLabel, irregardless if the container is privileged or not?

Does this need an updated description of InitLabels() (and are consumers of this function required to make changes?); current description is:

// InitLabels returns the process label and file labels to be used within
// the container.  A list of options can be passed into this function to alter
// the labels.  The labels returned will include a random MCS String, that is
// guaranteed to be unique.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the selinux is disabled, then by definition it is Privileged from an SELinux point of view. The goal is to always apply a label to the content, so that confined containers can not write to it. Currently if we return "". The label might be read/writable by other containers.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@thaJeztah Updated the docs.

@thaJeztah
Copy link
Member

@kolyshkin ptal

@rhatdan
Copy link
Collaborator Author

rhatdan commented May 6, 2021

@thaJeztah @kolyshkin Can we get a final review on this, I want to merge so we can prepare a new release of the container tools.

@rhatdan
Copy link
Collaborator Author

rhatdan commented May 6, 2021

@vrothberg @giuseppe PTAL

Comment on lines 37 to 38
t.Log("InitLabels Disabled mlabel Failed", mlabel)
t.FailNow()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can be t.Fatalf("InitLabels Disabled mlabel Failed", mlabel) (same for other cases), but that is not important.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

Comment on lines 35 to 36
t.Log("InitLabels Disabled mlabel Failed")
t.FailNow()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

@@ -11,9 +11,10 @@ const (
Permissive = 0
// Disabled constant to indicate SELinux is disabled
Disabled = -1

// maxCategoriy is the maximum number of categories used within containers
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo: s/maxCategoriy/maxCategory/

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

@@ -276,3 +277,8 @@ func DisableSecOpt() []string {
func GetDefaultContextWithLevel(user, level, scon string) (string, error) {
return getDefaultContextWithLevel(user, level, scon)
}

// PrivContainerMountLabel returns mount labels for privileged containers
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo? s/labels/label/

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

@@ -2,6 +2,8 @@

package selinux

var privContainerMountLabel string
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can be

const privContainerMountLabel = ""

but doesn't matter.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

@rhatdan rhatdan force-pushed the version branch 2 times, most recently from 9fb9a89 to e6cbcaf Compare May 7, 2021 10:29
Currently each privileged container is reserving a different category
to make sure that other containers can not see their content. This
wastes container categories.  This PR will reserve one category for
all privileged containers (s0:c1023,c1024), and free all of the
other categories for confined containers.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
@rhatdan rhatdan changed the title Reserver one Category for the privileged containers to use Reserve one Category for the privileged containers to use May 7, 2021
@rhatdan
Copy link
Collaborator Author

rhatdan commented May 8, 2021

Copy link
Member

@giuseppe giuseppe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@thaJeztah thaJeztah merged commit 2b894f8 into opencontainers:master May 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants