android_kernel_oneplus_msm8998/arch/mips
Matt Redfearn d37aca471b MIPS: memset.S: Fix clobber of v1 in last_fixup
commit c96eebf07692e53bf4dd5987510d8b550e793598 upstream.

The label .Llast_fixup\@ is jumped to on page fault within the final
byte set loop of memset (on < MIPSR6 architectures). For some reason, in
this fault handler, the v1 register is randomly set to a2 & STORMASK.
This clobbers v1 for the calling function. This can be observed with the
following test code:

static int __init __attribute__((optimize("O0"))) test_clear_user(void)
{
  register int t asm("v1");
  char *test;
  int j, k;

  pr_info("\n\n\nTesting clear_user\n");
  test = vmalloc(PAGE_SIZE);

  for (j = 256; j < 512; j++) {
    t = 0xa5a5a5a5;
    if ((k = clear_user(test + PAGE_SIZE - 256, j)) != j - 256) {
        pr_err("clear_user (%px %d) returned %d\n", test + PAGE_SIZE - 256, j, k);
    }
    if (t != 0xa5a5a5a5) {
       pr_err("v1 was clobbered to 0x%x!\n", t);
    }
  }

  return 0;
}
late_initcall(test_clear_user);

Which demonstrates that v1 is indeed clobbered (MIPS64):

Testing clear_user
v1 was clobbered to 0x1!
v1 was clobbered to 0x2!
v1 was clobbered to 0x3!
v1 was clobbered to 0x4!
v1 was clobbered to 0x5!
v1 was clobbered to 0x6!
v1 was clobbered to 0x7!

Since the number of bytes that could not be set is already contained in
a2, the andi placing a value in v1 is not necessary and actively
harmful in clobbering v1.

Reported-by: James Hogan <jhogan@kernel.org>
Signed-off-by: Matt Redfearn <matt.redfearn@mips.com>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: linux-mips@linux-mips.org
Cc: stable@vger.kernel.org
Patchwork: https://patchwork.linux-mips.org/patch/19109/
Signed-off-by: James Hogan <jhogan@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-04-24 09:32:10 +02:00
..
alchemy pcmcia: db1xxx_ss: fix last irq_to_gpio user 2016-04-20 15:42:09 +09:00
ar7 MIPS: AR7: ensure the port type's FCR value is used 2018-01-23 19:50:18 +01:00
ath25 MIPS: ath25: Check for kzalloc allocation failure 2018-03-18 11:17:49 +01:00
ath79 MIPS: ath79: fix regression in PCI window initialization 2017-07-05 14:37:17 +02:00
bcm47xx MIPS: BCM47XX: Fix LED inversion for WRT54GSv1 2017-11-30 08:37:20 +00:00
bcm63xx
bmips
boot
cavium-octeon MIPS: OCTEON: irq: Check for null return on kzalloc allocation 2018-03-18 11:17:49 +01:00
cobalt
configs MIPS: Update lemote2f_defconfig for CPU_FREQ_STAT change 2017-03-18 19:09:56 +08:00
dec MIPS: DEC: Avoid la pseudo-instruction in delay slots 2017-03-18 19:09:57 +08:00
emma
fw
include MIPS: uaccess: Add micromips clobbers to bzero invocation 2018-04-24 09:32:10 +02:00
jazz
jz4740
kernel MIPS: r2-on-r6-emu: Clear BLTZALL and BGEZALL debugfs counters 2018-03-22 09:23:25 +01:00
kvm KVM: MIPS: Flush KVM entry code from icache globally 2017-01-12 11:22:43 +01:00
lantiq MIPS: Lantiq: Fix another request_mem_region() return code check 2017-10-08 10:14:18 +02:00
lasat
lib MIPS: memset.S: Fix clobber of v1 in last_fixup 2018-04-24 09:32:10 +02:00
loongson32
loongson64 MIPS: hpet: Increase HPET_MIN_PROG_DELTA and decrease HPET_MIN_CYCLES 2016-08-20 18:09:27 +02:00
math-emu MIPS: math-emu: Fix final emulation phase for certain instructions 2017-12-25 14:22:15 +01:00
mm MIPS: mm: fixed mappings: correct initialisation 2018-04-13 19:50:19 +02:00
mti-malta MIPS: Malta: Fix IOCU disable switch read for MIPS64 2016-10-07 15:23:43 +02:00
mti-sead3
net MIPS: BPF: Fix multiple problems in JIT skb access helpers. 2018-03-22 09:23:25 +01:00
netlogic MIPS: Netlogic: Exclude netlogic,xlp-pic code from XLR builds 2017-11-21 09:21:22 +01:00
oprofile
paravirt
pci
pistachio
pmcs-msp71xx
pnx833x
power
ralink MIPS: ralink: Remove ralink_halt() 2018-03-28 18:40:12 +02:00
rb532
sgi-ip22 MIPS: ip22: Fix ip28 build for modern gcc 2017-03-18 19:09:56 +08:00
sgi-ip27
sgi-ip32
sibyte
sni
txx9
vdso MIPS: Fix -mabi=64 build of vdso.lds 2016-10-28 03:01:30 -04:00
vr41xx
xilfpga
Kbuild
Kbuild.platforms
Kconfig MIPS: fix Select HAVE_IRQ_EXIT_ON_IRQ_STACK patch. 2017-04-21 09:30:08 +02:00
Kconfig.debug MIPS: Remove compact branch policy Kconfig entries 2016-09-30 10:18:39 +02:00
Makefile MIPS: Remove compact branch policy Kconfig entries 2016-09-30 10:18:39 +02:00