Re: [RFC PATCH] Introduce sysfs interface to disable kfence for selected slabs.

From: Imran Khan
Date: Thu Aug 11 2022 - 05:05:08 EST


Hello,

On 11/8/22 6:40 pm, Marco Elver wrote:
> On Thu, 11 Aug 2022 at 09:26, Imran Khan <imran.f.khan@xxxxxxxxxx> wrote:
>>
>> By default kfence allocation can happen for any slab object, whose size
>> is up to PAGE_SIZE, as long as that allocation is the first allocation
>> after expiration of kfence sample interval. But in certain debugging
>> scenarios we may be interested in debugging corruptions involving
>> some specific slub objects like dentry or ext4_* etc. In such cases
>> limiting kfence for allocations involving only specific slub objects
>> will increase the probablity of catching the issue since kfence pool
>> will not be consumed by other slab objects.
>>
>> This patch introduces a sysfs interface '/sys/kernel/slab/<name>/skip_kfence'
>> to disable kfence for specific slabs. Having the interface work in this
>> way does not impact current/default behavior of kfence and allows us to
>> use kfence for specific slabs (when needed) as well. The decision to
>> skip/use kfence is taken depending on whether kmem_cache.flags has
>> (newly introduced) SLAB_SKIP_KFENCE flag set or not.
>>
>> Signed-off-by: Imran Khan <imran.f.khan@xxxxxxxxxx>
>> ---
>>
>> This RFC patch is implementing the sysfs work mentioned in [1]. Since the
>> approach taken in [1] was not proper, I am sending this RFC patch as a
>> separate change.
>
> This design is much simpler and looks good to me. Feel free to send as
> a non-RFC.
>

Thanks for reviewing this. I have sent non-RFC version of this change.

Thanks,
-- Imran