lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200104011318.GA11376@localhost.localdomain>
Date:   Sat, 4 Jan 2020 01:13:24 +0000
From:   Roman Gushchin <guro@...com>
To:     Alexei Starovoitov <alexei.starovoitov@...il.com>
CC:     "bpf@...r.kernel.org" <bpf@...r.kernel.org>,
        Alexei Starovoitov <ast@...nel.org>,
        Daniel Borkmann <daniel@...earbox.net>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        Kernel Team <Kernel-team@...com>,
        "netdev@...r.kernel.org" <netdev@...r.kernel.org>,
        "stable@...r.kernel.org" <stable@...r.kernel.org>
Subject: Re: [PATCH bpf] bpf: cgroup: prevent out-of-order release of cgroup
 bpf

On Fri, Jan 03, 2020 at 04:35:25PM -0800, Alexei Starovoitov wrote:
> On Fri, Dec 27, 2019 at 01:50:34PM -0800, Roman Gushchin wrote:
> > Before commit 4bfc0bb2c60e ("bpf: decouple the lifetime of cgroup_bpf
> > from cgroup itself") cgroup bpf structures were released with
> > corresponding cgroup structures. It guaranteed the hierarchical order
> > of destruction: children were always first. It preserved attached
> > programs from being released before their propagated copies.
> > 
> > But with cgroup auto-detachment there are no such guarantees anymore:
> > cgroup bpf is released as soon as the cgroup is offline and there are
> > no live associated sockets. It means that an attached program can be
> > detached and released, while its propagated copy is still living
> > in the cgroup subtree. This will obviously lead to an use-after-free
> > bug.
> ...
> > @@ -65,6 +65,9 @@ static void cgroup_bpf_release(struct work_struct *work)
> >  
> >  	mutex_unlock(&cgroup_mutex);
> >  
> > +	for (p = cgroup_parent(cgrp); p; p = cgroup_parent(p))
> > +		cgroup_bpf_put(p);
> > +
> 
> The fix makes sense, but is it really safe to walk cgroup hierarchy
> without holding cgroup_mutex?

It is, because we're holding a reference to the original cgroup and going
towards the root. On each level the cgroup is protected by a reference
from their child cgroup.

Thanks!

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ