* [PATCH v3] drivers/char: kmem: disable on arm64
@ 2017-06-20 6:59 Ard Biesheuvel
2017-06-20 9:31 ` Mark Rutland
2017-06-20 11:20 ` Ard Biesheuvel
0 siblings, 2 replies; 5+ messages in thread
From: Ard Biesheuvel @ 2017-06-20 6:59 UTC (permalink / raw)
To: linux-arm-kernel
As it turns out, arm64 deviates from other architectures in the way it
maps the VMALLOC region: on most (all?) other architectures, it resides
strictly above the kernel's direct mapping of DRAM, but on arm64, this
is the other way around. For instance, for a 48-bit VA configuration,
we have
modules : 0xffff000000000000 - 0xffff000008000000 ( 128 MB)
vmalloc : 0xffff000008000000 - 0xffff7dffbfff0000 (129022 GB)
...
vmemmap : 0xffff7e0000000000 - 0xffff800000000000 ( 2048 GB maximum)
0xffff7e0000000000 - 0xffff7e0003ff0000 ( 63 MB actual)
memory : 0xffff800000000000 - 0xffff8000ffc00000 ( 4092 MB)
This has mostly gone unnoticed until now, but it does appear that it
breaks an assumption in the kcore read/write code, which does something
like
if (p < (unsigned long) high_memory) {
... use straight copy_[to|from]_user() using p as virtual address ...
}
...
if (count > 0) {
... use vread/vwrite for accesses past high_memory ...
}
The first condition will inadvertently hold for the VMALLOC region if
VMALLOC_START < PAGE_OFFSET [which is the case on arm64], but the read
or write will subsequently fail the virt_addr_valid() check, resulting
in a -ENXIO return value.
Given how kmem seems to be living in borrowed time anyway, and given
the fact that nobody noticed that the read/write interface is broken
on arm64 in the first place, let's not bother trying to fix it, but
simply disable the /dev/kmem interface entirely for arm64.
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
v3: improve commit log
v2: disable /dev/kmem entirely rather than bandaiding it
drivers/char/Kconfig | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig
index 31adbebf812e..8102ee7b3247 100644
--- a/drivers/char/Kconfig
+++ b/drivers/char/Kconfig
@@ -17,6 +17,8 @@ config DEVMEM
config DEVKMEM
bool "/dev/kmem virtual device support"
+ # On arm64, VMALLOC_START < PAGE_OFFSET, which confuses kmem read/write
+ depends on !ARM64
help
Say Y here if you want to support the /dev/kmem device. The
/dev/kmem device is rarely used, but can be used for certain
--
2.7.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v3] drivers/char: kmem: disable on arm64
2017-06-20 6:59 [PATCH v3] drivers/char: kmem: disable on arm64 Ard Biesheuvel
@ 2017-06-20 9:31 ` Mark Rutland
2017-06-20 11:20 ` Ard Biesheuvel
1 sibling, 0 replies; 5+ messages in thread
From: Mark Rutland @ 2017-06-20 9:31 UTC (permalink / raw)
To: linux-arm-kernel
On Tue, Jun 20, 2017 at 08:59:00AM +0200, Ard Biesheuvel wrote:
> As it turns out, arm64 deviates from other architectures in the way it
> maps the VMALLOC region: on most (all?) other architectures, it resides
> strictly above the kernel's direct mapping of DRAM, but on arm64, this
> is the other way around. For instance, for a 48-bit VA configuration,
> we have
>
> modules : 0xffff000000000000 - 0xffff000008000000 ( 128 MB)
> vmalloc : 0xffff000008000000 - 0xffff7dffbfff0000 (129022 GB)
> ...
> vmemmap : 0xffff7e0000000000 - 0xffff800000000000 ( 2048 GB maximum)
> 0xffff7e0000000000 - 0xffff7e0003ff0000 ( 63 MB actual)
> memory : 0xffff800000000000 - 0xffff8000ffc00000 ( 4092 MB)
>
> This has mostly gone unnoticed until now, but it does appear that it
> breaks an assumption in the kcore read/write code, which does something
> like
>
> if (p < (unsigned long) high_memory) {
> ... use straight copy_[to|from]_user() using p as virtual address ...
> }
> ...
> if (count > 0) {
> ... use vread/vwrite for accesses past high_memory ...
> }
>
> The first condition will inadvertently hold for the VMALLOC region if
> VMALLOC_START < PAGE_OFFSET [which is the case on arm64], but the read
> or write will subsequently fail the virt_addr_valid() check, resulting
> in a -ENXIO return value.
>
> Given how kmem seems to be living in borrowed time anyway, and given
> the fact that nobody noticed that the read/write interface is broken
> on arm64 in the first place, let's not bother trying to fix it, but
> simply disable the /dev/kmem interface entirely for arm64.
>
> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
FWIW:
Acked-by: Mark Rutland <mark.rutland@arm.com>
Mark.
> ---
> v3: improve commit log
> v2: disable /dev/kmem entirely rather than bandaiding it
>
> drivers/char/Kconfig | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig
> index 31adbebf812e..8102ee7b3247 100644
> --- a/drivers/char/Kconfig
> +++ b/drivers/char/Kconfig
> @@ -17,6 +17,8 @@ config DEVMEM
>
> config DEVKMEM
> bool "/dev/kmem virtual device support"
> + # On arm64, VMALLOC_START < PAGE_OFFSET, which confuses kmem read/write
> + depends on !ARM64
> help
> Say Y here if you want to support the /dev/kmem device. The
> /dev/kmem device is rarely used, but can be used for certain
> --
> 2.7.4
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v3] drivers/char: kmem: disable on arm64
2017-06-20 6:59 [PATCH v3] drivers/char: kmem: disable on arm64 Ard Biesheuvel
2017-06-20 9:31 ` Mark Rutland
@ 2017-06-20 11:20 ` Ard Biesheuvel
2017-07-17 14:18 ` gregkh at linuxfoundation.org
1 sibling, 1 reply; 5+ messages in thread
From: Ard Biesheuvel @ 2017-06-20 11:20 UTC (permalink / raw)
To: linux-arm-kernel
On 20 June 2017 at 08:59, Ard Biesheuvel <ard.biesheuvel@linaro.org> wrote:
> As it turns out, arm64 deviates from other architectures in the way it
> maps the VMALLOC region: on most (all?) other architectures, it resides
> strictly above the kernel's direct mapping of DRAM, but on arm64, this
> is the other way around. For instance, for a 48-bit VA configuration,
> we have
>
> modules : 0xffff000000000000 - 0xffff000008000000 ( 128 MB)
> vmalloc : 0xffff000008000000 - 0xffff7dffbfff0000 (129022 GB)
> ...
> vmemmap : 0xffff7e0000000000 - 0xffff800000000000 ( 2048 GB maximum)
> 0xffff7e0000000000 - 0xffff7e0003ff0000 ( 63 MB actual)
> memory : 0xffff800000000000 - 0xffff8000ffc00000 ( 4092 MB)
>
> This has mostly gone unnoticed until now, but it does appear that it
> breaks an assumption in the kcore
s/kcore/kmem/
> read/write code, which does something
> like
>
> if (p < (unsigned long) high_memory) {
> ... use straight copy_[to|from]_user() using p as virtual address ...
> }
> ...
> if (count > 0) {
> ... use vread/vwrite for accesses past high_memory ...
> }
>
> The first condition will inadvertently hold for the VMALLOC region if
> VMALLOC_START < PAGE_OFFSET [which is the case on arm64], but the read
> or write will subsequently fail the virt_addr_valid() check, resulting
> in a -ENXIO return value.
>
> Given how kmem seems to be living in borrowed time anyway, and given
> the fact that nobody noticed that the read/write interface is broken
> on arm64 in the first place, let's not bother trying to fix it, but
> simply disable the /dev/kmem interface entirely for arm64.
>
> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> ---
> v3: improve commit log
> v2: disable /dev/kmem entirely rather than bandaiding it
>
> drivers/char/Kconfig | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig
> index 31adbebf812e..8102ee7b3247 100644
> --- a/drivers/char/Kconfig
> +++ b/drivers/char/Kconfig
> @@ -17,6 +17,8 @@ config DEVMEM
>
> config DEVKMEM
> bool "/dev/kmem virtual device support"
> + # On arm64, VMALLOC_START < PAGE_OFFSET, which confuses kmem read/write
> + depends on !ARM64
> help
> Say Y here if you want to support the /dev/kmem device. The
> /dev/kmem device is rarely used, but can be used for certain
> --
> 2.7.4
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v3] drivers/char: kmem: disable on arm64
2017-06-20 11:20 ` Ard Biesheuvel
@ 2017-07-17 14:18 ` gregkh at linuxfoundation.org
2017-07-17 17:04 ` Ard Biesheuvel
0 siblings, 1 reply; 5+ messages in thread
From: gregkh at linuxfoundation.org @ 2017-07-17 14:18 UTC (permalink / raw)
To: linux-arm-kernel
On Tue, Jun 20, 2017 at 01:20:49PM +0200, Ard Biesheuvel wrote:
> On 20 June 2017 at 08:59, Ard Biesheuvel <ard.biesheuvel@linaro.org> wrote:
> > As it turns out, arm64 deviates from other architectures in the way it
> > maps the VMALLOC region: on most (all?) other architectures, it resides
> > strictly above the kernel's direct mapping of DRAM, but on arm64, this
> > is the other way around. For instance, for a 48-bit VA configuration,
> > we have
> >
> > modules : 0xffff000000000000 - 0xffff000008000000 ( 128 MB)
> > vmalloc : 0xffff000008000000 - 0xffff7dffbfff0000 (129022 GB)
> > ...
> > vmemmap : 0xffff7e0000000000 - 0xffff800000000000 ( 2048 GB maximum)
> > 0xffff7e0000000000 - 0xffff7e0003ff0000 ( 63 MB actual)
> > memory : 0xffff800000000000 - 0xffff8000ffc00000 ( 4092 MB)
> >
> > This has mostly gone unnoticed until now, but it does appear that it
> > breaks an assumption in the kcore
>
> s/kcore/kmem/
v4? :)
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v3] drivers/char: kmem: disable on arm64
2017-07-17 14:18 ` gregkh at linuxfoundation.org
@ 2017-07-17 17:04 ` Ard Biesheuvel
0 siblings, 0 replies; 5+ messages in thread
From: Ard Biesheuvel @ 2017-07-17 17:04 UTC (permalink / raw)
To: linux-arm-kernel
On 17 July 2017 at 15:18, gregkh at linuxfoundation.org
<gregkh@linuxfoundation.org> wrote:
> On Tue, Jun 20, 2017 at 01:20:49PM +0200, Ard Biesheuvel wrote:
>> On 20 June 2017 at 08:59, Ard Biesheuvel <ard.biesheuvel@linaro.org> wrote:
>> > As it turns out, arm64 deviates from other architectures in the way it
>> > maps the VMALLOC region: on most (all?) other architectures, it resides
>> > strictly above the kernel's direct mapping of DRAM, but on arm64, this
>> > is the other way around. For instance, for a 48-bit VA configuration,
>> > we have
>> >
>> > modules : 0xffff000000000000 - 0xffff000008000000 ( 128 MB)
>> > vmalloc : 0xffff000008000000 - 0xffff7dffbfff0000 (129022 GB)
>> > ...
>> > vmemmap : 0xffff7e0000000000 - 0xffff800000000000 ( 2048 GB maximum)
>> > 0xffff7e0000000000 - 0xffff7e0003ff0000 ( 63 MB actual)
>> > memory : 0xffff800000000000 - 0xffff8000ffc00000 ( 4092 MB)
>> >
>> > This has mostly gone unnoticed until now, but it does appear that it
>> > breaks an assumption in the kcore
>>
>> s/kcore/kmem/
>
> v4? :)
>
This is already in mainline as 06c35ef1fdf8d955684448683f7e48ac5f15ccfd
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2017-07-17 17:04 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-06-20 6:59 [PATCH v3] drivers/char: kmem: disable on arm64 Ard Biesheuvel
2017-06-20 9:31 ` Mark Rutland
2017-06-20 11:20 ` Ard Biesheuvel
2017-07-17 14:18 ` gregkh at linuxfoundation.org
2017-07-17 17:04 ` Ard Biesheuvel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).