Skip to content
This repository has been archived by the owner on Oct 13, 2023. It is now read-only.

[18.03] Fix AppArmor not being applied to Exec processes #470

Merged
merged 1 commit into from
Apr 12, 2018

Conversation

thaJeztah
Copy link
Member

cherry-pick of moby/moby#36466

git checkout -b 18.03-fix-exec-apparmor upstream/18.03 
git cherry-pick -s -S -x -Xsubtree=components/engine 8f3308ae10ec9ad0dd4edfb46fde53a0e1e19b34

No conflicts

fixes moby/moby#36456

Exec processes do not automatically inherit AppArmor profiles from the container.

This patch sets the AppArmor profile for the exec process.

Before this change:

apparmor_parser -q -r <<EOF
#include <tunables/global>
profile deny-write flags=(attach_disconnected) {
  #include <abstractions/base>
  file,
  network,
  deny /tmp/** w,
  capability,
}
EOF

docker run -dit --security-opt "apparmor=deny-write" --name aa busybox

Running docker exec doesn't get the profile applied:

docker exec aa sh -c 'mkdir /tmp/test'
(no error)

With this change:

Running docker exec gets the AppArmor profile applied

docker exec aa sh -c 'mkdir /tmp/test'
mkdir: can't create directory '/tmp/test': Permission denied

- How to verify it

Build a .deb from this PR, using the Docker CE packaging scripts; https://github.com/docker/docker-ce-packaging/tree/master/deb

make \
  ENGINE_DIR=$GOPATH/src/github.com/docker/docker \
  CLI_DIR=$GOPATH/src/github.com/docker/cli \
  ubuntu-xenial  

Which puts the package in debbuild/ubuntu-xenial

On an Ubuntu 16.04 machine, install the package:

dpkg -i ./docker-ce_0.0.0~dev~git20180302.121756.0.dae4588d4-0~ubuntu_amd64.deb

Run the reproduction steps above

- Description for the changelog

* Fix AppArmor profiles not being applied to `docker exec` processes [moby/moby#36466](https://github.com/moby/moby/pull/36466)

Exec processes do not automatically inherit AppArmor
profiles from the container.

This patch sets the AppArmor profile for the exec
process.

Before this change:

    apparmor_parser -q -r <<EOF
    #include <tunables/global>
    profile deny-write flags=(attach_disconnected) {
      #include <abstractions/base>
      file,
      network,
      deny /tmp/** w,
      capability,
    }
    EOF

    docker run -dit --security-opt "apparmor=deny-write" --name aa busybox

    docker exec aa sh -c 'mkdir /tmp/test'
    (no error)

With this change applied:

    docker exec aa sh -c 'mkdir /tmp/test'
    mkdir: can't create directory '/tmp/test': Permission denied

Signed-off-by: Sebastiaan van Stijn <[email protected]>
(cherry picked from commit 8f3308ae10ec9ad0dd4edfb46fde53a0e1e19b34)
Signed-off-by: Sebastiaan van Stijn <[email protected]>
@thaJeztah thaJeztah added this to the 18.03.0 milestone Mar 20, 2018
@andrewhsu andrewhsu modified the milestones: 18.03.0, 18.03.1 Mar 23, 2018
Copy link
Contributor

@andrewhsu andrewhsu left a comment

Choose a reason for hiding this comment

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

LGTM

@andrewhsu andrewhsu merged commit 7ee3cf5 into docker-archive:18.03 Apr 12, 2018
@thaJeztah thaJeztah deleted the 18.03-fix-exec-apparmor branch April 12, 2018 01:22
silvin-lubecki pushed a commit to silvin-lubecki/docker-ce that referenced this pull request Jan 31, 2020
…pparmor

[18.03] Fix AppArmor not being applied to Exec processes
docker-jenkins pushed a commit that referenced this pull request May 8, 2020
[master] Build CentOS 8 on PR builds and fix GPG errors
Upstream-commit: 1c4fdf5
Component: packaging
akrasnov-drv pushed a commit to drivenets/docker-ce that referenced this pull request Apr 23, 2023
[master] Build CentOS 8 on PR builds and fix GPG errors
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
2 participants