On Tue, May 12, 2020 at 5:38 AM Walter Wu <walter-zh.wu@xxxxxxxxxxxx> wrote: > > Are you sure it will increase object size? > > I think we overlap kasan_free_meta with the object as well. The only > > case we don't overlap kasan_free_meta with the object are > > SLAB_TYPESAFE_BY_RCU || cache->ctor. But these are rare and it should > > only affect small objects with small redzones. > > And I think now we simply have a bug for these objects, we check > > KASAN_KMALLOC_FREE and then assume object contains free stack, but for > > objects with ctor, they still contain live object data, we don't store > > free stack in them. > > Such objects can be both free and still contain user data. > > > > Overlay kasan_free_meta. I see. but overlay it only when the object was > freed. kasan_free_meta will be used until free object. > 1). When put object into quarantine, it need kasan_free_meta. > 2). When the object exit from quarantine, it need kasan_free_meta > > If we choose to overlay kasan_free_meta, then the free stack will be > stored very late. It may has no free stack in report. Sorry, I don't understand what you mean. Why will it be stored too late? In __kasan_slab_free() putting into quarantine and recording free stack are literally adjacent lines of code: static bool __kasan_slab_free(struct kmem_cache *cache, void *object, unsigned long ip, bool quarantine) { ... kasan_set_free_info(cache, object, tag); quarantine_put(get_free_info(cache, object), cache); Just to make sure, what I meant is that we add free_track to kasan_free_meta: struct kasan_free_meta { struct qlist_node quarantine_link; + struct kasan_track free_track; }; And I think its life-time and everything should be exactly what we need. Also it should help to fix the problem with ctors: kasan_free_meta is already allocated on the side for such objects, and that's exactly what we need for objects with ctor's.