2021-02-02 23:19:52 +01:00
|
|
|
From eb4e0b351b4bb229bfd5fd3ed57d3c35040265e0 Mon Sep 17 00:00:00 2001
|
2018-06-29 13:09:45 +02:00
|
|
|
From: Aleksa Sarai <asarai@suse.de>
|
|
|
|
Date: Fri, 29 Jun 2018 17:59:30 +1000
|
2021-02-02 23:19:52 +01:00
|
|
|
Subject: [PATCH 4/4] bsc1073877: apparmor: clobber docker-default profile on
|
2021-01-30 02:14:10 +01:00
|
|
|
start
|
2018-06-29 13:09:45 +02:00
|
|
|
|
|
|
|
In the process of making docker-default reloading far less expensive,
|
|
|
|
567ef8e7858c ("daemon: switch to 'ensure' workflow for AppArmor
|
|
|
|
profiles") mistakenly made the initial profile load at dockerd start-up
|
|
|
|
lazy. As a result, if you have a running Docker daemon and upgrade it to
|
|
|
|
a new one with an updated AppArmor profile the new profile will not take
|
|
|
|
effect (because the old one is still loaded). The fix for this is quite
|
|
|
|
trivial, and just requires us to clobber the profile on start-up.
|
|
|
|
|
|
|
|
Fixes: 567ef8e7858c ("daemon: switch to 'ensure' workflow for AppArmor profiles")
|
|
|
|
SUSE-Bugs: bsc#1099277
|
|
|
|
Signed-off-by: Aleksa Sarai <asarai@suse.de>
|
|
|
|
---
|
2021-01-30 02:14:10 +01:00
|
|
|
daemon/apparmor_default.go | 14 ++++++++++----
|
|
|
|
daemon/apparmor_default_unsupported.go | 4 ++++
|
|
|
|
daemon/daemon.go | 5 +++--
|
2019-07-23 03:51:56 +02:00
|
|
|
3 files changed, 17 insertions(+), 6 deletions(-)
|
2018-06-29 13:09:45 +02:00
|
|
|
|
2021-01-30 02:14:10 +01:00
|
|
|
diff --git a/daemon/apparmor_default.go b/daemon/apparmor_default.go
|
2021-02-02 23:19:52 +01:00
|
|
|
index a7cc3a5ef412..1a952953da8f 100644
|
2021-01-30 02:14:10 +01:00
|
|
|
--- a/daemon/apparmor_default.go
|
|
|
|
+++ b/daemon/apparmor_default.go
|
2021-02-02 23:19:52 +01:00
|
|
|
@@ -23,6 +23,15 @@ func DefaultApparmorProfile() string {
|
|
|
|
return ""
|
|
|
|
}
|
2018-06-29 13:09:45 +02:00
|
|
|
|
|
|
|
+func clobberDefaultAppArmorProfile() error {
|
|
|
|
+ if apparmor.IsEnabled() {
|
2021-01-30 02:14:10 +01:00
|
|
|
+ if err := aaprofile.InstallDefault(defaultAppArmorProfile); err != nil {
|
|
|
|
+ return fmt.Errorf("AppArmor enabled on system but the %s profile could not be loaded: %s", defaultAppArmorProfile, err)
|
2018-06-29 13:09:45 +02:00
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return nil
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
func ensureDefaultAppArmorProfile() error {
|
|
|
|
if apparmor.IsEnabled() {
|
2021-01-30 02:14:10 +01:00
|
|
|
loaded, err := aaprofile.IsLoaded(defaultAppArmorProfile)
|
2021-02-02 23:19:52 +01:00
|
|
|
@@ -36,10 +45,7 @@ func ensureDefaultAppArmorProfile() error {
|
2018-06-29 13:09:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Load the profile.
|
2021-01-30 02:14:10 +01:00
|
|
|
- if err := aaprofile.InstallDefault(defaultAppArmorProfile); err != nil {
|
|
|
|
- return fmt.Errorf("AppArmor enabled on system but the %s profile could not be loaded: %s", defaultAppArmorProfile, err)
|
2018-06-29 13:09:45 +02:00
|
|
|
- }
|
|
|
|
+ return clobberDefaultAppArmorProfile()
|
|
|
|
}
|
|
|
|
-
|
|
|
|
return nil
|
|
|
|
}
|
2021-01-30 02:14:10 +01:00
|
|
|
diff --git a/daemon/apparmor_default_unsupported.go b/daemon/apparmor_default_unsupported.go
|
2021-02-02 23:19:52 +01:00
|
|
|
index dd581dc7dadb..5b14979cd4a3 100644
|
2021-01-30 02:14:10 +01:00
|
|
|
--- a/daemon/apparmor_default_unsupported.go
|
|
|
|
+++ b/daemon/apparmor_default_unsupported.go
|
2018-06-29 13:09:45 +02:00
|
|
|
@@ -2,6 +2,10 @@
|
|
|
|
|
2018-08-15 09:09:12 +02:00
|
|
|
package daemon // import "github.com/docker/docker/daemon"
|
2018-06-29 13:09:45 +02:00
|
|
|
|
|
|
|
+func clobberDefaultAppArmorProfile() error {
|
|
|
|
+ return nil
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
func ensureDefaultAppArmorProfile() error {
|
|
|
|
return nil
|
|
|
|
}
|
2021-01-30 02:14:10 +01:00
|
|
|
diff --git a/daemon/daemon.go b/daemon/daemon.go
|
2021-02-02 23:19:52 +01:00
|
|
|
index 794ff9712d08..f9e727b348c5 100644
|
2021-01-30 02:14:10 +01:00
|
|
|
--- a/daemon/daemon.go
|
|
|
|
+++ b/daemon/daemon.go
|
|
|
|
@@ -855,8 +855,9 @@ func NewDaemon(ctx context.Context, config *config.Config, pluginStore *plugin.S
|
2018-06-29 13:09:45 +02:00
|
|
|
logrus.Warnf("Failed to configure golang's threads limit: %v", err)
|
|
|
|
}
|
|
|
|
|
2019-07-23 03:51:56 +02:00
|
|
|
- // ensureDefaultAppArmorProfile does nothing if apparmor is disabled
|
2018-06-29 13:09:45 +02:00
|
|
|
- if err := ensureDefaultAppArmorProfile(); err != nil {
|
|
|
|
+ // Make sure we clobber any pre-existing docker-default profile to ensure
|
|
|
|
+ // that upgrades to the profile actually work smoothly.
|
|
|
|
+ if err := clobberDefaultAppArmorProfile(); err != nil {
|
|
|
|
logrus.Errorf(err.Error())
|
|
|
|
}
|
|
|
|
|
|
|
|
--
|
2021-01-30 02:14:10 +01:00
|
|
|
2.30.0
|
2018-06-29 13:09:45 +02:00
|
|
|
|