Cc: Roman Gushchin <g...@fb.com>

Thanks for fixing this.

On 2020/6/17 2:03, Cong Wang wrote:
> When we clone a socket in sk_clone_lock(), its sk_cgrp_data is
> copied, so the cgroup refcnt must be taken too. And, unlike the
> sk_alloc() path, sock_update_netprioidx() is not called here.
> Therefore, it is safe and necessary to grab the cgroup refcnt
> even when cgroup_sk_alloc is disabled.
> 
> sk_clone_lock() is in BH context anyway, the in_interrupt()
> would terminate this function if called there. And for sk_alloc()
> skcd->val is always zero. So it's safe to factor out the code
> to make it more readable.
> 
> Fixes: 090e28b229af92dc5b ("netprio_cgroup: Fix unlimited memory leak of v2 
> cgroups")

but I don't think the bug was introduced by this commit, because there
are already calls to cgroup_sk_alloc_disable() in write_priomap() and
write_classid(), which can be triggered by writing to ifpriomap or
classid in cgroupfs. This commit just made it much easier to happen
with systemd invovled.

I think it's 4bfc0bb2c60e2f4c ("bpf: decouple the lifetime of cgroup_bpf from 
cgroup itself"),
which added cgroup_bpf_get() in cgroup_sk_alloc().

> Reported-by: Cameron Berkenpas <c...@neo-zeon.de>
> Reported-by: Peter Geis <pgwipe...@gmail.com>
> Reported-by: Lu Fengqi <lufq.f...@cn.fujitsu.com>
> Reported-by: Daniƫl Sonck <dsonc...@gmail.com>
> Tested-by: Cameron Berkenpas <c...@neo-zeon.de>
> Cc: Daniel Borkmann <dan...@iogearbox.net>
> Cc: Zefan Li <lize...@huawei.com>
> Cc: Tejun Heo <t...@kernel.org>
> Signed-off-by: Cong Wang <xiyou.wangc...@gmail.com>
> ---

Reply via email to