Subject: [PATCH v2 5/5] arm64: kernel: Don't toggle PAN on systems with UAO

From: [email-masked] (James Morse)
Date: Thu, 18 Feb 2016 14:43:48 +0000

Hi Catalin,

On 18/02/16 14:36, Catalin Marinas wrote:
> On Fri, Feb 05, 2016 at 02:58:50PM +0000, James Morse wrote:
>> --- a/arch/arm64/mm/fault.c
>> +++ b/arch/arm64/mm/fault.c
>> @@ -234,6 +234,9 @@ static int __kprobes do_page_fault(unsigned long addr, unsigned int esr,
>>  	}
>>  
>>  	if (permission_fault(esr) && (addr < USER_DS)) {
>> +		if (get_thread_info(regs->sp)->addr_limit == KERNEL_DS)
>> +			panic("Accessing user space memory with fs=KERNEL_DS");
> 
> We could simply use "get_fs() == KERNEL_DS" as we should call
> do_page_fault() outside the current context.

shouldn't?

You're right, it will always be on the same stack, so get_fs() will give us the
right result. This fits better with getting rid of the new get_thread_info() in
patch 3.

Thanks,

James