Skip to content

Commit dd5ee1f

Browse files
committed
fix: uniqMcs use all cpu
1 parent a8faa24 commit dd5ee1f

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

go-selinux/label/label_linux.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ func InitLabels(options []string) (plabel string, mlabel string, retErr error) {
3030
if !selinux.GetEnabled() {
3131
return "", "", nil
3232
}
33+
if selinux.GetContainerLabelsSize() == int(selinux.DefaultCategoryRange*(selinux.DefaultCategoryRange-1)/2)-1 {
34+
return "", "", fmt.Errorf("cannot allocate selinuxlabel anymore with options %v", options)
35+
}
3336
processLabel, mountLabel := selinux.ContainerLabels()
3437
if processLabel != "" {
3538
defer func() {

go-selinux/selinux_linux.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,12 @@ var (
8585
labels map[string]string
8686
)
8787

88+
func GetContainerLabelsSize() int {
89+
state.Lock()
90+
defer state.Unlock()
91+
return len(state.mcsList)
92+
}
93+
8894
func policyRoot() string {
8995
policyRootOnce.Do(func() {
9096
policyRootVal = filepath.Join(selinuxDir, readConfig(selinuxTypeTag))

0 commit comments

Comments
 (0)