All of lore.kernel.org
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	stable@vger.kernel.org, James Hogan <james.hogan@imgtec.com>,
	linux-metag@vger.kernel.org
Subject: [PATCH 4.10 039/110] metag/usercopy: Fix src fixup in from user rapf loops
Date: Mon, 10 Apr 2017 18:42:30 +0200	[thread overview]
Message-ID: <20170410164203.392408464@linuxfoundation.org> (raw)
In-Reply-To: <20170410164201.247583164@linuxfoundation.org>

4.10-stable review patch.  If anyone has any objections, please let me know.

------------------

From: James Hogan <james.hogan@imgtec.com>

commit 2c0b1df88b987a12d95ea1d6beaf01894f3cc725 upstream.

The fixup code to rewind the source pointer in
__asm_copy_from_user_{32,64}bit_rapf_loop() always rewound the source by
a single unit (4 or 8 bytes), however this is insufficient if the fault
didn't occur on the first load in the loop, as the source pointer will
have been incremented but nothing will have been stored until all 4
register [pairs] are loaded.

Read the LSM_STEP field of TXSTATUS (which is already loaded into a
register), a bit like the copy_to_user versions, to determine how many
iterations of MGET[DL] have taken place, all of which need rewinding.

Fixes: 373cd784d0fc ("metag: Memory handling")
Signed-off-by: James Hogan <james.hogan@imgtec.com>
Cc: linux-metag@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 arch/metag/lib/usercopy.c |   36 ++++++++++++++++++++++++++++--------
 1 file changed, 28 insertions(+), 8 deletions(-)

--- a/arch/metag/lib/usercopy.c
+++ b/arch/metag/lib/usercopy.c
@@ -687,29 +687,49 @@ EXPORT_SYMBOL(__copy_user);
  *
  *	Rationale:
  *		A fault occurs while reading from user buffer, which is the
- *		source. Since the fault is at a single address, we only
- *		need to rewind by 8 bytes.
+ *		source.
  *		Since we don't write to kernel buffer until we read first,
  *		the kernel buffer is at the right state and needn't be
- *		corrected.
+ *		corrected, but the source must be rewound to the beginning of
+ *		the block, which is LSM_STEP*8 bytes.
+ *		LSM_STEP is bits 10:8 in TXSTATUS which is already read
+ *		and stored in D0Ar2
+ *
+ *		NOTE: If a fault occurs at the last operation in M{G,S}ETL
+ *			LSM_STEP will be 0. ie: we do 4 writes in our case, if
+ *			a fault happens at the 4th write, LSM_STEP will be 0
+ *			instead of 4. The code copes with that.
  */
 #define __asm_copy_from_user_64bit_rapf_loop(to, from, ret, n, id)	\
 	__asm_copy_user_64bit_rapf_loop(to, from, ret, n, id,		\
-		"SUB	%1, %1, #8\n")
+		"LSR	D0Ar2, D0Ar2, #5\n"				\
+		"ANDS	D0Ar2, D0Ar2, #0x38\n"				\
+		"ADDZ	D0Ar2, D0Ar2, #32\n"				\
+		"SUB	%1, %1, D0Ar2\n")
 
 /*	rewind 'from' pointer when a fault occurs
  *
  *	Rationale:
  *		A fault occurs while reading from user buffer, which is the
- *		source. Since the fault is at a single address, we only
- *		need to rewind by 4 bytes.
+ *		source.
  *		Since we don't write to kernel buffer until we read first,
  *		the kernel buffer is at the right state and needn't be
- *		corrected.
+ *		corrected, but the source must be rewound to the beginning of
+ *		the block, which is LSM_STEP*4 bytes.
+ *		LSM_STEP is bits 10:8 in TXSTATUS which is already read
+ *		and stored in D0Ar2
+ *
+ *		NOTE: If a fault occurs at the last operation in M{G,S}ETL
+ *			LSM_STEP will be 0. ie: we do 4 writes in our case, if
+ *			a fault happens at the 4th write, LSM_STEP will be 0
+ *			instead of 4. The code copes with that.
  */
 #define __asm_copy_from_user_32bit_rapf_loop(to, from, ret, n, id)	\
 	__asm_copy_user_32bit_rapf_loop(to, from, ret, n, id,		\
-		"SUB	%1, %1, #4\n")
+		"LSR	D0Ar2, D0Ar2, #6\n"				\
+		"ANDS	D0Ar2, D0Ar2, #0x1c\n"				\
+		"ADDZ	D0Ar2, D0Ar2, #16\n"				\
+		"SUB	%1, %1, D0Ar2\n")
 
 
 /*

  parent reply	other threads:[~2017-04-10 16:51 UTC|newest]

Thread overview: 120+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-10 16:41 [PATCH 4.10 000/110] 4.10.10-stable review Greg Kroah-Hartman
2017-04-10 16:41 ` [PATCH 4.10 001/110] drm/vmwgfx: Type-check lookups of fence objects Greg Kroah-Hartman
2017-04-10 16:41 ` [PATCH 4.10 002/110] drm/vmwgfx: NULL pointer dereference in vmw_surface_define_ioctl() Greg Kroah-Hartman
2017-04-10 16:41 ` [PATCH 4.10 003/110] drm/vmwgfx: avoid calling vzalloc with a 0 size in vmw_get_cap_3d_ioctl() Greg Kroah-Hartman
2017-04-10 16:41 ` [PATCH 4.10 004/110] drm/ttm, drm/vmwgfx: Relax permission checking when opening surfaces Greg Kroah-Hartman
2017-04-10 16:41 ` [PATCH 4.10 005/110] drm/vmwgfx: Remove getparam error message Greg Kroah-Hartman
2017-04-10 16:41 ` [PATCH 4.10 006/110] drm/vmwgfx: fix integer overflow in vmw_surface_define_ioctl() Greg Kroah-Hartman
2017-04-10 16:41 ` [PATCH 4.10 007/110] PCI: thunder-pem: Add legacy firmware support for Cavium ThunderX host controller Greg Kroah-Hartman
2017-04-10 16:41 ` [PATCH 4.10 008/110] PCI: thunder-pem: Fix legacy firmware PEM-specific resources Greg Kroah-Hartman
2017-04-10 16:42 ` [PATCH 4.10 009/110] sysfs: be careful of error returns from ops->show() Greg Kroah-Hartman
2017-04-10 16:42 ` [PATCH 4.10 010/110] staging: android: ashmem: lseek failed due to no FMODE_LSEEK Greg Kroah-Hartman
2017-04-10 16:42 ` [PATCH 4.10 011/110] arm/arm64: KVM: Take mmap_sem in stage2_unmap_vm Greg Kroah-Hartman
2017-04-10 16:42 ` [PATCH 4.10 012/110] arm/arm64: KVM: Take mmap_sem in kvm_arch_prepare_memory_region Greg Kroah-Hartman
2017-04-10 16:42 ` [PATCH 4.10 013/110] kvm: arm/arm64: Fix locking for kvm_free_stage2_pgd Greg Kroah-Hartman
2017-04-10 16:42 ` [PATCH 4.10 014/110] iio: core: Fix IIO_VAL_FRACTIONAL_LOG2 for negative values Greg Kroah-Hartman
2017-04-10 16:42 ` [PATCH 4.10 015/110] iio: st_pressure: initialize lps22hb bootime Greg Kroah-Hartman
2017-04-10 16:42 ` [PATCH 4.10 016/110] iio: bmg160: reset chip when probing Greg Kroah-Hartman
2017-04-10 16:42 ` [PATCH 4.10 017/110] arm64: mm: unaligned access by user-land should be received as SIGBUS Greg Kroah-Hartman
2017-04-10 16:42 ` [PATCH 4.10 018/110] cfg80211: check rdev resume callback only for registered wiphy Greg Kroah-Hartman
2017-04-10 16:42 ` [PATCH 4.10 019/110] Reset TreeId to zero on SMB2 TREE_CONNECT Greg Kroah-Hartman
2017-04-10 16:42 ` [PATCH 4.10 020/110] mm/page_alloc.c: fix print order in show_free_areas() Greg Kroah-Hartman
2017-04-10 16:42 ` [PATCH 4.10 021/110] ptrace: fix PTRACE_LISTEN race corrupting task->state Greg Kroah-Hartman
2017-04-10 16:42 ` [PATCH 4.10 022/110] dax: fix radix tree insertion race Greg Kroah-Hartman
2017-04-10 16:42 ` [PATCH 4.10 023/110] dm verity fec: limit error correction recursion Greg Kroah-Hartman
2017-04-10 16:42 ` [PATCH 4.10 024/110] dm verity fec: fix bufio leaks Greg Kroah-Hartman
2017-04-10 16:42 ` [PATCH 4.10 025/110] ACPI / gpio: do not fall back to parsing _CRS when we get a deferral Greg Kroah-Hartman
2017-04-10 16:42 ` [PATCH 4.10 026/110] ACPI / scan: Prefer devices without _HID for _ADR matching Greg Kroah-Hartman
2017-04-10 16:42 ` [PATCH 4.10 027/110] Kbuild: use cc-disable-warning consistently for maybe-uninitialized Greg Kroah-Hartman
2017-04-10 16:42 ` [PATCH 4.10 028/110] jump label: fix passing kbuild_cflags when checking for asm goto support Greg Kroah-Hartman
2017-04-10 16:42 ` [PATCH 4.10 029/110] orangefs: move features validation to fix filesystem hang Greg Kroah-Hartman
2017-04-10 16:42 ` [PATCH 4.10 030/110] xfs: Honor FALLOC_FL_KEEP_SIZE when punching ends of files Greg Kroah-Hartman
2017-04-10 16:42 ` [PATCH 4.10 031/110] ring-buffer: Fix return value check in test_ringbuffer() Greg Kroah-Hartman
2017-04-10 16:42 ` [PATCH 4.10 032/110] mac80211: unconditionally start new netdev queues with iTXQ support Greg Kroah-Hartman
2017-04-10 16:42 ` [PATCH 4.10 033/110] brcmfmac: use local iftype avoiding use-after-free of virtual interface Greg Kroah-Hartman
2017-04-10 16:42 ` [PATCH 4.10 034/110] metag/usercopy: Drop unused macros Greg Kroah-Hartman
2017-04-10 16:42 ` [PATCH 4.10 035/110] metag/usercopy: Fix alignment error checking Greg Kroah-Hartman
2017-04-10 16:42 ` [PATCH 4.10 036/110] metag/usercopy: Add early abort to copy_to_user Greg Kroah-Hartman
2017-04-10 16:42 ` [PATCH 4.10 037/110] metag/usercopy: Zero rest of buffer from copy_from_user Greg Kroah-Hartman
2017-04-10 16:42 ` [PATCH 4.10 038/110] metag/usercopy: Set flags before ADDZ Greg Kroah-Hartman
2017-04-10 16:42   ` Greg Kroah-Hartman
2017-04-10 16:42 ` Greg Kroah-Hartman [this message]
2017-04-10 16:42 ` [PATCH 4.10 040/110] metag/usercopy: Add missing fixups Greg Kroah-Hartman
2017-04-10 16:42 ` [PATCH 4.10 041/110] drm/msm: adreno: fix build error without debugfs Greg Kroah-Hartman
2017-04-10 16:42 ` [PATCH 4.10 042/110] powerpc: Disable HFSCR[TM] if TM is not supported Greg Kroah-Hartman
2017-04-10 16:42 ` [PATCH 4.10 043/110] powerpc/mm: Add missing global TLB invalidate if cxl is active Greg Kroah-Hartman
2017-04-10 16:42 ` [PATCH 4.10 044/110] powerpc/64: Fix flush_(d|i)cache_range() called from modules Greg Kroah-Hartman
2017-04-10 16:42 ` [PATCH 4.10 045/110] powerpc: Dont try to fix up misaligned load-with-reservation instructions Greg Kroah-Hartman
2017-04-10 16:42 ` [PATCH 4.10 046/110] powerpc/crypto/crc32c-vpmsum: Fix missing preempt_disable() Greg Kroah-Hartman
2017-04-10 16:42 ` [PATCH 4.10 048/110] x86/mce: Dont print MCEs when mcelog is active Greg Kroah-Hartman
2017-04-10 16:42 ` [PATCH 4.10 049/110] nios2: reserve boot memory for device tree Greg Kroah-Hartman
2017-04-10 16:42 ` [PATCH 4.10 050/110] xtensa: make __pa work with uncached KSEG addresses Greg Kroah-Hartman
2017-04-10 16:42 ` [PATCH 4.10 051/110] s390/decompressor: fix initrd corruption caused by bss clear Greg Kroah-Hartman
2017-04-10 16:42 ` [PATCH 4.10 052/110] s390/uaccess: get_user() should zero on failure (again) Greg Kroah-Hartman
2017-04-10 16:42 ` [PATCH 4.10 053/110] MIPS: Force o32 fp64 support on 32bit MIPS64r6 kernels Greg Kroah-Hartman
2017-04-10 16:42 ` [PATCH 4.10 054/110] MIPS: ralink: Fix typos in rt3883 pinctrl Greg Kroah-Hartman
2017-04-10 16:42 ` [PATCH 4.10 055/110] MIPS: End spinlocks with .insn Greg Kroah-Hartman
2017-04-10 16:42 ` [PATCH 4.10 056/110] MIPS: Lantiq: fix missing xbar kernel panic Greg Kroah-Hartman
2017-04-10 16:42 ` [PATCH 4.10 057/110] MIPS: Check TLB before handle_ri_rdhwr() for Loongson-3 Greg Kroah-Hartman
2017-04-10 16:42 ` [PATCH 4.10 058/110] MIPS: Add MIPS_CPU_FTLB for Loongson-3A R2 Greg Kroah-Hartman
2017-04-10 16:42 ` [PATCH 4.10 059/110] MIPS: Flush wrong invalid FTLB entry for huge page Greg Kroah-Hartman
2017-04-10 16:42 ` [PATCH 4.10 060/110] MIPS: c-r4k: Fix Loongson-3s vcache/scache waysize calculation Greg Kroah-Hartman
2017-04-10 16:42 ` [PATCH 4.10 061/110] drm/i915/gvt: Fix gvt scheduler interval time Greg Kroah-Hartman
2017-04-10 16:42 ` [PATCH 4.10 062/110] drm/i915/kvmgt: fix suspicious rcu dereference usage Greg Kroah-Hartman
2017-04-10 16:42 ` [PATCH 4.10 063/110] usb: dwc3: gadget: delay unmap of bounced requests Greg Kroah-Hartman
2017-04-10 16:42 ` [PATCH 4.10 064/110] Documentation: stable-kernel-rules: fix stable-tag format Greg Kroah-Hartman
2017-04-10 16:42 ` [PATCH 4.10 065/110] mm/mempolicy.c: fix error handling in set_mempolicy and mbind Greg Kroah-Hartman
2017-04-10 16:42 ` [PATCH 4.10 066/110] random: use chacha20 for get_random_int/long Greg Kroah-Hartman
2017-04-10 16:42 ` [PATCH 4.10 067/110] kvm: fix page struct leak in handle_vmon Greg Kroah-Hartman
2017-04-10 16:42 ` [PATCH 4.10 068/110] HID: multitouch: enable the Surface 4 Type Cover Pro (JP) to report multitouch data Greg Kroah-Hartman
2017-04-10 16:43 ` [PATCH 4.10 069/110] drm/edid: constify edid quirk list Greg Kroah-Hartman
2017-04-10 16:43 ` [PATCH 4.10 070/110] drm/i915: fix INTEL_BDW_IDS definition Greg Kroah-Hartman
2017-04-10 16:43 ` [PATCH 4.10 071/110] drm/i915: more .is_mobile cleanups for BDW Greg Kroah-Hartman
2017-04-10 16:43 ` [PATCH 4.10 072/110] drm/i915: actually drive the BDW reserved IDs Greg Kroah-Hartman
2017-04-10 16:43 ` [PATCH 4.10 073/110] ASoC: Intel: bytcr_rt5640: quirks for Insyde devices Greg Kroah-Hartman
2017-04-10 16:43 ` [PATCH 4.10 074/110] ARM: OMAP2+: Fix init for multiple quirks for the same SoC Greg Kroah-Hartman
2017-04-10 16:43 ` [PATCH 4.10 075/110] usb: chipidea: msm: Rely on core to override AHBBURST Greg Kroah-Hartman
2017-04-10 16:43 ` [PATCH 4.10 076/110] serial: 8250_omap: Add OMAP_DMA_TX_KICK quirk for AM437x Greg Kroah-Hartman
2017-04-10 16:43 ` [PATCH 4.10 077/110] ARM: davinci: add skeleton for pdata-quirks Greg Kroah-Hartman
2017-04-11  8:13   ` Sekhar Nori
2017-04-11 14:41     ` Greg Kroah-Hartman
2017-04-10 16:43 ` [PATCH 4.10 079/110] usb: host: xhci-plat: enable BROKEN_PED quirk if platform requested Greg Kroah-Hartman
2017-04-10 16:43 ` [PATCH 4.10 080/110] usb: dwc3: host: pass quirk-broken-port-ped property for known broken revisions Greg Kroah-Hartman
2017-04-10 16:43 ` [PATCH 4.10 081/110] drm/mga: remove device_is_agp callback Greg Kroah-Hartman
2017-04-10 16:43 ` [PATCH 4.10 082/110] PCI: Add ACS quirk for Intel Union Point Greg Kroah-Hartman
2017-04-10 16:43 ` [PATCH 4.10 083/110] PCI: xgene: Fix double free on init error Greg Kroah-Hartman
2017-04-10 16:43 ` [PATCH 4.10 084/110] [media] rx51: broken build Greg Kroah-Hartman
2017-04-11 11:44   ` Sean Young
2017-04-11 14:42     ` Greg Kroah-Hartman
2017-04-10 16:43 ` [PATCH 4.10 085/110] sata: ahci-da850: implement a workaround for the softreset quirk Greg Kroah-Hartman
2017-04-10 16:43 ` [PATCH 4.10 086/110] ACPI / button: Change default behavior to lid_init_state=open Greg Kroah-Hartman
2017-04-10 16:43 ` [PATCH 4.10 087/110] ASoC: codecs: rt5670: add quirk for Lenovo Thinkpad 10 Greg Kroah-Hartman
2017-04-10 16:43 ` [PATCH 4.10 088/110] ASoC: Intel: Baytrail: " Greg Kroah-Hartman
2017-04-10 16:43 ` [PATCH 4.10 089/110] ASoC: Intel: cht_bsw_rt5645: harden ACPI device detection Greg Kroah-Hartman
2017-04-10 16:43 ` [PATCH 4.10 090/110] ASoC: Intel: cht_bsw_rt5645: add Baytrail MCLK support Greg Kroah-Hartman
2017-04-10 16:43 ` [PATCH 4.10 091/110] ACPI: save NVS memory for Lenovo G50-45 Greg Kroah-Hartman
2017-04-10 16:43 ` [PATCH 4.10 092/110] usb: musb: da8xx: Fix host mode suspend Greg Kroah-Hartman
2017-04-10 16:43 ` [PATCH 4.10 094/110] HID: wacom: dont apply generic settings to old devices Greg Kroah-Hartman
2017-04-10 16:43 ` [PATCH 4.10 095/110] arm: kernel: Add SMC structure parameter Greg Kroah-Hartman
2017-04-10 16:43 ` [PATCH 4.10 096/110] firmware: qcom: scm: Fix interrupted SCM calls Greg Kroah-Hartman
2017-04-10 16:43 ` [PATCH 4.10 097/110] ARM: smccc: Update HVC comment to describe new quirk parameter Greg Kroah-Hartman
2017-04-10 16:43 ` [PATCH 4.10 098/110] PCI: Add Broadcom Northstar2 PAXC quirk for device class and MPSS Greg Kroah-Hartman
2017-04-10 16:43 ` [PATCH 4.10 099/110] PCI: Disable MSI for HiSilicon Hip06/Hip07 Root Ports Greg Kroah-Hartman
2017-04-10 16:43 ` [PATCH 4.10 100/110] mmc: sdhci-of-esdhc: remove default broken-cd for ARM Greg Kroah-Hartman
2017-04-10 16:43 ` [PATCH 4.10 101/110] PCI: Sort the list of devices with D3 delay quirk by ID Greg Kroah-Hartman
2017-04-10 16:43 ` [PATCH 4.10 102/110] PCI: Add ACS quirk for Qualcomm QDF2400 and QDF2432 Greg Kroah-Hartman
2017-04-10 16:43 ` [PATCH 4.10 103/110] watchdog: s3c2410: Fix infinite interrupt in soft mode Greg Kroah-Hartman
2017-04-10 16:43 ` [PATCH 4.10 105/110] tools/power turbostat: decode Baytrail CC6 and MC6 demotion configuration Greg Kroah-Hartman
2017-04-10 16:43 ` [PATCH 4.10 106/110] tools/power turbostat: dump Atom P-states correctly Greg Kroah-Hartman
2017-04-10 16:43 ` [PATCH 4.10 107/110] x86/reboot/quirks: Add ASUS EeeBook X205TA reboot quirk Greg Kroah-Hartman
2017-04-10 16:43 ` [PATCH 4.10 108/110] x86/reboot/quirks: Add ASUS EeeBook X205TA/W " Greg Kroah-Hartman
2017-04-10 16:43 ` [PATCH 4.10 109/110] usb-storage: Add ignore-residue quirk for Initio INIC-3619 Greg Kroah-Hartman
2017-04-10 16:43 ` [PATCH 4.10 110/110] x86/reboot/quirks: Fix typo in ASUS EeeBook X205TA reboot quirk Greg Kroah-Hartman
2017-04-10 20:39 ` [PATCH 4.10 000/110] 4.10.10-stable review Shuah Khan
2017-04-11  4:58   ` Greg Kroah-Hartman
2017-04-10 23:58 ` Andre Tomt
2017-04-11  4:55   ` Greg Kroah-Hartman
2017-04-11  3:17 ` Guenter Roeck
2017-04-11  4:48   ` Greg Kroah-Hartman
2017-04-11  5:04     ` Guenter Roeck
2017-04-11  5:02 ` 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=20170410164203.392408464@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=james.hogan@imgtec.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-metag@vger.kernel.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 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.