From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
stable@vger.kernel.org, Mark Rutland <mark.rutland@arm.com>,
Russell King <rmk+kernel@armlinux.org.uk>
Subject: [PATCH 4.13 12/33] ARM: 8720/1: ensure dump_instr() checks addr_limit
Date: Mon, 13 Nov 2017 13:56:33 +0100 [thread overview]
Message-ID: <20171113125612.340096529@linuxfoundation.org> (raw)
In-Reply-To: <20171113125611.096767733@linuxfoundation.org>
4.13-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mark Rutland <mark.rutland@arm.com>
commit b9dd05c7002ee0ca8b676428b2268c26399b5e31 upstream.
When CONFIG_DEBUG_USER is enabled, it's possible for a user to
deliberately trigger dump_instr() with a chosen kernel address.
Let's avoid problems resulting from this by using get_user() rather than
__get_user(), ensuring that we don't erroneously access kernel memory.
So that we can use the same code to dump user instructions and kernel
instructions, the common dumping code is factored out to __dump_instr(),
with the fs manipulated appropriately in dump_instr() around calls to
this.
Signed-off-by: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
arch/arm/kernel/traps.c | 28 ++++++++++++++++++----------
1 file changed, 18 insertions(+), 10 deletions(-)
--- a/arch/arm/kernel/traps.c
+++ b/arch/arm/kernel/traps.c
@@ -154,30 +154,26 @@ static void dump_mem(const char *lvl, co
set_fs(fs);
}
-static void dump_instr(const char *lvl, struct pt_regs *regs)
+static void __dump_instr(const char *lvl, struct pt_regs *regs)
{
unsigned long addr = instruction_pointer(regs);
const int thumb = thumb_mode(regs);
const int width = thumb ? 4 : 8;
- mm_segment_t fs;
char str[sizeof("00000000 ") * 5 + 2 + 1], *p = str;
int i;
/*
- * We need to switch to kernel mode so that we can use __get_user
- * to safely read from kernel space. Note that we now dump the
- * code first, just in case the backtrace kills us.
+ * Note that we now dump the code first, just in case the backtrace
+ * kills us.
*/
- fs = get_fs();
- set_fs(KERNEL_DS);
for (i = -4; i < 1 + !!thumb; i++) {
unsigned int val, bad;
if (thumb)
- bad = __get_user(val, &((u16 *)addr)[i]);
+ bad = get_user(val, &((u16 *)addr)[i]);
else
- bad = __get_user(val, &((u32 *)addr)[i]);
+ bad = get_user(val, &((u32 *)addr)[i]);
if (!bad)
p += sprintf(p, i == 0 ? "(%0*x) " : "%0*x ",
@@ -188,8 +184,20 @@ static void dump_instr(const char *lvl,
}
}
printk("%sCode: %s\n", lvl, str);
+}
- set_fs(fs);
+static void dump_instr(const char *lvl, struct pt_regs *regs)
+{
+ mm_segment_t fs;
+
+ if (!user_mode(regs)) {
+ fs = get_fs();
+ set_fs(KERNEL_DS);
+ __dump_instr(lvl, regs);
+ set_fs(fs);
+ } else {
+ __dump_instr(lvl, regs);
+ }
}
#ifdef CONFIG_ARM_UNWIND
next prev parent reply other threads:[~2017-11-13 13:04 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-13 12:56 [PATCH 4.13 00/33] 4.13.13-stable review Greg Kroah-Hartman
2017-11-13 12:56 ` [PATCH 4.13 01/33] netfilter: nat: Revert "netfilter: nat: convert nat bysrc hash to rhashtable" Greg Kroah-Hartman
2017-11-13 12:56 ` [PATCH 4.13 02/33] netfilter: nft_set_hash: disable fast_ops for 2-len keys Greg Kroah-Hartman
2017-11-13 12:56 ` [PATCH 4.13 03/33] workqueue: Fix NULL pointer dereference Greg Kroah-Hartman
2017-11-13 12:56 ` [PATCH 4.13 04/33] crypto: ccm - preserve the IV buffer Greg Kroah-Hartman
2017-11-13 12:56 ` [PATCH 4.13 05/33] crypto: x86/sha1-mb - fix panic due to unaligned access Greg Kroah-Hartman
2017-11-13 12:56 ` [PATCH 4.13 06/33] crypto: x86/sha256-mb " Greg Kroah-Hartman
2017-11-13 12:56 ` [PATCH 4.13 07/33] KEYS: fix NULL pointer dereference during ASN.1 parsing [ver #2] Greg Kroah-Hartman
2017-11-13 12:56 ` [PATCH 4.13 08/33] ACPI / PM: Blacklist Low Power S0 Idle _DSM for Dell XPS13 9360 Greg Kroah-Hartman
2017-11-13 12:56 ` [PATCH 4.13 09/33] ACPICA: Dispatch active GPEs at init time Greg Kroah-Hartman
2017-11-13 12:56 ` [PATCH 4.13 10/33] ACPICA: Make it possible to enable runtime GPEs earlier Greg Kroah-Hartman
2017-11-13 12:56 ` [PATCH 4.13 11/33] ACPI / scan: Enable GPEs before scanning the namespace Greg Kroah-Hartman
2017-11-13 12:56 ` Greg Kroah-Hartman [this message]
2017-11-13 12:56 ` [PATCH 4.13 14/33] ALSA: usb-audio: support new Amanero Combo384 firmware version Greg Kroah-Hartman
2017-11-13 12:56 ` [PATCH 4.13 15/33] ALSA: hda - fix headset mic problem for Dell machines with alc274 Greg Kroah-Hartman
2017-11-13 12:56 ` [PATCH 4.13 16/33] ALSA: seq: Fix OSS sysex delivery in OSS emulation Greg Kroah-Hartman
2017-11-13 12:56 ` [PATCH 4.13 17/33] ALSA: seq: Avoid invalid lockdep class warning Greg Kroah-Hartman
2017-11-13 12:56 ` [PATCH 4.13 18/33] MIPS: Fix CM region target definitions Greg Kroah-Hartman
2017-11-13 12:56 ` [PATCH 4.13 19/33] MIPS: BMIPS: Fix missing cbr address Greg Kroah-Hartman
2017-11-13 12:56 ` [PATCH 4.13 20/33] MIPS: AR7: Defer registration of GPIO Greg Kroah-Hartman
2017-11-13 12:56 ` [PATCH 4.13 21/33] MIPS: AR7: Ensure that serial ports are properly set up Greg Kroah-Hartman
2017-11-13 12:56 ` [PATCH 4.13 22/33] KVM: PPC: Book3S HV: Fix exclusion between HPT resizing and other HPT updates Greg Kroah-Hartman
2017-11-13 12:56 ` [PATCH 4.13 23/33] Input: elan_i2c - add ELAN060C to the ACPI table Greg Kroah-Hartman
2017-11-13 12:56 ` [PATCH 4.13 24/33] rbd: use GFP_NOIO for parent stat and data requests Greg Kroah-Hartman
2017-11-13 12:56 ` [PATCH 4.13 25/33] drm/vmwgfx: Fix Ubuntu 17.10 Wayland black screen issue Greg Kroah-Hartman
2017-11-13 12:56 ` [PATCH 4.13 26/33] Revert "x86: CPU: Fix up "cpu MHz" in /proc/cpuinfo" Greg Kroah-Hartman
2017-11-13 12:56 ` [PATCH 4.13 27/33] can: sun4i: handle overrun in RX FIFO Greg Kroah-Hartman
2017-11-13 12:56 ` [PATCH 4.13 28/33] can: peak: Add support for new PCIe/M2 CAN FD interfaces Greg Kroah-Hartman
2017-11-13 12:56 ` [PATCH 4.13 29/33] can: ifi: Fix transmitter delay calculation Greg Kroah-Hartman
2017-11-13 12:56 ` [PATCH 4.13 31/33] x86/debug: Handle warnings before the notifier chain, to fix KGDB crash Greg Kroah-Hartman
2017-11-13 12:56 ` [PATCH 4.13 32/33] x86/smpboot: Make optimization of delay calibration work correctly Greg Kroah-Hartman
2017-11-13 12:56 ` [PATCH 4.13 33/33] x86/oprofile/ppro: Do not use __this_cpu*() in preemptible context Greg Kroah-Hartman
2017-11-13 21:52 ` [PATCH 4.13 00/33] 4.13.13-stable review Shuah Khan
2017-11-13 22:29 ` Guenter Roeck
2017-11-14 7:49 ` Greg Kroah-Hartman
[not found] ` <5a0a1664.87c7df0a.74220.6a5a@mx.google.com>
2017-11-14 7:43 ` Greg Kroah-Hartman
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=20171113125612.340096529@linuxfoundation.org \
--to=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=rmk+kernel@armlinux.org.uk \
--cc=stable@vger.kernel.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 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).