linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: stable@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Matt Redfearn <matt.redfearn@imgtec.com>,
	Marcin Nowakowski <marcin.nowakowski@imgtec.com>,
	James Hogan <james.hogan@imgtec.com>,
	Ingo Molnar <mingo@kernel.org>,
	Paul Burton <paul.burton@imgtec.com>,
	linux-mips@linux-mips.org, Ralf Baechle <ralf@linux-mips.org>,
	Sasha Levin <sashal@kernel.org>
Subject: [PATCH AUTOSEL 4.9 04/98] MIPS: Handle non word sized instructions when examining frame
Date: Thu, 25 Oct 2018 10:12:49 -0400	[thread overview]
Message-ID: <20181025141423.213774-4-sashal@kernel.org> (raw)
In-Reply-To: <20181025141423.213774-1-sashal@kernel.org>

From: Matt Redfearn <matt.redfearn@imgtec.com>

[ Upstream commit 11887ed172a6960673f130dad8f8fb42778f64d7 ]

Commit 34c2f668d0f6b ("MIPS: microMIPS: Add unaligned access support.")
added fairly broken support for handling 16bit microMIPS instructions in
get_frame_info(). It adjusts the instruction pointer by 16bits in the
case of a 16bit sp move instruction, but not any other 16bit
instruction.

Commit b6c7a324df37 ("MIPS: Fix get_frame_info() handling of microMIPS
function size") goes some way to fixing get_frame_info() to iterate over
microMIPS instuctions, but the instruction pointer is still manipulated
using a postincrement, and is of union mips_instruction type. Since the
union is sized to the largest member (a word), but microMIPS
instructions are a mix of halfword and word sizes, the function does not
always iterate correctly, ending up misaligned with the instruction
stream and interpreting it incorrectly.

Since the instruction modifying the stack pointer is usually the first
in the function, that one is usually handled correctly. But the
instruction which saves the return address to the sp is some variable
number of instructions into the frame and is frequently missed due to
not being on a word boundary, leading to incomplete walking of the
stack.

Fix this by incrementing the instruction pointer based on the size of
the previously decoded instruction (& remove the hack introduced by
commit 34c2f668d0f6b ("MIPS: microMIPS: Add unaligned access support.")
which adjusts the instruction pointer in the case of a 16bit sp move
instruction, but not any other).

Fixes: 34c2f668d0f6b ("MIPS: microMIPS: Add unaligned access support.")
Signed-off-by: Matt Redfearn <matt.redfearn@imgtec.com>
Cc: Marcin Nowakowski <marcin.nowakowski@imgtec.com>
Cc: James Hogan <james.hogan@imgtec.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Paul Burton <paul.burton@imgtec.com>
Cc: linux-mips@linux-mips.org
Cc: linux-kernel@vger.kernel.org
Patchwork: https://patchwork.linux-mips.org/patch/16953/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 arch/mips/kernel/process.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/arch/mips/kernel/process.c b/arch/mips/kernel/process.c
index 0211dc737a21..1cc133e7026f 100644
--- a/arch/mips/kernel/process.c
+++ b/arch/mips/kernel/process.c
@@ -346,6 +346,7 @@ static int get_frame_info(struct mips_frame_info *info)
 	bool is_mmips = IS_ENABLED(CONFIG_CPU_MICROMIPS);
 	union mips_instruction insn, *ip, *ip_end;
 	const unsigned int max_insns = 128;
+	unsigned int last_insn_size = 0;
 	unsigned int i;
 
 	info->pc_offset = -1;
@@ -357,15 +358,19 @@ static int get_frame_info(struct mips_frame_info *info)
 
 	ip_end = (void *)ip + info->func_size;
 
-	for (i = 0; i < max_insns && ip < ip_end; i++, ip++) {
+	for (i = 0; i < max_insns && ip < ip_end; i++) {
+		ip = (void *)ip + last_insn_size;
 		if (is_mmips && mm_insn_16bit(ip->halfword[0])) {
 			insn.halfword[0] = 0;
 			insn.halfword[1] = ip->halfword[0];
+			last_insn_size = 2;
 		} else if (is_mmips) {
 			insn.halfword[0] = ip->halfword[1];
 			insn.halfword[1] = ip->halfword[0];
+			last_insn_size = 4;
 		} else {
 			insn.word = ip->word;
+			last_insn_size = 4;
 		}
 
 		if (is_jump_ins(&insn))
@@ -387,8 +392,6 @@ static int get_frame_info(struct mips_frame_info *info)
 						tmp = (ip->halfword[0] >> 1);
 						info->frame_size = -(signed short)(tmp & 0xf);
 					}
-					ip = (void *) &ip->halfword[1];
-					ip--;
 				} else
 #endif
 				info->frame_size = - ip->i_format.simmediate;
-- 
2.17.1


  parent reply	other threads:[~2018-10-25 14:14 UTC|newest]

Thread overview: 102+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-25 14:12 [PATCH AUTOSEL 4.9 01/98] perf symbols: Fix memory corruption because of zero length symbols Sasha Levin
2018-10-25 14:12 ` [PATCH AUTOSEL 4.9 02/98] mm/memory_hotplug.c: fix overflow in test_pages_in_a_zone() Sasha Levin
2018-10-25 14:12 ` [PATCH AUTOSEL 4.9 03/98] MIPS: microMIPS: Fix decoding of swsp16 instruction Sasha Levin
2018-10-25 14:12 ` Sasha Levin [this message]
2018-10-25 14:12 ` [PATCH AUTOSEL 4.9 05/98] scsi: aacraid: Fix typo in blink status Sasha Levin
2018-10-25 14:12 ` [PATCH AUTOSEL 4.9 06/98] f2fs: fix multiple f2fs_add_link() having same name for inline dentry Sasha Levin
2018-10-25 14:12 ` [PATCH AUTOSEL 4.9 07/98] igb: Remove superfluous reset to PHY and page 0 selection Sasha Levin
2018-10-25 14:12 ` [PATCH AUTOSEL 4.9 08/98] ACPI: sysfs: Make ACPI GPE mask kernel parameter cover all GPEs Sasha Levin
2018-10-25 14:12 ` [PATCH AUTOSEL 4.9 09/98] PCI: Disable MSI for HiSilicon Hip06/Hip07 only in Root Port mode Sasha Levin
2018-10-25 14:12 ` [PATCH AUTOSEL 4.9 10/98] i2c: bcm2835: Avoid possible NULL ptr dereference Sasha Levin
2018-10-25 14:12 ` [PATCH AUTOSEL 4.9 11/98] efi/fb: Correct PCI_STD_RESOURCE_END usage Sasha Levin
2018-10-25 14:12 ` [PATCH AUTOSEL 4.9 12/98] ipv6: set rt6i_protocol properly in the route when it is installed Sasha Levin
2018-10-25 14:12 ` [PATCH AUTOSEL 4.9 13/98] platform/x86: acer-wmi: setup accelerometer when ACPI device was found Sasha Levin
2018-10-25 14:12 ` [PATCH AUTOSEL 4.9 14/98] IB/ipoib: Do not warn if IPoIB debugfs doesn't exist Sasha Levin
2018-10-25 14:13 ` [PATCH AUTOSEL 4.9 15/98] IB/core: Fix the validations of a multicast LID in attach or detach operations Sasha Levin
2018-10-25 14:13 ` [PATCH AUTOSEL 4.9 16/98] orangefs: off by ones in xattr size checks Sasha Levin
2018-10-25 14:13 ` [PATCH AUTOSEL 4.9 17/98] rxe: Fix a sleep-in-atomic bug in post_one_send Sasha Levin
2018-10-25 14:13 ` [PATCH AUTOSEL 4.9 18/98] nvme-pci: fix CMB sysfs file removal in reset path Sasha Levin
2018-10-25 14:13 ` [PATCH AUTOSEL 4.9 19/98] net: phy: marvell: Limit 88m1101 autoneg errata to 88E1145 as well Sasha Levin
2018-10-25 14:13 ` [PATCH AUTOSEL 4.9 20/98] net/mlx5: Fix command completion after timeout access invalid structure Sasha Levin
2018-10-25 14:13 ` [PATCH AUTOSEL 4.9 21/98] tipc: Fix tipc_sk_reinit handling of -EAGAIN Sasha Levin
2018-10-25 14:13 ` [PATCH AUTOSEL 4.9 22/98] tipc: fix a race condition of releasing subscriber object Sasha Levin
2018-10-25 14:13 ` [PATCH AUTOSEL 4.9 23/98] bnxt_en: Don't use rtnl lock to protect link change logic in workqueue Sasha Levin
2018-10-25 14:13 ` [PATCH AUTOSEL 4.9 24/98] ath10k: fix NAPI enable/disable symmetry for AHB interface Sasha Levin
2018-10-25 14:13 ` [PATCH AUTOSEL 4.9 25/98] ARM: dts: bcm283x: Reserve first page for firmware Sasha Levin
2018-10-25 14:13 ` [PATCH AUTOSEL 4.9 26/98] btrfs: fiemap: Cache and merge fiemap extent before submit it to user Sasha Levin
2018-10-25 14:13 ` [PATCH AUTOSEL 4.9 27/98] ata: sata_rcar: Handle return value of clk_prepare_enable Sasha Levin
2018-10-25 14:13 ` [PATCH AUTOSEL 4.9 28/98] reset: hi6220: Set module license so that it can be loaded Sasha Levin
2018-10-25 14:13 ` [PATCH AUTOSEL 4.9 29/98] ASoC: Intel: Skylake: Fix to parse consecutive string tkns in manifest Sasha Levin
2018-10-25 14:13 ` [PATCH AUTOSEL 4.9 30/98] arch/sparc: increase CONFIG_NODES_SHIFT on SPARC64 to 5 Sasha Levin
2018-10-25 14:13 ` [PATCH AUTOSEL 4.9 31/98] mac80211: fix TX aggregation start/stop callback race Sasha Levin
2018-10-25 14:13 ` [PATCH AUTOSEL 4.9 32/98] libata: fix error checking in in ata_parse_force_one() Sasha Levin
2018-10-25 14:13 ` [PATCH AUTOSEL 4.9 33/98] ARM: dts: imx6ul-14x14-evk: Add ksz8081 phy properties Sasha Levin
2018-10-29 14:07   ` Leonard Crestez
2018-10-29 18:46     ` Sasha Levin
2018-10-25 14:13 ` [PATCH AUTOSEL 4.9 34/98] net: ethernet: stmmac: Fix altr_tse_pcs SGMII Initialization Sasha Levin
2018-10-25 14:13 ` [PATCH AUTOSEL 4.9 35/98] qlcnic: Fix tunnel offload for 82xx adapters Sasha Levin
2018-10-25 14:13 ` [PATCH AUTOSEL 4.9 36/98] x86/cpu/cyrix: Add alternative Device ID of Geode GX1 SoC Sasha Levin
2018-10-25 14:13 ` [PATCH AUTOSEL 4.9 37/98] ARM: 8677/1: boot/compressed: fix decompressor header layout for v7-M Sasha Levin
2018-10-25 14:13 ` [PATCH AUTOSEL 4.9 38/98] gpu: ipu-v3: Fix CSI selection for VDIC Sasha Levin
2018-10-25 14:13 ` [PATCH AUTOSEL 4.9 39/98] elevator: fix truncation of icq_cache_name Sasha Levin
2018-10-25 14:13 ` [PATCH AUTOSEL 4.9 40/98] net: stmmac: ensure jumbo_frm error return is correctly checked for -ve value Sasha Levin
2018-10-25 14:13 ` [PATCH AUTOSEL 4.9 41/98] Btrfs: clear EXTENT_DEFRAG bits in finish_ordered_io Sasha Levin
2018-10-25 14:13 ` [PATCH AUTOSEL 4.9 42/98] ufs: we need to sync inode before freeing it Sasha Levin
2018-10-25 14:13 ` [PATCH AUTOSEL 4.9 43/98] net/mlx5e: Fix fixpoint divide exception in mlx5e_am_stats_compare Sasha Levin
2018-10-25 14:13 ` [PATCH AUTOSEL 4.9 44/98] ip6_tunnel: Correct tos value in collect_md mode Sasha Levin
2018-10-25 14:13 ` [PATCH AUTOSEL 4.9 45/98] net/mlx5: Fix driver load error flow when firmware is stuck Sasha Levin
2018-10-25 14:13 ` [PATCH AUTOSEL 4.9 46/98] perf evsel: Fix probing of precise_ip level for default cycles event Sasha Levin
2018-10-25 14:13 ` [PATCH AUTOSEL 4.9 47/98] perf probe: Fix probe definition for inlined functions Sasha Levin
2018-10-25 14:13 ` [PATCH AUTOSEL 4.9 48/98] net/mlx5: Fix health work queue spin lock to IRQ safe Sasha Levin
2018-10-25 14:13 ` [PATCH AUTOSEL 4.9 49/98] usb: renesas_usbhs: gadget: fix spin_lock_init() for &uep->lock Sasha Levin
2018-10-25 14:13 ` [PATCH AUTOSEL 4.9 50/98] usb: renesas_usbhs: gadget: fix unused-but-set-variable warning Sasha Levin
2018-10-25 14:13 ` [PATCH AUTOSEL 4.9 51/98] usb: dwc3: omap: remove IRQ_NOAUTOEN used with shared irq Sasha Levin
2018-10-25 14:13 ` [PATCH AUTOSEL 4.9 52/98] clk: samsung: Fix m2m scaler clock on Exynos542x Sasha Levin
2018-10-25 14:13 ` [PATCH AUTOSEL 4.9 53/98] ptr_ring: fix up after recent ptr_ring changes Sasha Levin
2018-10-25 14:13 ` [PATCH AUTOSEL 4.9 54/98] staging: wilc1000: Fix problem with wrong vif index Sasha Levin
2018-10-25 14:13 ` [PATCH AUTOSEL 4.9 55/98] rds: ib: Fix missing call to rds_ib_dev_put in rds_ib_setup_qp Sasha Levin
2018-10-25 14:13 ` [PATCH AUTOSEL 4.9 56/98] iio: adc: Revert "axp288: Drop bogus AXP288_ADC_TS_PIN_CTRL register modifications" Sasha Levin
2018-10-25 14:13 ` [PATCH AUTOSEL 4.9 57/98] qed: Warn PTT usage by wrong hw-function Sasha Levin
2018-10-25 14:13 ` [PATCH AUTOSEL 4.9 58/98] ocfs2: fix deadlock caused by recursive locking in xattr Sasha Levin
2018-10-25 14:13 ` [PATCH AUTOSEL 4.9 59/98] net: cdc_ncm: GetNtbFormat endian fix Sasha Levin
2018-10-25 14:13 ` [PATCH AUTOSEL 4.9 60/98] sctp: use right member as the param of list_for_each_entry Sasha Levin
2018-10-25 14:13 ` [PATCH AUTOSEL 4.9 61/98] ALSA: hda - No loopback on ALC299 codec Sasha Levin
2018-10-25 14:13 ` [PATCH AUTOSEL 4.9 62/98] x86/power: Fix some ordering bugs in __restore_processor_context() Sasha Levin
2018-10-25 14:13 ` [PATCH AUTOSEL 4.9 63/98] ath10k: convert warning about non-existent OTP board id to debug message Sasha Levin
2018-10-25 14:13 ` [PATCH AUTOSEL 4.9 64/98] ipv6: fix cleanup ordering for ip6_mr failure Sasha Levin
2018-10-25 14:13 ` [PATCH AUTOSEL 4.9 65/98] IB/ipoib: Fix lockdep issue found on ipoib_ib_dev_heavy_flush Sasha Levin
2018-10-25 14:13 ` [PATCH AUTOSEL 4.9 66/98] IB/rxe: put the pool on allocation failure Sasha Levin
2018-10-25 14:13 ` [PATCH AUTOSEL 4.9 67/98] nbd: only set MSG_MORE when we have more to send Sasha Levin
2018-10-25 14:13 ` [PATCH AUTOSEL 4.9 68/98] mm/frame_vector.c: release a semaphore in 'get_vaddr_frames()' Sasha Levin
2018-10-25 14:13 ` [PATCH AUTOSEL 4.9 69/98] IB/mlx5: Avoid passing an invalid QP type to firmware Sasha Levin
2018-10-25 14:13 ` [PATCH AUTOSEL 4.9 70/98] scsi: qla2xxx: Avoid double completion of abort command Sasha Levin
2018-10-25 14:13 ` [PATCH AUTOSEL 4.9 71/98] drm: bochs: Don't remove uninitialized fbdev framebuffer Sasha Levin
2018-10-25 14:13 ` [PATCH AUTOSEL 4.9 72/98] i40e: avoid NVM acquire deadlock during NVM update Sasha Levin
2018-10-25 14:13 ` [PATCH AUTOSEL 4.9 73/98] Revert "IB/ipoib: Update broadcast object if PKey value was changed in index 0" Sasha Levin
2018-10-25 14:13 ` [PATCH AUTOSEL 4.9 74/98] Btrfs: incremental send, fix invalid memory access Sasha Levin
2018-10-25 14:14 ` [PATCH AUTOSEL 4.9 75/98] drm/msm: Fix possible null dereference on failure of get_pages() Sasha Levin
2018-10-25 14:14 ` [PATCH AUTOSEL 4.9 76/98] ARM: tegra: Fix ULPI regression on Tegra20 Sasha Levin
2018-10-25 14:14 ` [PATCH AUTOSEL 4.9 77/98] module: fix DEBUG_SET_MODULE_RONX typo Sasha Levin
2018-10-25 14:14 ` [PATCH AUTOSEL 4.9 78/98] iio: pressure: zpa2326: Remove always-true check which confuses gcc Sasha Levin
2018-10-25 14:14 ` [PATCH AUTOSEL 4.9 79/98] l2tp: remove configurable payload offset Sasha Levin
2018-10-25 14:14 ` [PATCH AUTOSEL 4.9 80/98] macsec: fix memory leaks when skb_to_sgvec fails Sasha Levin
2018-10-25 14:14 ` [PATCH AUTOSEL 4.9 81/98] perf/core: Fix locking for children siblings group read Sasha Levin
2018-10-25 14:14 ` [PATCH AUTOSEL 4.9 82/98] cifs: Use ULL suffix for 64-bit constant Sasha Levin
2018-10-25 14:14 ` [PATCH AUTOSEL 4.9 83/98] futex: futex_wake_op, do not fail on invalid op Sasha Levin
2018-10-25 14:14 ` [PATCH AUTOSEL 4.9 84/98] ALSA: hda - Fix incorrect usage of IS_REACHABLE() Sasha Levin
2018-10-25 14:14 ` [PATCH AUTOSEL 4.9 85/98] test_bpf: Fix testing with CONFIG_BPF_JIT_ALWAYS_ON=y on other arches Sasha Levin
2018-10-25 14:14 ` [PATCH AUTOSEL 4.9 86/98] xen-netfront: Update features after registering netdev Sasha Levin
2018-10-25 14:14 ` [PATCH AUTOSEL 4.9 87/98] sparc64: Fix regression in pmdp_invalidate() Sasha Levin
2018-10-25 14:14 ` [PATCH AUTOSEL 4.9 88/98] xen-netfront: Fix mismatched rtnl_unlock Sasha Levin
2018-10-25 14:14 ` [PATCH AUTOSEL 4.9 89/98] enic: do not overwrite error code Sasha Levin
2018-10-25 14:14 ` [PATCH AUTOSEL 4.9 90/98] bonding: ratelimit failed speed/duplex update warning Sasha Levin
2018-10-25 14:14 ` [PATCH AUTOSEL 4.9 91/98] tty: serial: pl011: add ttyAMA for matching pl011 console Sasha Levin
2018-10-25 15:17   ` Sudeep Holla
2018-10-29 13:39     ` Sasha Levin
2018-10-25 14:14 ` [PATCH AUTOSEL 4.9 92/98] nvmet: fix space padding in serial number Sasha Levin
2018-10-25 14:14 ` [PATCH AUTOSEL 4.9 93/98] iio: buffer: fix the function signature to match implementation Sasha Levin
2018-10-25 14:14 ` [PATCH AUTOSEL 4.9 94/98] x86/paravirt: Fix some warning messages Sasha Levin
2018-10-25 14:14 ` [PATCH AUTOSEL 4.9 95/98] IB/mlx4: Fix an error handling path in 'mlx4_ib_rereg_user_mr()' Sasha Levin
2018-10-25 14:14 ` [PATCH AUTOSEL 4.9 96/98] libertas: call into generic suspend code before turning off power Sasha Levin
2018-10-25 14:14 ` [PATCH AUTOSEL 4.9 97/98] xhci: Fix USB3 NULL pointer dereference at logical disconnect Sasha Levin
2018-10-25 14:14 ` [PATCH AUTOSEL 4.9 98/98] perf tests: Fix indexing when invoking subtests Sasha Levin

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=20181025141423.213774-4-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=james.hogan@imgtec.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mips@linux-mips.org \
    --cc=marcin.nowakowski@imgtec.com \
    --cc=matt.redfearn@imgtec.com \
    --cc=mingo@kernel.org \
    --cc=paul.burton@imgtec.com \
    --cc=ralf@linux-mips.org \
    --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).