This is a follow-up to patches from zhonjiang [0] and myself [1] that aim
to solve a problem in the kcore code, which gets confused by the presence
of block mappings in the vmalloc region.
While fixing the crash is quite straight forward [2], we need to tweak
the kcore code itself to ensure that it operates correctly on arm64.
Fortunately, we can achieve this with two very simple changes:
- replace a call to is_vmalloc_or_module_addr() in read_kcore() with a
comparison of the kclist type field (#1)
- enable CONFIG_ARCH_PROC_KCORE_TEXT for arm64 (#2)
[0] http://marc.info/?l=linux-mm&m=149632393629295&w=2
[1] http://marc.info/?l=linux-mm&m=149685966530180&w=2
[2] http://marc.info/?l=linux-mm&m=149694975123959&w=2
Ard Biesheuvel (2):
fs/proc: kcore: use kcore_list type to check for vmalloc/module
address
arm64: mm: select CONFIG_ARCH_PROC_KCORE_TEXT
arch/arm64/Kconfig | 3 +++
fs/proc/kcore.c | 2 +-
2 files changed, 4 insertions(+), 1 deletion(-)
--
2.9.3
Instead of passing each start address into is_vmalloc_or_module_addr()
to decide whether it falls into either the VMALLOC or the MODULES region,
we can simply check the type field of the current kcore_list entry, since
it will be set to KCORE_VMALLOC based on exactly the same conditions.
As a bonus, when reading the KCORE_TEXT region on architectures that have
one, this will avoid using vread() on the region if it happens to intersect
with a KCORE_VMALLOC region. This is due the fact that the KCORE_TEXT
region is the first one to be added to the kcore region list.
Signed-off-by: Ard Biesheuvel <redacted>
---
fs/proc/kcore.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
@@ -504,7 +504,7 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)if(&m->list==&kclist_head){if(clear_user(buffer,tsz))return-EFAULT;-}elseif(is_vmalloc_or_module_addr((void*)start)){+}elseif(m->type==KCORE_VMALLOC){vread(buf,(char*)start,tsz);/* we have to zero-fill user buffer even if no read */if(copy_to_user(buffer,buf,tsz))
To avoid issues with the /proc/kcore code getting confused about the
kernels block mappings in the VMALLOC region, enable the existing
facility that describes the [_text, _end) interval as a separate
KCORE_TEXT region, which supersedes the KCORE_VMALLOC region that
it intersects with on arm64.
Signed-off-by: Ard Biesheuvel <redacted>
---
arch/arm64/Kconfig | 3 +++
1 file changed, 3 insertions(+)
From: Mark Rutland <mark.rutland@arm.com> Date: 2017-06-09 10:01:17
On Thu, Jun 08, 2017 at 07:41:37PM +0000, Ard Biesheuvel wrote:
This is a follow-up to patches from zhonjiang [0] and myself [1] that aim
to solve a problem in the kcore code, which gets confused by the presence
of block mappings in the vmalloc region.
While fixing the crash is quite straight forward [2], we need to tweak
the kcore code itself to ensure that it operates correctly on arm64.
Fortunately, we can achieve this with two very simple changes:
- replace a call to is_vmalloc_or_module_addr() in read_kcore() with a
comparison of the kclist type field (#1)
- enable CONFIG_ARCH_PROC_KCORE_TEXT for arm64 (#2)
From: Laura Abbott <hidden> Date: 2017-06-09 18:05:09
On 06/08/2017 12:41 PM, Ard Biesheuvel wrote:
This is a follow-up to patches from zhonjiang [0] and myself [1] that aim
to solve a problem in the kcore code, which gets confused by the presence
of block mappings in the vmalloc region.
While fixing the crash is quite straight forward [2], we need to tweak
the kcore code itself to ensure that it operates correctly on arm64.
Fortunately, we can achieve this with two very simple changes:
- replace a call to is_vmalloc_or_module_addr() in read_kcore() with a
comparison of the kclist type field (#1)
- enable CONFIG_ARCH_PROC_KCORE_TEXT for arm64 (#2)
[0] http://marc.info/?l=linux-mm&m=149632393629295&w=2
[1] http://marc.info/?l=linux-mm&m=149685966530180&w=2
[2] http://marc.info/?l=linux-mm&m=149694975123959&w=2
Ard Biesheuvel (2):
fs/proc: kcore: use kcore_list type to check for vmalloc/module
address
arm64: mm: select CONFIG_ARCH_PROC_KCORE_TEXT
arch/arm64/Kconfig | 3 +++
fs/proc/kcore.c | 2 +-
2 files changed, 4 insertions(+), 1 deletion(-)
Reviewed-by: Laura Abbott <redacted>
I wish there was actual Kconfig help text for CONFIG_ARCH_PROC_KCORE_TEXT
instead of having to go into kcore.c to read about how it was used but
that can be fixed up separately.
Thanks,
Laura
From: Tan Xiaojun <hidden> Date: 2017-06-13 02:00:30
On 2017/6/9 3:41, Ard Biesheuvel wrote:
This is a follow-up to patches from zhonjiang [0] and myself [1] that aim
to solve a problem in the kcore code, which gets confused by the presence
of block mappings in the vmalloc region.
While fixing the crash is quite straight forward [2], we need to tweak
the kcore code itself to ensure that it operates correctly on arm64.
Fortunately, we can achieve this with two very simple changes:
- replace a call to is_vmalloc_or_module_addr() in read_kcore() with a
comparison of the kclist type field (#1)
- enable CONFIG_ARCH_PROC_KCORE_TEXT for arm64 (#2)
[0] http://marc.info/?l=linux-mm&m=149632393629295&w=2
[1] http://marc.info/?l=linux-mm&m=149685966530180&w=2
[2] http://marc.info/?l=linux-mm&m=149694975123959&w=2
Ard Biesheuvel (2):
fs/proc: kcore: use kcore_list type to check for vmalloc/module
address
arm64: mm: select CONFIG_ARCH_PROC_KCORE_TEXT
arch/arm64/Kconfig | 3 +++
fs/proc/kcore.c | 2 +-
2 files changed, 4 insertions(+), 1 deletion(-)
Reported-by: Tan Xiaojun <redacted>
Tested-by: Tan Xiaojun <redacted>
Thank you for working on this problem which I reported two months ago.
https://patchwork.kernel.org/patch/9687319/
I tested, and it really solved the problem in Hisilicon D02/D03/D05.
Thanks.
Xiaojun.
On 13 June 2017 at 04:00, Tan Xiaojun [off-list ref] wrote:
On 2017/6/9 3:41, Ard Biesheuvel wrote:
quoted
This is a follow-up to patches from zhonjiang [0] and myself [1] that aim
to solve a problem in the kcore code, which gets confused by the presence
of block mappings in the vmalloc region.
While fixing the crash is quite straight forward [2], we need to tweak
the kcore code itself to ensure that it operates correctly on arm64.
Fortunately, we can achieve this with two very simple changes:
- replace a call to is_vmalloc_or_module_addr() in read_kcore() with a
comparison of the kclist type field (#1)
- enable CONFIG_ARCH_PROC_KCORE_TEXT for arm64 (#2)
[0] http://marc.info/?l=linux-mm&m=149632393629295&w=2
[1] http://marc.info/?l=linux-mm&m=149685966530180&w=2
[2] http://marc.info/?l=linux-mm&m=149694975123959&w=2
Ard Biesheuvel (2):
fs/proc: kcore: use kcore_list type to check for vmalloc/module
address
arm64: mm: select CONFIG_ARCH_PROC_KCORE_TEXT
arch/arm64/Kconfig | 3 +++
fs/proc/kcore.c | 2 +-
2 files changed, 4 insertions(+), 1 deletion(-)
Reported-by: Tan Xiaojun <redacted>
Tested-by: Tan Xiaojun <redacted>
Thank you for working on this problem which I reported two months ago.
https://patchwork.kernel.org/patch/9687319/
I tested, and it really solved the problem in Hisilicon D02/D03/D05.
Thank you.
fs/proc/kcore.c does not have a maintainer according to
get_maintainer.pl but it would be nice if we could get an ack on patch
#1 from someone who is not a usual ARM suspect.
Patch #1 is here:
http://marc.info/?l=linux-kernel&m=149695092424288&w=2
Ingo, Andrew, Jiri, any objections?
From: Jiri Olsa <hidden> Date: 2017-06-13 14:06:32
On Tue, Jun 13, 2017 at 09:17:49AM +0200, Ard Biesheuvel wrote:
On 13 June 2017 at 04:00, Tan Xiaojun [off-list ref] wrote:
quoted
On 2017/6/9 3:41, Ard Biesheuvel wrote:
quoted
This is a follow-up to patches from zhonjiang [0] and myself [1] that aim
to solve a problem in the kcore code, which gets confused by the presence
of block mappings in the vmalloc region.
While fixing the crash is quite straight forward [2], we need to tweak
the kcore code itself to ensure that it operates correctly on arm64.
Fortunately, we can achieve this with two very simple changes:
- replace a call to is_vmalloc_or_module_addr() in read_kcore() with a
comparison of the kclist type field (#1)
- enable CONFIG_ARCH_PROC_KCORE_TEXT for arm64 (#2)
[0] http://marc.info/?l=linux-mm&m=149632393629295&w=2
[1] http://marc.info/?l=linux-mm&m=149685966530180&w=2
[2] http://marc.info/?l=linux-mm&m=149694975123959&w=2
Ard Biesheuvel (2):
fs/proc: kcore: use kcore_list type to check for vmalloc/module
address
arm64: mm: select CONFIG_ARCH_PROC_KCORE_TEXT
arch/arm64/Kconfig | 3 +++
fs/proc/kcore.c | 2 +-
2 files changed, 4 insertions(+), 1 deletion(-)
Reported-by: Tan Xiaojun <redacted>
Tested-by: Tan Xiaojun <redacted>
Thank you for working on this problem which I reported two months ago.
https://patchwork.kernel.org/patch/9687319/
I tested, and it really solved the problem in Hisilicon D02/D03/D05.
Thank you.
fs/proc/kcore.c does not have a maintainer according to
get_maintainer.pl but it would be nice if we could get an ack on patch
#1 from someone who is not a usual ARM suspect.
Patch #1 is here:
http://marc.info/?l=linux-kernel&m=149695092424288&w=2
Ingo, Andrew, Jiri, any objections?
hi,
pretty straightforward.. looks ok to me
Reviewed-by: Jiri Olsa <jolsa@kernel.org>
jirka