X Tutup
Skip to content

Docker inspect "AppArmorProfile" field now shows "docker-default" when AppArmor is enabled and no other profile was defined #27083

Merged
tonistiigi merged 1 commit intomoby:masterfrom
RobSkye:25935-show-apparmor-default-profile-in-docker-inspect
Jan 30, 2017
Merged

Docker inspect "AppArmorProfile" field now shows "docker-default" when AppArmor is enabled and no other profile was defined #27083
tonistiigi merged 1 commit intomoby:masterfrom
RobSkye:25935-show-apparmor-default-profile-in-docker-inspect

Conversation

@RobSkye
Copy link
Contributor

@RobSkye RobSkye commented Sep 30, 2016

This pull request fixes #25935 showing "AppArmorProfile" in docker inspect filled with "docker-default" when AppArmor is enabled and no other profile was defined using --security-opt.

@RobSkye RobSkye closed this Sep 30, 2016
@RobSkye RobSkye changed the title adde Docker inspect "AppArmorProfile" field now shows "default-profile" when AppArmor is enabled and no other profile was defined Oct 1, 2016
@thaJeztah
Copy link
Member

@RobSkye did you close this on purpose, or by accident?

@RobSkye RobSkye reopened this Oct 1, 2016
@RobSkye
Copy link
Contributor Author

RobSkye commented Oct 1, 2016

By Accident...laptops and beds are bad combination....I'm editing the description too.

@thaJeztah
Copy link
Member

GitHub buttons are also a disaster at times, haha, no worries, thanks!

@thaJeztah
Copy link
Member

Guess this fixes #25935

@RobSkye
Copy link
Contributor Author

RobSkye commented Oct 1, 2016

Yes.

@RobSkye RobSkye changed the title Docker inspect "AppArmorProfile" field now shows "default-profile" when AppArmor is enabled and no other profile was defined Docker inspect "AppArmorProfile" field now shows "docker-default" when AppArmor is enabled and no other profile was defined Oct 1, 2016
Copy link
Member

@tonistiigi tonistiigi left a comment

Choose a reason for hiding this comment

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

Please squash the commits as well.

Copy link
Member

Choose a reason for hiding this comment

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

there is const defaultApparmorProfile

Copy link
Member

Choose a reason for hiding this comment

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

Also need to handle --privileged. See https://github.com/docker/docker/blob/master/daemon/oci_linux.go#L709-L714

Even with privileged fixed this is a slight behavioral change. If apparmor is enabled after container was created this var will not change. I think if this is only called on inspecting single container we can lazy load the value like we do in container startup.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Even with privileged fixed this is a slight behavioral change. If apparmor is enabled after container was created this var will not change. I think if this is only called on inspecting single container we can lazy load the value like we do in container startup.

Yes, I agree on that. Maybe docker inspect is not the best place to show security information because one thing is the definition of the security you want and the other the security you really have in place at execution time.

Having said that, we can check in daemon.containerStart if the container apparmor options are compatible with the actual execution environment and if not, change the value to unconfined.

I'm going to commit and push this ASAP and..I will squash the commits, sorry about that :p

@thaJeztah
Copy link
Member

@RobSkye can you address @tonistiigi's comments, and squash your commits?

@RobSkye
Copy link
Contributor Author

RobSkye commented Oct 11, 2016

With the latest push, if you change apparmor configuration and apparmor completely disappear from the dockerhost (I have some comments about this below) the AppArmorProfile is updated with the expected configuration but still there is some issues we have to address:

  1. If you do an inspect after an apparmor change and before the start of the container, still shows the old AppArmorProfile.
  2. If you create the container with apparmor disabled but with --security-opt apparmor=someprofile, when you enable apparmor in dockerhost, AppArmorProfile will be "docker-default".
  3. Apparmor status is checked ONLY checking the existence of /sys/kernel/security/apparmor and is not a good method, you can have apparmor completely shutdown and still that directory exists. see https://github.com/docker/docker/blob/master/pkg/sysinfo/sysinfo_linux.go#L57
  4. You can run a container with --security-opt apparmor=someprofile and someprofile will be set in AppArmorProfile whether or not exists as an valid apparmor profile.

I don't know if addressing this issues are in the scope of the main issue. I' have the feeling that implementing a real-time check of the security configuration of containers will require more than a "slight behavioral change".

I have some ideas of adding security information in the "docker ps" command and a more detailed "docker security" showing all the security settings of a container.

I look forward to your feedback.

Copy link
Member

Choose a reason for hiding this comment

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

Don't understand this. Why is unconfined profile switched back to default.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That is actually an error. I was trying to restore "docker-default" to the unconfined containers if the containers were created after apparmor was enabled but i didn't notice the effect of enabling apparmor to the containers with --security-opt app-armor:unconfined.

I'm gonna think on how manage this correctly.

@RobSkye
Copy link
Contributor Author

RobSkye commented Oct 12, 2016

I did a little refactor of the patch in the last commit. Now inspect always shows an empty AppArmorProfile when the container is stopped ( maybe empty is not the best value but this can be changed easily to undefined, unconfined or something more clarifying).

The correct value of AppArmorProfile is set at container startup using the actual status of apparmor, the privileged flag and the configured apparmor settings using --security-opt.

@LK4D4
Copy link
Contributor

LK4D4 commented Nov 3, 2016

@RobSkye I'm not sure that I like an idea of clearing profile on stopped containers - it's breaking change, and indeed it might be useful for debugging. Otherwise, the patch is ok for me.

@mlaventure
Copy link
Contributor

ping @RobSkye , needs a rebase.

I personally don't think showing the previous apparmor profile when inspecting old containers is an issue to be fixed otherwise. It properly reflect how this container was run.

@RobSkye
Copy link
Contributor Author

RobSkye commented Dec 4, 2016

Ok, i'll delete that part and rebase/commit.

@GordonTheTurtle GordonTheTurtle added dco/no Automatically set by a bot when one of the commits lacks proper signature and removed dco/no Automatically set by a bot when one of the commits lacks proper signature labels Dec 19, 2016
@thaJeztah
Copy link
Member

ping @tonistiigi @LK4D4 PTAL what's the status on this one?

Copy link
Member

Choose a reason for hiding this comment

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

I'd call this saveApparmorConfig

Copy link
Member

Choose a reason for hiding this comment

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

This shows unconfined when apparmor is disabled.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, do you want to show "Disabled" instead?

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 empty would do. unconfined implies that special privileged profile was applied(at least to me).

@LK4D4
Copy link
Contributor

LK4D4 commented Jan 19, 2017

ping @RobSkye
Would you mind to fix Tonis' comments? Then we can merge

…AppArmor is enabled or not. It is set in NewDaemon using sysInfo information.

Signed-off-by: Roberto Muñoz Fernández <robertomf@gmail.com>

Added an apparmorEnabled boolean in the Daemon struct to indicate if AppArmor is enabled or not. It is set in NewDaemon using sysInfo information.

Signed-off-by: Roberto Muñoz Fernández <robertomf@gmail.com>

gofmt'd

Signed-off-by: Roberto Muñoz Fernández <robertomf@gmail.com>

change the function name to something more adequate and changed the behaviour to show empty value on an apparmor disabled system.

Signed-off-by: Roberto Muñoz Fernández <robertomf@gmail.com>

go fmt

Signed-off-by: Roberto Muñoz Fernández <robertomf@gmail.com>
@LK4D4
Copy link
Contributor

LK4D4 commented Jan 30, 2017

LGTM
ping @tonistiigi

Copy link
Member

@tonistiigi tonistiigi left a comment

Choose a reason for hiding this comment

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

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

docker inspect contains no indication of default AppArmor profile

6 participants

X Tutup