[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Zw_yHEJCBwtYFJoR@slm.duckdns.org>
Date: Wed, 16 Oct 2024 07:04:28 -1000
From: Tejun Heo <tj@...nel.org>
To: Michal Koutný <mkoutny@...e.com>
Cc: Chen Ridong <chenridong@...weicloud.com>, lizefan.x@...edance.com,
hannes@...xchg.org, longman@...hat.com, john.fastabend@...il.com,
roman.gushchin@...ux.dev, quanyang.wang@...driver.com,
ast@...nel.org, cgroups@...r.kernel.org,
linux-kernel@...r.kernel.org, bpf@...r.kernel.org,
chenridong@...wei.com, wangweiyang2@...wei.com
Subject: Re: [PATCH] cgroup/bpf: fix NULL pointer dereference at
cgroup_bpf_offline
On Wed, Oct 16, 2024 at 03:13:52PM +0200, Michal Koutný wrote:
> Hello.
>
> On Wed, Oct 16, 2024 at 09:36:33AM GMT, Chen Ridong <chenridong@...weicloud.com> wrote:
> > As mentioned above, when cgroup_bpf_inherit returns an error in
> > cgroup_setup_root, cgrp->bpf.refcnt has been exited. If cgrp->bpf.refcnt is
> > killed again in the cgroup_kill_sb function, the data of cgrp->bpf.refcnt
> > may have become NULL, leading to NULL pointer dereference.
> >
> > To fix this issue, goto err when cgroup_bpf_inherit returns an error.
> > Additionally, if cgroup_bpf_inherit returns an error after rebinding
> > subsystems, the root_cgrp->self.refcnt is exited, which leads to
> > cgroup1_root_to_use return 1 (restart) when subsystems is mounted next.
> > This is due to a failure trying to get the refcnt(the root is root_cgrp,
> > without rebinding back to cgrp_dfl_root). So move the call to
> > cgroup_bpf_inherit above rebind_subsystems in the cgroup_setup_root.
> >
> > Fixes: 04f8ef5643bc ("cgroup: Fix memory leak caused by missing cgroup_bpf_offline")
> > Signed-off-by: Chen Ridong <chenridong@...wei.com>
>
> Hm, I always thought that BPF progs can only be attached to the default
> hierarchy (cgroup_bpf_prog_attach/cgroup_get_from_fd should prevent
> that).
>
> Thus I wonder whether cgroup_bpf_inherit (which is more like
> cgroup_bpf_init in this case) needs to be called no v1 roots at all (and
> with such a change, 04f8ef5643bc could be effectively reverted too).
>
> Or can bpf data be used on v1 hierarchies somehow?
We relaxed some of the usages (see cgroup_v1v2_get_from_fd()) but cgroup BPF
progs can only be attached to v2.
Thanks.
--
tejun
Powered by blists - more mailing lists