On Tue, Mar 29, 2022 at 2:58 AM Marco Elver <elver@xxxxxxxxxx> wrote: > > On Mon, 28 Mar 2022 at 17:54, Muchun Song <songmuchun@xxxxxxxxxxxxx> wrote: > [...] > > > > > > > > Btw, how did you test this? > > > > > > > > I have tested it with syzkaller with the following configs. > > And I didn't find any issues. > > > > CONFIG_KFENCE=y > > CONFIG_KFENCE_SAMPLE_INTERVAL=10 > > CONFIG_KFENCE_NUM_OBJECTS=2550 > > CONFIG_KFENCE_DEFERRABLE=n > > CONFIG_KFENCE_STATIC_KEYS=y > > CONFIG_KFENCE_STRESS_TEST_FAULTS=0 > > Hmm, I would have expected that you have some definitive test case > that shows the issue, and with the patch the issue is gone. Were there > issues triggered by syzkaller w/o this patch? > I have tested this patch with the following patch and without this patch. Then we'll see the BUG_ON meaning both objcg vector and object are allocated from kfence pool. diff --git a/mm/slab.h b/mm/slab.h index c7f2abc2b154..1d8d15522a2e 100644 --- a/mm/slab.h +++ b/mm/slab.h @@ -519,6 +519,8 @@ static inline void memcg_slab_post_alloc_hook(struct kmem_cache *s, continue; } + BUG_ON(is_kfence_address(p[i]) && is_kfence_address(slab_objcgs(slab))); + off = obj_to_index(s, slab, p[i]); obj_cgroup_get(objcg); slab_objcgs(slab)[off] = objcg;