2024-04-24 23:20:41 +02:00
|
|
|
From a924a0f12b7cb1655e0bdf3f40ae294982045749 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
|
2024-02-20 09:51:39 +01:00
|
|
|
Subject: [PATCH 4/5] 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
|
2024-04-24 23:20:41 +02:00
|
|
|
index 81e10b6cbec0..e695667a190f 100644
|
2021-01-30 02:14:10 +01:00
|
|
|
--- a/daemon/apparmor_default.go
|
|
|
|
+++ b/daemon/apparmor_default.go
|
2024-02-20 09:51:39 +01:00
|
|
|
@@ -23,6 +23,15 @@ func DefaultApparmorProfile() string {
|
2021-02-02 23:19:52 +01:00
|
|
|
return ""
|
|
|
|
}
|
2018-06-29 13:09:45 +02:00
|
|
|
|
|
|
|
+func clobberDefaultAppArmorProfile() error {
|
2023-04-26 08:31:24 +02:00
|
|
|
+ if apparmor.HostSupports() {
|
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 {
|
2023-04-26 08:31:24 +02:00
|
|
|
if apparmor.HostSupports() {
|
2021-01-30 02:14:10 +01:00
|
|
|
loaded, err := aaprofile.IsLoaded(defaultAppArmorProfile)
|
2024-02-20 09:51:39 +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
|
2024-04-24 23:20:41 +02:00
|
|
|
index be4938f5b61a..2b326fea5829 100644
|
2021-01-30 02:14:10 +01:00
|
|
|
--- a/daemon/apparmor_default_unsupported.go
|
|
|
|
+++ b/daemon/apparmor_default_unsupported.go
|
2024-02-20 09:51:39 +01:00
|
|
|
@@ -2,6 +2,10 @@
|
2018-06-29 13:09:45 +02:00
|
|
|
|
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
|
2024-04-24 23:20:41 +02:00
|
|
|
index e7ca77d8cbfc..13b39538fb00 100644
|
2021-01-30 02:14:10 +01:00
|
|
|
--- a/daemon/daemon.go
|
|
|
|
+++ b/daemon/daemon.go
|
2024-04-24 23:20:41 +02:00
|
|
|
@@ -916,8 +916,9 @@ func NewDaemon(ctx context.Context, config *config.Config, pluginStore *plugin.S
|
2024-02-20 09:51:39 +01:00
|
|
|
log.G(ctx).Warnf("Failed to configure golang's threads limit: %v", err)
|
2018-06-29 13:09:45 +02:00
|
|
|
}
|
|
|
|
|
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 {
|
2024-02-20 09:51:39 +01:00
|
|
|
log.G(ctx).Errorf(err.Error())
|
2018-06-29 13:09:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
--
|
2024-04-24 23:20:41 +02:00
|
|
|
2.44.0
|
2018-06-29 13:09:45 +02:00
|
|
|
|