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

update runtime-spec version #349

Merged
merged 1 commit into from
Apr 11, 2017
Merged

Conversation

zhouhao3
Copy link

Update the runtime-spec version, some corresponding change questionable, what questions please suggest.

Signed-off-by: zhouhao zhouhao@cn.fujitsu.com

@@ -22,8 +22,6 @@ var generateFlags = []cli.Flag{
cli.StringFlag{Name: "arch", Value: runtime.GOARCH, Usage: "architecture the container is created for"},
cli.StringSliceFlag{Name: "args", Usage: "command to run in the container"},
cli.StringSliceFlag{Name: "bind", Usage: "bind mount directories src:dest[:options...]"},
cli.StringSliceFlag{Name: "cap-add", Usage: "add Linux capabilities"},
cli.StringSliceFlag{Name: "cap-drop", Usage: "drop Linux capabilities"},
Copy link
Author

Choose a reason for hiding this comment

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

Because the structure of capabilities changes, I do not know how to deal with these two functions, so temporarily delete, there are good ways to solve.

Copy link
Contributor

Choose a reason for hiding this comment

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

We can use these flags to add/drop from all the 5 sets. We can add other more specific flags like cap-bounding-add/cap-bounding-drop after this PR. Thanks!

Copy link
Author

Choose a reason for hiding this comment

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

updated. In the subsequent PR can continue to improve.


// The required part and optional part are separated by ":"
// The required part and optional part are seperated by ":"
Copy link
Contributor

Choose a reason for hiding this comment

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

“separated” was right.

expectedCaps[ec] = true
}
for _, ec := range spec.Process.Capabilities.Effective {
expectedCaps[ec] = true
Copy link
Contributor

Choose a reason for hiding this comment

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

This isn't right. You'll need different maps for each spec.Process.Capabilities.* and then different checks for each map below. For example, the current actuallySet := processCaps.Get(capability.EFFECTIVE, cap) should be compared against an expected value from spec.Process.Capabilities.Effective.

"CAP_AUDIT_WRITE",
"CAP_KILL",
"CAP_NET_BIND_SERVICE",
},
Copy link
Contributor

Choose a reason for hiding this comment

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

What you're moving back towards here is close to what @mrunalp landed way back in b462307. But in 3a2ba61, @mrunalp changed that default to more closely match values extracted from Docker. In the absence of arguments for or against a given value, I expect we want to leave the values alone (and keep the fuller set from Docker as we move into the bounding/permitted/… capabilities world).

g.spec.Process.SelinuxLabel = ""
g.spec.Process.ApparmorProfile = ""
g.spec.Linux.Seccomp = nil
}
}

// ClearProcessCapabilities clear g.spec.Process.Capabilities.
func (g *Generator) ClearProcessCapabilities() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Clearing all of process.capabilities is still a well-defined operation. We may need new operations to clear individual process.capabilities.*, but there's no need to drop this one.

@zhouhao3 zhouhao3 force-pushed the up-version branch 5 times, most recently from 644cef4 to 5ad3127 Compare March 24, 2017 02:17
actuallySet := processCaps.Get(capability.BOUNDING, cap)
if expectedSet != actuallySet {
if expectedSet {
return fmt.Errorf("Expected Capability %v not set for process", cap.String())
Copy link
Contributor

@mrunalp mrunalp Mar 24, 2017

Choose a reason for hiding this comment

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

Can we add the type of capability here?

return fmt.Errorf("Expected bounding capability %v not set for process", cap.String())`

if expectedSet {
return fmt.Errorf("Expected Capability %v not set for process", cap.String())
}
return fmt.Errorf("Unexpected Capability %v set for process", cap.String())
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here.

actuallySet = processCaps.Get(capability.EFFECTIVE, cap)
if expectedSet != actuallySet {
if expectedSet {
return fmt.Errorf("Expected Capability %v not set for process", cap.String())
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we add the type of capability here?

return fmt.Errorf("Expected effective capability %v not set for process", cap.String())`

if expectedSet {
return fmt.Errorf("Expected Capability %v not set for process", cap.String())
}
return fmt.Errorf("Unexpected Capability %v set for process", cap.String())
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here and for the other capability types below.

{
Name: "accept",
Names: []string{"accept"},
Copy link
Contributor

Choose a reason for hiding this comment

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

All of the system calls can now be added to a single Names list here.
For e.g.

Names: []string{
              "accept",
              "accept4",
              "access",
}

Copy link
Author

Choose a reason for hiding this comment

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

updated, PTAL.

@mrunalp
Copy link
Contributor

mrunalp commented Mar 24, 2017

@grantseltzer Could you review the seccomp related changes?

@grantseltzer
Copy link
Contributor

grantseltzer commented Mar 25, 2017

Everything appears to be working properly, but there should be capability added to place a comment inside the rules if we're updating to the new spec anyway.

@zhouhao3 zhouhao3 force-pushed the up-version branch 4 times, most recently from 02d7d0d to 51da485 Compare March 28, 2017 03:30
@@ -34,8 +33,8 @@
},
{
"ImportPath": "github.com/opencontainers/runtime-spec/specs-go",
"Comment": "v1.0.0-rc1-31-gbb6925e",
"Rev": "bb6925ea99f0e366a3f7d1c975f6577475ca25f0"
"Comment": "v1.0.0-rc5-30-g3adac26",
Copy link
Contributor

@wking wking Mar 29, 2017

Choose a reason for hiding this comment

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

Is this intentionally bumping to a commit that is 30 commits after the tagged rc5? I don't think the LinuxSyscall.Comment removal or Linux.IntelRdt addition are so pressing that it's worth bringing in a non-release spec commit.

Copy link
Author

Choose a reason for hiding this comment

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

Do you mean to only update to v1.0.0-rc5? Or like 237bca6?

Copy link
Contributor

Choose a reason for hiding this comment

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

Do you mean to only update to v1.0.0-rc5?

That's what I mean. I'd rather avoid:

$ ./oci-runtime-tool validate
1 Errors detected:
internal error: validate currently only handles version 1.0.0-rc5-dev, but the supplied configuration targets 1.0.0-rc5

Copy link
Author

Choose a reason for hiding this comment

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

I now use godep update to update the runtime-spec, after the update directly to the latest version (v1.0.0-rc5-30), what method can you only be updated to 1.0.0-rc5? Thanks.

Copy link
Contributor

Choose a reason for hiding this comment

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

… what method can you only be updated to 1.0.0-rc5?

In whichever GOPATH you use, go to src/github.com/opencontainers/runtime-spec. Then:

$ git checkout v1.0.0-rc5

Now, back in runtime-tools:

$ godep update github.com/opencontainers/runtime-spec/specs-go

and you should be good to go.

Copy link
Author

Choose a reason for hiding this comment

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

updated. Thank you very much for your guidance.

@vbatts
Copy link
Member

vbatts commented Apr 3, 2017

LGTM

Approved with PullApprove

@mrunalp
Copy link
Contributor

mrunalp commented Apr 3, 2017

There is an issue with generate specifically in the syscall section.
runc run/ make localvalidation just hang.

@cyphar
Copy link
Member

cyphar commented Apr 5, 2017

This is currently blocking a wide variety of things (like being able to use the newest version of runC with anything generated by this library). So umoci can't work with the latest runC at the moment, neither can cri-o or orca.

Are there any updates?

@mrunalp
Copy link
Contributor

mrunalp commented Apr 6, 2017

I'll look into this by tomorrow if there are no more updates to the PR.

@vbatts
Copy link
Member

vbatts commented Apr 6, 2017

yeah. the generated config.json does not currently work with runc run
something in capabilities is not marshalling correctly as a []string, and the syscall names in seccomp are marshalling as empty strings.
I wish we could add a round-trip test for this (i realize that it's default to bootstrap that).

@wking
Copy link
Contributor

wking commented Apr 6, 2017 via email

{
Index: 0,
Value: 0xffffffff,
Op: rspec.OpEqualTo,
Copy link
Contributor

Choose a reason for hiding this comment

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

This looks buggy to me (and may be the source of @mrunalp's problem). In master, only personality has an 0xffffffff arg, but here you have a whole bunch of names with that arg. I think you over-flattened here, and need to split this entry into separate entries for each []LinuxSeccompArg value in master.

Copy link
Contributor

Choose a reason for hiding this comment

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

Adding this diff makes this PR work.

diff --git a/generate/seccomp/seccomp_default.go b/generate/seccomp/seccomp_default.go
index e057ca7..e9561ae 100644
--- a/generate/seccomp/seccomp_default.go
+++ b/generate/seccomp/seccomp_default.go
@@ -344,23 +344,6 @@ func DefaultProfile(rs *specs.Spec) *rspec.LinuxSeccomp {
                                "writev",
                        },
                        Action: rspec.ActAllow,
-                       Args: []rspec.LinuxSeccompArg{
-                               {
-                                       Index: 0,
-                                       Value: 0x0,
-                                       Op:    rspec.OpEqualTo,
-                               },
-                               {
-                                       Index: 0,
-                                       Value: 0x0008,
-                                       Op:    rspec.OpEqualTo,
-                               },
-                               {
-                                       Index: 0,
-                                       Value: 0xffffffff,
-                                       Op:    rspec.OpEqualTo,
-                               },
-                       },
                },
        }
        var sysCloneFlagsIndex uint

Copy link
Contributor

Choose a reason for hiding this comment

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

@q384566678 could you include the diff from my comment above in the PR?

Copy link
Contributor

@wking wking Apr 7, 2017

Choose a reason for hiding this comment

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

… could you include the diff from my comment above in the PR?

I think that patch is too coarse. For example personality should probably keep its old entries. The algorithm for the change should be:

For all the old syscalls, group by (action, args) tuples, and create a new entry collecting all the old Names into the new Names.

It looks like:

      Action: rspec.ActAllow,
      Args:   []rspec.Arg{},

matches everything except personality (based on a very quick skim, may have missed something). And personality will still need three entries (one for each of its current []rspec.Arg values.

Or maybe personality can have a single entry:

    {
      Names: []string{"personality"},
      Action: rspec.ActAllow,
      Args: []rspec.Arg{
        {
          Index: 0,
          Value: 0x0,
          Op:    rspec.OpEqualTo,
        },
        {
          Index: 0,
          Value: 0x0008,
          Op:    rspec.OpEqualTo,
        },
        {
          Index: 0,
          Value: 0xffffffff,
          Op:    rspec.OpEqualTo,
        },
      },
    },

I'm not sure what the semantics are supposed to be for multiple Args.

Copy link
Author

Choose a reason for hiding this comment

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

I think dc38a7d is better.
@mrunalp @wking PTAL

Copy link
Contributor

Choose a reason for hiding this comment

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

@q384566678 Did you test latest changes with latest runc? (I'll test it tomorrow).

Copy link
Author

Choose a reason for hiding this comment

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

@mrunalp I was doing it, but when I executed the sudo make RUNTIME=runc localvalidation command, the following error occurred:

go: GOPATH entry is relative; must be absolute path: "".

I have already set up GOPATH, I'm looking for the solution, may want to make trouble you first test, thanks a lot.

Copy link
Contributor

Choose a reason for hiding this comment

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

@q384566678 I cannot find dc38a7d. Did you forget to push it?

Copy link
Contributor

Choose a reason for hiding this comment

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

I cannot find dc38a7d. Did you forget to push it?

The current tip (afc8d35) includes the change I think we want, and was committed a few hours after @q384566678 mentioned dc38a7d. I expect he just fixed up some minor thing in the interim, and that afc8d35 is ready for testing/merging.

Signed-off-by: zhouhao <zhouhao@cn.fujitsu.com>
@mrunalp
Copy link
Contributor

mrunalp commented Apr 10, 2017

Much better now. runc start fine and tests also run. The one problem I see in the generated config is chroot being added to the seccomp section 5 times:

                               {
                                        "names": [
                                                "chroot"
                                        ],
                                        "action": "SCMP_ACT_ALLOW",
                                        "args": [],
                                        "comment": ""
                                },
                                {
                                        "names": [
                                                "chroot"
                                        ],
                                        "action": "SCMP_ACT_ALLOW",
                                        "args": [],
                                        "comment": ""
                                },
                                {
                                        "names": [
                                                "chroot"
                                        ],
                                        "action": "SCMP_ACT_ALLOW",
                                        "args": [],
                                        "comment": ""
                                },
                                {
                                        "names": [
                                                "chroot"
                                        ],
                                        "action": "SCMP_ACT_ALLOW",
                                        "args": [],
                                        "comment": ""
                                },
                                {
                                        "names": [
                                                "chroot"
                                        ],
                                        "action": "SCMP_ACT_ALLOW",
                                        "args": [],
                                        "comment": ""
                                },

},
}
var sysCloneFlagsIndex uint

capSysAdmin := false
var cap string
var caps []string
Copy link
Contributor

Choose a reason for hiding this comment

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

The reason for repitition is because we are adding caps multiple times in this list. Practically the first 4 will be same for most containers and ambient could have extra capabilities. So, instead of adding all, can we just add the caps from permitted and ambient to a map and then iterate over the map to add the syscalls?

Copy link
Contributor

Choose a reason for hiding this comment

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

So, instead of adding all, can we just add the caps from permitted and ambient to a map…

This is probably the way to go (although I'm not sure it has to be part of this PR). However, the map is going to be complicated, because you want to key by (LinuxSeccompAction, LinuxSeccompArg) with values that are []*LinuxSyscall (because the same backing LinuxSyscall may show up as the value for multiple keys in the map, and there may be multiple entries for each key). And then once you find the appropriate group of LinuxSyscalls you only need to add the syscall if it's not already listed in Names for any LinuxSyscall.

@wking
Copy link
Contributor

wking commented Apr 10, 2017 via email

@mrunalp
Copy link
Contributor

mrunalp commented Apr 10, 2017

@wking Yeah, we can fix that up in a follow on PR.

@mrunalp
Copy link
Contributor

mrunalp commented Apr 10, 2017

LGTM
cc: @Mashimiao @liangchenye

Approved with PullApprove

@Mashimiao
Copy link

Mashimiao commented Apr 11, 2017

LGTM

Approved with PullApprove

@Mashimiao Mashimiao merged commit 868323a into opencontainers:master Apr 11, 2017
@zhouhao3 zhouhao3 deleted the up-version branch April 11, 2017 01:34
@cyphar
Copy link
Member

cyphar commented Apr 11, 2017

👍

@vbatts
Copy link
Member

vbatts commented Apr 11, 2017

💯

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.

7 participants