Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@umohnani8
Copy link
Member

@umohnani8 umohnani8 commented May 2, 2018

The list of capabilities to be added can be defined in
/etc/crio/crio.conf.

Fixes #1536

Signed-off-by: umohnani8 [email protected]

@umohnani8 umohnani8 requested review from mrunalp and runcom as code owners May 2, 2018 19:12
@k8s-ci-robot k8s-ci-robot added cncf-cla: yes size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels May 2, 2018
@umohnani8
Copy link
Member Author

@rhatdan @mrunalp PTAL

@mrunalp
Copy link
Member

mrunalp commented May 2, 2018

Let us add an integration test that uses this configuration.

lib/config.go Outdated
"NET_BIND_SERVICE",
"SYS_CHROOT",
"KILL",
"AUDIT_WRITE",
Copy link
Contributor

Choose a reason for hiding this comment

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

I propose we remove AUDIT_WRITE from defaults.
/* Allow writing the audit log via unicast netlink socket */

This allows an application to send a message to the audit log system, I think this should be blocked by default.

lib/config.go Outdated
"NET_RAW",
"SETGID",
"SETUID",
"SETFCAP",
Copy link
Contributor

Choose a reason for hiding this comment

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

I propose we remove SETFCAP from defaults, this is only used for installation software, like rpm. The ability to create a setuid or file cap file should be blocked by default.

lib/config.go Outdated
"DAC_OVERRIDE",
"FSETID",
"FOWNER",
"MKNOD",
Copy link
Contributor

Choose a reason for hiding this comment

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

I propose we remove MKNOD from default. This will block the ability for apps to create device nodes. I don't believe that containers should have this by default. This is needed for installation not for running containers in production. The one potential problem with this would be applications creating something like a loopback device.

cgroup_manager = "{{ .CgroupManager }}"
# capabilities is the list of capabilities to add and can be modified here.
# If capabilities below is commented out, the default list of capabilites defined in the
Copy link
Contributor

Choose a reason for hiding this comment

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

Spelling capabilites

@rhatdan
Copy link
Contributor

rhatdan commented May 2, 2018

I think there should be a --default-capabilities flag for CRI-O so distros can specify the list of capabilities to add by default

@umohnani8 umohnani8 force-pushed the cap branch 4 times, most recently from 0e7672d to 1d7dfd9 Compare May 4, 2018 20:42
@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels May 4, 2018
@umohnani8 umohnani8 force-pushed the cap branch 2 times, most recently from 412c344 to 7f2e159 Compare May 7, 2018 15:17
test/ctr.bats Outdated
}

@test "ctr with list of capabilities given by user in crio.conf" {
start_crio "" "" "" "--default-capabilities CHOWN --default-capabilities KILL" ""
Copy link
Member

Choose a reason for hiding this comment

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

I think we should do --default-capabilities=CHOWN,KILL instead of one argument per capability.

fi

if [[ -n "$4" ]]; then
capabilities="$4"
Copy link
Member

Choose a reason for hiding this comment

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

I think this might just gobble the first in the list as is. Try with set -x.

@umohnani8 umohnani8 force-pushed the cap branch 2 times, most recently from 02fd63c to 5b70294 Compare May 7, 2018 20:17
@mrunalp
Copy link
Member

mrunalp commented May 9, 2018

We need to set the default capabilities for the sandbox infra container as well.

@umohnani8 umohnani8 force-pushed the cap branch 4 times, most recently from f696cd8 to 4441f22 Compare May 14, 2018 15:16
@umohnani8
Copy link
Member Author

/test all

@umohnani8
Copy link
Member Author

@rhatdan @mrunalp PTAL. The unit tests pass. I don't understand why integration and e2e are failing - looks like something to do with go environment.

@rhatdan
Copy link
Contributor

rhatdan commented May 14, 2018

@mrunalp
The error is:

Detected go version: go version go1.10.1 linux/amd64.
Kubernetes requires go1.10.2 or greater.
Please install go1.10.2 or later.

Does this mean we need to update the AMI?

@umohnani8
Copy link
Member Author

/test all

@umohnani8
Copy link
Member Author

/test critest_fedora
/test critest_rhel

@umohnani8
Copy link
Member Author

/test integration_fedora
/test critest_fedora

@umohnani8
Copy link
Member Author

/test critest_rhel

@umohnani8
Copy link
Member Author

/test integration_rhel

@umohnani8
Copy link
Member Author

/test integration_fedora

1 similar comment
@umohnani8
Copy link
Member Author

/test integration_fedora

@umohnani8
Copy link
Member Author

/test all

@umohnani8
Copy link
Member Author

/test kata-containers

@umohnani8
Copy link
Member Author

Tests pass!
@rhatdan @mrunalp PTAL

@rhatdan
Copy link
Contributor

rhatdan commented May 17, 2018

LGTM

@rhatdan
Copy link
Contributor

rhatdan commented May 18, 2018

@runcom @wking @mrunalp PTAL

"$COPYIMG_BINARY" --root "$TESTDIR/crio" $STORAGE_OPTIONS --runroot "$TESTDIR/crio-run" --image-name=quay.io/crio/busybox:latest --import-from=dir:"$ARTIFACTS_PATH"/busybox-image --signature-policy="$INTEGRATION_ROOT"/policy.json
"$COPYIMG_BINARY" --root "$TESTDIR/crio" $STORAGE_OPTIONS --runroot "$TESTDIR/crio-run" --image-name=quay.io/crio/stderr-test:latest --import-from=dir:"$ARTIFACTS_PATH"/stderr-test --signature-policy="$INTEGRATION_ROOT"/policy.json
"$CRIO_BINARY" ${DEFAULT_MOUNTS_OPTS} ${HOOKS_OPTS} --conmon "$CONMON_BINARY" --listen "$CRIO_SOCKET" --cgroup-manager "$CGROUP_MANAGER" --default-mounts-file "$TESTDIR/containers/mounts.conf" --registry "quay.io" --runtime "$RUNTIME_BINARY" --root "$TESTDIR/crio" --runroot "$TESTDIR/crio-run" $STORAGE_OPTIONS --seccomp-profile "$seccomp" --apparmor-profile "$apparmor" --cni-config-dir "$CRIO_CNI_CONFIG" --cni-plugin-dir "$CRIO_CNI_PLUGIN" --signature-policy "$INTEGRATION_ROOT"/policy.json --image-volumes "$IMAGE_VOLUMES" --pids-limit "$PIDS_LIMIT" --log-size-max "$LOG_SIZE_MAX_LIMIT" --config /dev/null config >$CRIO_CONFIG
"$CRIO_BINARY" ${DEFAULT_MOUNTS_OPTS} ${HOOKS_OPTS} --default-capabilities "$capabilities" --conmon "$CONMON_BINARY" --listen "$CRIO_SOCKET" --cgroup-manager "$CGROUP_MANAGER" --default-mounts-file "$TESTDIR/containers/mounts.conf" --registry "quay.io" --runtime "$RUNTIME_BINARY" --root "$TESTDIR/crio" --runroot "$TESTDIR/crio-run" $STORAGE_OPTIONS --seccomp-profile "$seccomp" --apparmor-profile "$apparmor" --cni-config-dir "$CRIO_CNI_CONFIG" --cni-plugin-dir "$CRIO_CNI_PLUGIN" --signature-policy "$INTEGRATION_ROOT"/policy.json --image-volumes "$IMAGE_VOLUMES" --pids-limit "$PIDS_LIMIT" --log-size-max "$LOG_SIZE_MAX_LIMIT" --config /dev/null config >$CRIO_CONFIG
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the easiest approach to "for a handful of tests I want to set this option" is to use an ADDITIONAL_CRIO_OPTIONS environment variable. For an example, see here and here in the otherwise unrelated #1280. Passing these in as positional arguments seems more brittle than:

ADDITIONAL_CRIO_OPTIONS='--default-capabilities "CHOWN,DAC_OVERRIDE,FSETID,FOWNER,NET_RAW,SETGID,SETUID"' start_crio

Copy link
Member Author

Choose a reason for hiding this comment

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

The default capabilities needs to be set for all the tests as we are getting rid of some of the capabilities given by the default spec. There is just one test where I change the capabilities to test out that when the user updates the list of capabilities, cri-o uses the new list.

@rhatdan
Copy link
Contributor

rhatdan commented May 19, 2018

@umohnani8 Sadly this needs a rebase, also could you check to make sure the seccomp handling is done correctly. IE Seccomp rules are supposed to reflect the current settings in the capabilities list.

Change the configs under testdata to default to not share the pid
namespace unless required to.

Signed-off-by: umohnani8 <[email protected]>
@umohnani8
Copy link
Member Author

rebased.

@umohnani8
Copy link
Member Author

/test all

@umohnani8
Copy link
Member Author

/test e2e_rhel

The list of capabilities to be added can be defined in
/etc/crio/crio.conf.

Signed-off-by: umohnani8 <[email protected]>
@umohnani8
Copy link
Member Author

/test all

@rhatdan
Copy link
Contributor

rhatdan commented May 22, 2018

LGTM

Copy link
Member

@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 mrunalp merged commit 7b3dab8 into cri-o:master May 23, 2018
@umohnani8 umohnani8 deleted the cap branch January 31, 2019 19:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants