Skip to content

fix: uniqMcs use all cpu#246

Open
ningmingxiao wants to merge 1 commit intoopencontainers:mainfrom
ningmingxiao:dev03
Open

fix: uniqMcs use all cpu#246
ningmingxiao wants to merge 1 commit intoopencontainers:mainfrom
ningmingxiao:dev03

Conversation

@ningmingxiao
Copy link
Copy Markdown
Contributor

@ningmingxiao ningmingxiao commented Nov 25, 2025

fix #247

Comment thread go-selinux/label/label_linux_test.go Outdated
Comment thread go-selinux/selinux_linux.go Outdated
@ningmingxiao ningmingxiao force-pushed the dev03 branch 2 times, most recently from d083957 to 4567cb2 Compare March 17, 2026 02:01
@rhatdan
Copy link
Copy Markdown
Collaborator

rhatdan commented Mar 23, 2026

LGTM

Comment thread go-selinux/label/label_linux.go Outdated
Copy link
Copy Markdown
Collaborator

@kolyshkin kolyshkin left a comment

Choose a reason for hiding this comment

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

Maybe we need to change the public API to add error reporting to, say, selinux.ContainerLabels (and similar functions using addMcs/uniqMcs)?
Keep the old functions for backward compatibility but deprecate those?

@ningmingxiao
Copy link
Copy Markdown
Contributor Author

Maybe we need to change the public API to add error reporting to, say, selinux.ContainerLabels (and similar functions using addMcs/uniqMcs)? Keep the old functions for backward compatibility but deprecate those?

I afraid user have to adapt to the new interface and we can't let user know old interface is deprecate. @kolyshkin

@rhatdan
Copy link
Copy Markdown
Collaborator

rhatdan commented Apr 24, 2026

Needs a rebase. @ningmingxiao still working on this one?

@ningmingxiao ningmingxiao force-pushed the dev03 branch 2 times, most recently from c63efca to a76e7fe Compare April 24, 2026 13:51
@ningmingxiao
Copy link
Copy Markdown
Contributor Author

done thanks @rhatdan

Copy link
Copy Markdown
Collaborator

@kolyshkin kolyshkin left a comment

Choose a reason for hiding this comment

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

So, what we need to do here is move selinux.ContainerLabels (and selinux.ContainerLabelsSize) into an internal package. It looks like no one is using selinux.ContainerLabels -- the only user is `label.InitLabels. Means we can move it to internal and then do whatever we want to. See #247 (comment) for details.

@ningmingxiao ningmingxiao force-pushed the dev03 branch 10 times, most recently from ae0f8db to 936fe01 Compare April 27, 2026 05:55
@ningmingxiao
Copy link
Copy Markdown
Contributor Author

done @kolyshkin

@ningmingxiao ningmingxiao force-pushed the dev03 branch 11 times, most recently from fed9a1b to 946445b Compare April 27, 2026 08:27
Comment thread go-selinux/label/label_linux_test.go Outdated
Comment thread go-selinux/label/label_linux_test.go Outdated
if i == 19 {
if err == nil {
t.Fatal("err should not be nil")
} else if !strings.Contains(err.Error(), "SELinux label exhaustion") {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Should you do if !errors.Is(err, ErrMCSExhausted)?

xattrNameSelinux = "security.selinux"
)

var maxSelinuxLabelSize = int(CategoryRange * (CategoryRange - 1) / 2)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Alas, CategoryRange can be (and is) changed by any other package.

I'm fixing this issue in #262 by introducing SetCategoryRange and deprecating CategoryRange.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

you can merge 262 into main I will rebase it @kolyshkin

Comment thread go-selinux/selinux.go
// ReserveLabel reserves the MLS/MCS level component of the specified label
//
// Deprecated: Use ReserveLabelV2 instead.
func ReserveLabel(label string) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Do we have any external users?

Yes we do; plenty.

Comment thread go-selinux/selinux.go Outdated
Comment thread go-selinux/selinux_linux.go Outdated
Signed-off-by: ningmingxiao <ning.mingxiao@zte.com.cn>
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.

uniqMcs use 100% cpu

3 participants