diff options
author | Rahat Mahmood <rahat@google.com> | 2021-05-14 11:06:07 -0700 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2021-05-14 11:07:57 -0700 |
commit | 78ae3db1a39c0cd925c6b75807fa1dc76ba99986 (patch) | |
tree | f4efaef41e425289ed253596c8e632431e21fdc2 /test/util/cgroup_util.cc | |
parent | 2b457d9ee9ba50da4a9208d957053fac2c77932d (diff) |
Fix cgroup hierarchy registration.
Previously, registration was racy because we were publishing
hierarchies in the registry without fully initializing the underlying
filesystem. This led to concurrent mount(2)s discovering the partially
intialized filesystems and dropping the final refs on them which cause
them to be freed prematurely.
Reported-by: syzbot+13f54e77bdf59f0171f0@syzkaller.appspotmail.com
Reported-by: syzbot+2c7f0a9127ac6a84f17e@syzkaller.appspotmail.com
PiperOrigin-RevId: 373824552
Diffstat (limited to 'test/util/cgroup_util.cc')
-rw-r--r-- | test/util/cgroup_util.cc | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/test/util/cgroup_util.cc b/test/util/cgroup_util.cc index 04d4f8de0..977993f41 100644 --- a/test/util/cgroup_util.cc +++ b/test/util/cgroup_util.cc @@ -142,6 +142,20 @@ PosixError Mounter::Unmount(const Cgroup& c) { return NoError(); } +void Mounter::release(const Cgroup& c) { + auto mp = mountpoints_.find(c.id()); + if (mp != mountpoints_.end()) { + mp->second.release(); + mountpoints_.erase(mp); + } + + auto m = mounts_.find(c.id()); + if (m != mounts_.end()) { + m->second.Release(); + mounts_.erase(m); + } +} + constexpr char kProcCgroupsHeader[] = "#subsys_name\thierarchy\tnum_cgroups\tenabled"; |