Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 84281555 authored by Bart Van Assche's avatar Bart Van Assche Committed by Automerger Merge Worker
Browse files

Merge "Enable the memory_recursiveprot mount option" am: 3e9eeb83

Original change: https://android-review.googlesource.com/c/platform/system/core/+/1975508

Change-Id: Ib570a1b16ea67fff6a8d318ea200777f14d78278
parents 06d9627e 3e9eeb83
Loading
Loading
Loading
Loading
+12 −2
Original line number Diff line number Diff line
@@ -263,8 +263,18 @@ static bool SetupCgroup(const CgroupDescriptor& descriptor) {
                return false;
            }

            result = mount("none", controller->path(), "cgroup2", MS_NODEV | MS_NOEXEC | MS_NOSUID,
                           nullptr);
            // The memory_recursiveprot mount option has been introduced by kernel commit
            // 8a931f801340 ("mm: memcontrol: recursive memory.low protection"; v5.7). Try first to
            // mount with that option enabled. If mounting fails because the kernel is too old,
            // retry without that mount option.
            if (mount("none", controller->path(), "cgroup2", MS_NODEV | MS_NOEXEC | MS_NOSUID,
                      "memory_recursiveprot") < 0) {
                LOG(INFO) << "Mounting memcg with memory_recursiveprot failed. Retrying without.";
                if (mount("none", controller->path(), "cgroup2", MS_NODEV | MS_NOEXEC | MS_NOSUID,
                          nullptr) < 0) {
                    PLOG(ERROR) << "Failed to mount cgroup v2";
                }
            }

            // selinux permissions change after mounting, so it's ok to change mode and owner now
            if (!ChangeDirModeAndOwner(controller->path(), descriptor.mode(), descriptor.uid(),