On Sun, Sep 29, 2024 at 10:05:42AM -0700, Alexei Starovoitov wrote: > On Fri, Sep 27, 2024 at 11:41 AM Namhyung Kim <namhyung@xxxxxxxxxx> wrote: > > > > +__bpf_kfunc struct kmem_cache *bpf_get_kmem_cache(u64 addr) > > +{ > > + struct slab *slab; > > + > > + slab = virt_to_slab((void *)(long)addr); > > + return slab ? slab->slab_cache : NULL; > > +} > > I think this needs more safety guards on 'addr'. > It needs to check the valid range of 'addr' before doing virt_to_slab. Ok, I think we can use virt_addr_valid() for that. Thanks, Namhyung