[<prev] [next>] [day] [month] [year] [list]
Message-ID: <CA+55aFyr56yHSzWA77-+P4hm2nzUgx0cea7Zk8YD0YqJv1W43w@mail.gmail.com>
Date: Tue, 16 Feb 2016 16:28:46 -0800
From: Linus Torvalds <torvalds@...ux-foundation.org>
To: Arjan van de Ven <arjan@...ux.intel.com>
Cc: james.morse@....com, salyzyn@...roid.com,
"linux-arm-kernel@...ts.infradead.org"
<linux-arm-kernel@...ts.infradead.org>,
"vladimir.murzin@....com" <vladimir.murzin@....com>,
Will Deacon <will.deacon@....com>,
Robin Murphy <robin.murphy@....com>,
"riandrews@...roid.com" <riandrews@...roid.com>,
Peter Anvin <hpa@...or.com>,
"Dave.Martin@....com" <Dave.Martin@....com>,
EunTaik Lee <eun.taik.lee@...sung.com>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"suzuki.poulose@....com" <suzuki.poulose@....com>,
Catalin Marinas <catalin.marinas@....com>,
Peter Zijlstra <peterz@...radead.org>
Subject: Re: [PATCH v2] arm64: add alignment fault hanling
On Tue, Feb 16, 2016 at 1:42 PM, Linus Torvalds
<torvalds@...ux-foundation.org> wrote:
>
> On Feb 16, 2016 1:31 PM, "Arjan van de Ven" <arjan@...ux.intel.com> wrote:
>>
>> but what happens to the read if the page isn't present?
>> or is execute-only or .. or ..
>
> If we actually get a fault and handle the exception (not handling the
> exception was the problem on arm), the exception code will just cut off the
> pathname at the page boundary.
>
> So it will see the accessible part, and get zeroes for the inaccessible one.
Actually, looking closer, we only do that for the kernel case (where
pagealloc-debug can cause the unaligned path component in *kernel*
space to trap).
I misremembered because I considered doing it for user accesses too,
but as Catalin correctly says, there we don't actually end up being
that clever, and we just fall back to byte-at-a-time. Which means that
we do get the exact EFAULT behavior even though I'm not 100% convinced
we need to.
See the use of "load_unaligned_zeropad()" (in the dcache handling) vs
just "get_user()" (in strncpy_from_user()).
The fault case doesn't actually ever happen in practice.
The IS_UNALIGNED() case (on architectures with inefficient unaligned
handling), which also falls back to the byte-at-a-time model, is
likely a much bigger problem. They probably need their own strncpy if
they care about performance. But the common architectures all happily
do efficient unaligneds these days.
Linus
Powered by blists - more mailing lists