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@xxxxxxxxxxxxxxx> 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@xxxxxxxxxx> > > 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