Skip to content

generate: do not validate caps when being dropped#466

Merged
mrunalp merged 1 commit intoopencontainers:masterfrom
runcom:no-drop-validate
Sep 9, 2017
Merged

generate: do not validate caps when being dropped#466
mrunalp merged 1 commit intoopencontainers:masterfrom
runcom:no-drop-validate

Conversation

@runcom
Copy link
Copy Markdown
Member

@runcom runcom commented Sep 7, 2017

There's actually little value in erroring out when asked to drop a
capability not supported on a system. This patch simply removes the cap
validation and just go ahead and drop the capability.

@mrunalp @Mashimiao PTAL

Signed-off-by: Antonio Murdaca runcom@redhat.com

Copy link
Copy Markdown
Contributor

@mrunalp mrunalp left a comment

Choose a reason for hiding this comment

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

LGTM

@mrunalp
Copy link
Copy Markdown
Contributor

mrunalp commented Sep 7, 2017

@vbatts PTAL

@Mashimiao
Copy link
Copy Markdown

Sorry, I don't think that's validation's problem. From the log in reference PR #860, it seems you have given wrong cp value CAP_CAP_AUDIT_READ. I think the right value should be CAP_AUDIT_READ

@wking
Copy link
Copy Markdown
Contributor

wking commented Sep 8, 2017

... it seems you have given wrong cp value CAP_CAP_AUDIT_READ. I think the right value should be CAP_AUDIT_READ

How about checking for "valid or already in the array (even if not valid)" and erroring if neither are true?

@Mashimiao
Copy link
Copy Markdown

If you use AddProcessCapability() to add cap, you even can't put wrong value into the cap array.
But maybe someone added wrong value into config.json directly, we can't control such thing.
So, I think your suggestion is OK.
We can move CapValid to behind the cap removing loop, if the value is not in array and also not a valid value, we can return the error

@runcom
Copy link
Copy Markdown
Member Author

runcom commented Sep 8, 2017

@Mashimiao no, this is not about the log in the linked PR, the CAP_CAP_ was a runtime-tools bug ;) fixed by my last PR here.

Anyhow, it's OK to validate to add caps, but totally useless to validate to DROP. What's the point in validating on drop? What do you gain? We aren't validating what will be put in the config like this, dropping removes a value so it's totally fine to not validate.

@Mashimiao
Copy link
Copy Markdown

Mashimiao commented Sep 8, 2017 via email

@runcom
Copy link
Copy Markdown
Member Author

runcom commented Sep 8, 2017

I want to keep cap validation for drop because I'm afraid users may accidentally input wrong value

@Mashimiao sorry but I can't understand this. What's the point in validating something that will be removed? If I want to remove a cap that my OS doesn't support, what's the issue? Who cares? If my OS doesn't support it, it's already dropped and will be discarded on capability application. If that's not the case, probably you're right though.

@Mashimiao
Copy link
Copy Markdown

I think you didn't get my point. I said,

 I'm afraid users may accidentally input wrong value, we can return him an error to warn that

For example, If user want drop CAP_SYS_ADMIN, accidentally type CAP_SYS_ADMI, I think we should tell him he's trying to drop invalid value. And that's what I care about.

There's actually little value in erroring out when asked to drop a
capability not supported on a system. This patch simply removes the cap
validation and just go ahead and drop the capability.

Signed-off-by: Antonio Murdaca <runcom@redhat.com>
@runcom
Copy link
Copy Markdown
Member Author

runcom commented Sep 8, 2017

@Mashimiao in that case, I believe we just need to turn off host validation, that way, you only care about syntax. PTAL, I pushed now.

@Mashimiao
Copy link
Copy Markdown

Mashimiao commented Sep 8, 2017

LGTM

Approved with PullApprove

@wking
Copy link
Copy Markdown
Contributor

wking commented Sep 8, 2017

Turning off host-specific checks won't cover the "someone got a broken value in there, and I want to remove it" case @Mashimiao pointed out here.

@runcom
Copy link
Copy Markdown
Member Author

runcom commented Sep 8, 2017

Turning off host-specific checks won't cover the "someone got a broken value in there, and I want to remove it" case @Mashimiao pointed out here.

And I believe you should check code https://github.com/opencontainers/runtime-tools/blob/master/validate/validate.go#L781 which disables check on host but keeps "valid cap" check...

That is just covering supportability on host, we don't need that, and that was the original error reported by me which I was trying to fix.

This is good now.

@wking
Copy link
Copy Markdown
Contributor

wking commented Sep 9, 2017

And I believe you should check code https://github.com/opencontainers/runtime-tools/blob/master/validate/validate.go#L781 which disables check on host but keeps "valid cap" check...

There is a CapValid check thst is independent of hostSpecific [here][1], which would block you from removing I_DONT_START_WITH_CAP_ if that happened to already be in the array.

@Mashimiao
Copy link
Copy Markdown

@runcom thinks this is enough for him, I'm OK with this. I plan to make a follow PR to fix that issue.

@mrunalp
Copy link
Copy Markdown
Contributor

mrunalp commented Sep 9, 2017

LGTM

Approved with PullApprove

@mrunalp mrunalp merged commit ba6f935 into opencontainers:master Sep 9, 2017
@runcom runcom deleted the no-drop-validate branch September 9, 2017 08:04
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.

4 participants