[PATCH 3/4] ARM: Support KFENCE for ARM

Kefeng Wang wangkefeng.wang at huawei.com
Wed Aug 25 07:31:45 PDT 2021


On 2021/8/25 21:18, ownia wrote:
> On 2021/8/25 17:21, Kefeng Wang wrote:
>> Add architecture specific implementation details for KFENCE and enable
>> KFENCE on ARM. In particular, this implements the required interface in
>>   <asm/kfence.h>.
>>
>> KFENCE requires that attributes for pages from its memory pool can
>> individually be set. Therefore, force the kfence pool to be mapped
>> at page granularity.
>>
>> Testing this patch using the testcases in kfence_test.c and all passed
>> with or without ARM_LPAE.
>>
>> Signed-off-by: Kefeng Wang <wangkefeng.wang at huawei.com>
...
>> +#endif /* __ASM_ARM_KFENCE_H */
>> diff --git a/arch/arm/mm/fault.c b/arch/arm/mm/fault.c
>> index f7ab6dabe89f..9fa221ffa1b9 100644
>> --- a/arch/arm/mm/fault.c
>> +++ b/arch/arm/mm/fault.c
>> @@ -17,6 +17,7 @@
>>   #include <linux/sched/debug.h>
>>   #include <linux/highmem.h>
>>   #include <linux/perf_event.h>
>> +#include <linux/kfence.h>
>>   
>>   #include <asm/system_misc.h>
>>   #include <asm/system_info.h>
>> @@ -131,10 +132,14 @@ __do_kernel_fault(struct mm_struct *mm, unsigned long addr, unsigned int fsr,
>>   	/*
>>   	 * No handler, we'll have to terminate things with extreme prejudice.
>>   	 */
>> -	if (addr < PAGE_SIZE)
>> +	if (addr < PAGE_SIZE) {
>>   		msg = "NULL pointer dereference";
>> -	else
>> +	} else {
>> +		if (kfence_handle_page_fault(addr, is_write_fault(fsr), regs))
>> +			return;
>> +
>>   		msg = "paging request";
>> +	}
>
> I think here should do some fixup to follow upstream mainline code.

Yes, the fixup is still there, as the cover-letter said,

NOTE:
The context of patch2/3 changes in arch/arm/mm/fault.c is based on link[1],
which make some refactor and cleanup about page fault.

...

[1]https://lore.kernel.org/linux-arm-kernel/20210610123556.171328-1-wangkefeng.wang@huawei.com/

>
>>   
>>   	die_kernel_fault(msg, mm, addr, fsr, regs);
>>   }
> .
>



More information about the linux-arm-kernel mailing list