All of lore.kernel.org
 help / color / mirror / Atom feed
From: wangkefeng.wang@huawei.com (Kefeng Wang)
To: linux-arm-kernel@lists.infradead.org
Subject: [Question] Crash when cat /dev/kmem in arm/arm64 but not in x86
Date: Mon, 30 May 2016 15:33:52 +0800	[thread overview]
Message-ID: <574BECE0.9070105@huawei.com> (raw)

Hi all,

When cat /dev/kmem in arm/arm64, it will crash, this is caused by "from = 0"
in copy_to_user(void __user *to, const void *from, unsigned long n),
call trace shows below(eg, arm64)

[    9.913370] Unable to handle kernel NULL pointer dereference at virtual address 00000000
[    9.914391] pgd = ffff800008345000
[    9.914976] [00000000] *pgd=00000000482bb003, *pud=00000000f69b4003, *pmd=0000000000000000
[    9.918036] Internal error: Oops: 96000006 [#1] PREEMPT SMP
[    9.918683] Modules linked in:
[    9.919413] CPU: 6 PID: 1021 Comm: cat Not tainted 4.6.0+ #80
[    9.920410] Hardware name: linux,dummy-virt (DT)
[    9.921003] task: ffff8000b6448000 ti: ffff8000083b0000 task.ti: ffff8000083b0000
[    9.922356] PC is at __copy_to_user+0x180/0x280
[    9.922847] LR is at read_kmem+0x200/0x220
[    9.923265] pc : [<ffff000008339500>] lr : [<ffff000008473168>] pstate: 20000145
[    9.923988] sp : ffff8000083b3d60
[    9.924670] x29: ffff8000083b3d60 x28: 0000000000001000
[    9.925420] x27: 0000000000001000 x26: ffff8000083b3ec8
[    9.926039] x25: ffff8000083b0000 x24: ffff000008a20638
[    9.926810] x23: 0000000000001000 x22: 0000ffffe4dac550
[    9.927668] x21: 0000000000000000 x20: 0000000000001000
[    9.928771] x19: 0000000000000000 x18: 0000ffffe4dab240
[    9.929494] x17: 0000000000497458 x16: ffff0000081bc098
[    9.930162] x15: ffffffffffffffff x14: ff00000000000000
[    9.930857] x13: ffffffffffffffff x12: 0000000000000038
[    9.931629] x11: 00000000000000c7 x10: 0000000000000006
[    9.932649] x9 : 0000000000000006 x8 : 207a73202c296c6c
[    9.933356] x7 : 756e282020202020 x6 : 0000ffffe4dab550
[    9.934050] x5 : 0000ffffe4dac550 x4 : 0000000000000000
[    9.934801] x3 : 0000000000000000 x2 : 0000000000000f80
[    9.935601] x1 : 0000000000000000 x0 : 0000ffffe4dab550


but in x86, cat /dev/kmem, will just return "Bad address". After check the x86 code,
copy_to_user ->  _copy_to_user(copy_user_64.S, fixup) -> copy_user_handle_tail (will return len > 0),
then the copy_to_user() will return -EFAULT, the fixup_exception will deal with this situation,
so does the arm/arm64 need the same mechanism to deal with it too?

Thanks
Kefeng

WARNING: multiple messages have this Message-ID (diff)
From: Kefeng Wang <wangkefeng.wang@huawei.com>
To: Catalin Marinas <catalin.marinas@arm.com>,
	Will Deacon <will.deacon@arm.com>,
	Russell King <linux@armlinux.org.uk>,
	Arnd Bergmann <arnd@arndb.de>
Cc: <chenweilong@huawei.com>,
	"Guohanjun (Hanjun Guo)" <guohanjun@huawei.com>,
	Li Bin <huawei.libin@huawei.com>, <wangkefeng.wang@huawei.com>,
	<linux-arm-kernel@lists.infradead.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: [Question] Crash when cat /dev/kmem in arm/arm64 but not in x86
Date: Mon, 30 May 2016 15:33:52 +0800	[thread overview]
Message-ID: <574BECE0.9070105@huawei.com> (raw)

Hi all,

When cat /dev/kmem in arm/arm64, it will crash, this is caused by "from = 0"
in copy_to_user(void __user *to, const void *from, unsigned long n),
call trace shows below(eg, arm64)

[    9.913370] Unable to handle kernel NULL pointer dereference at virtual address 00000000
[    9.914391] pgd = ffff800008345000
[    9.914976] [00000000] *pgd=00000000482bb003, *pud=00000000f69b4003, *pmd=0000000000000000
[    9.918036] Internal error: Oops: 96000006 [#1] PREEMPT SMP
[    9.918683] Modules linked in:
[    9.919413] CPU: 6 PID: 1021 Comm: cat Not tainted 4.6.0+ #80
[    9.920410] Hardware name: linux,dummy-virt (DT)
[    9.921003] task: ffff8000b6448000 ti: ffff8000083b0000 task.ti: ffff8000083b0000
[    9.922356] PC is at __copy_to_user+0x180/0x280
[    9.922847] LR is at read_kmem+0x200/0x220
[    9.923265] pc : [<ffff000008339500>] lr : [<ffff000008473168>] pstate: 20000145
[    9.923988] sp : ffff8000083b3d60
[    9.924670] x29: ffff8000083b3d60 x28: 0000000000001000
[    9.925420] x27: 0000000000001000 x26: ffff8000083b3ec8
[    9.926039] x25: ffff8000083b0000 x24: ffff000008a20638
[    9.926810] x23: 0000000000001000 x22: 0000ffffe4dac550
[    9.927668] x21: 0000000000000000 x20: 0000000000001000
[    9.928771] x19: 0000000000000000 x18: 0000ffffe4dab240
[    9.929494] x17: 0000000000497458 x16: ffff0000081bc098
[    9.930162] x15: ffffffffffffffff x14: ff00000000000000
[    9.930857] x13: ffffffffffffffff x12: 0000000000000038
[    9.931629] x11: 00000000000000c7 x10: 0000000000000006
[    9.932649] x9 : 0000000000000006 x8 : 207a73202c296c6c
[    9.933356] x7 : 756e282020202020 x6 : 0000ffffe4dab550
[    9.934050] x5 : 0000ffffe4dac550 x4 : 0000000000000000
[    9.934801] x3 : 0000000000000000 x2 : 0000000000000f80
[    9.935601] x1 : 0000000000000000 x0 : 0000ffffe4dab550


but in x86, cat /dev/kmem, will just return "Bad address". After check the x86 code,
copy_to_user ->  _copy_to_user(copy_user_64.S, fixup) -> copy_user_handle_tail (will return len > 0),
then the copy_to_user() will return -EFAULT, the fixup_exception will deal with this situation,
so does the arm/arm64 need the same mechanism to deal with it too?

Thanks
Kefeng

             reply	other threads:[~2016-05-30  7:33 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-30  7:33 Kefeng Wang [this message]
2016-05-30  7:33 ` [Question] Crash when cat /dev/kmem in arm/arm64 but not in x86 Kefeng Wang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=574BECE0.9070105@huawei.com \
    --to=wangkefeng.wang@huawei.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.