From: Greg Kroah-Hartman Date: Wed, 1 Apr 2020 15:17:00 +0000 (+0200) Subject: 4.9-stable patches X-Git-Tag: v5.6.2~5 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=c520f85224a64e94645d733270d33da425ed8fa9;p=thirdparty%2Fkernel%2Fstable-queue.git 4.9-stable patches added patches: arm64-alternative-fix-build-with-clang-integrated-assembler.patch net-ks8851-ml-fix-io-operations-again.patch perf-map-fix-off-by-one-in-strncpy-size-argument.patch --- diff --git a/queue-4.9/arm64-alternative-fix-build-with-clang-integrated-assembler.patch b/queue-4.9/arm64-alternative-fix-build-with-clang-integrated-assembler.patch new file mode 100644 index 00000000000..c20c089fa59 --- /dev/null +++ b/queue-4.9/arm64-alternative-fix-build-with-clang-integrated-assembler.patch @@ -0,0 +1,47 @@ +From 6f5459da2b8736720afdbd67c4bd2d1edba7d0e3 Mon Sep 17 00:00:00 2001 +From: Ilie Halip +Date: Thu, 19 Mar 2020 23:45:28 +0200 +Subject: arm64: alternative: fix build with clang integrated assembler + +From: Ilie Halip + +commit 6f5459da2b8736720afdbd67c4bd2d1edba7d0e3 upstream. + +Building an arm64 defconfig with clang's integrated assembler, this error +occurs: + :2:2: error: unrecognized instruction mnemonic + _ASM_EXTABLE 9999b, 9f + ^ + arch/arm64/mm/cache.S:50:1: note: while in macro instantiation + user_alt 9f, "dc cvau, x4", "dc civac, x4", 0 + ^ + +While GNU as seems fine with case-sensitive macro instantiations, clang +doesn't, so use the actual macro name (_asm_extable) as in the rest of +the file. + +Also checked that the generated assembly matches the GCC output. + +Reviewed-by: Nick Desaulniers +Tested-by: Nick Desaulniers +Fixes: 290622efc76e ("arm64: fix "dc cvau" cache operation on errata-affected core") +Link: https://github.com/ClangBuiltLinux/linux/issues/924 +Signed-off-by: Ilie Halip +Signed-off-by: Will Deacon +Signed-off-by: Greg Kroah-Hartman + +--- + arch/arm64/include/asm/alternative.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/arch/arm64/include/asm/alternative.h ++++ b/arch/arm64/include/asm/alternative.h +@@ -215,7 +215,7 @@ alternative_endif + + .macro user_alt, label, oldinstr, newinstr, cond + 9999: alternative_insn "\oldinstr", "\newinstr", \cond +- _ASM_EXTABLE 9999b, \label ++ _asm_extable 9999b, \label + .endm + + /* diff --git a/queue-4.9/net-ks8851-ml-fix-io-operations-again.patch b/queue-4.9/net-ks8851-ml-fix-io-operations-again.patch new file mode 100644 index 00000000000..073a96ff1b4 --- /dev/null +++ b/queue-4.9/net-ks8851-ml-fix-io-operations-again.patch @@ -0,0 +1,137 @@ +From 8262e6f9b1034ede34548a04dec4c302d92c9497 Mon Sep 17 00:00:00 2001 +From: Marek Vasut +Date: Wed, 25 Mar 2020 15:25:47 +0100 +Subject: net: ks8851-ml: Fix IO operations, again + +From: Marek Vasut + +commit 8262e6f9b1034ede34548a04dec4c302d92c9497 upstream. + +This patch reverts 58292104832f ("net: ks8851-ml: Fix 16-bit IO operation") +and edacb098ea9c ("net: ks8851-ml: Fix 16-bit data access"), because it +turns out these were only necessary due to buggy hardware. This patch adds +a check for such a buggy hardware to prevent any such mistakes again. + +While working further on the KS8851 driver, it came to light that the +KS8851-16MLL is capable of switching bus endianness by a hardware strap, +EESK pin. If this strap is incorrect, the IO accesses require such endian +swapping as is being reverted by this patch. Such swapping also impacts +the performance significantly. + +Hence, in addition to removing it, detect that the hardware is broken, +report to user, and fail to bind with such hardware. + +Fixes: 58292104832f ("net: ks8851-ml: Fix 16-bit IO operation") +Fixes: edacb098ea9c ("net: ks8851-ml: Fix 16-bit data access") +Signed-off-by: Marek Vasut +Cc: David S. Miller +Cc: Lukas Wunner +Cc: Petr Stetiar +Cc: YueHaibing +Signed-off-by: David S. Miller +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/net/ethernet/micrel/ks8851_mll.c | 56 ++++++++++++++++++++++++++++--- + 1 file changed, 52 insertions(+), 4 deletions(-) + +--- a/drivers/net/ethernet/micrel/ks8851_mll.c ++++ b/drivers/net/ethernet/micrel/ks8851_mll.c +@@ -475,6 +475,50 @@ static int msg_enable; + */ + + /** ++ * ks_check_endian - Check whether endianness of the bus is correct ++ * @ks : The chip information ++ * ++ * The KS8851-16MLL EESK pin allows selecting the endianness of the 16bit ++ * bus. To maintain optimum performance, the bus endianness should be set ++ * such that it matches the endianness of the CPU. ++ */ ++ ++static int ks_check_endian(struct ks_net *ks) ++{ ++ u16 cider; ++ ++ /* ++ * Read CIDER register first, however read it the "wrong" way around. ++ * If the endian strap on the KS8851-16MLL in incorrect and the chip ++ * is operating in different endianness than the CPU, then the meaning ++ * of BE[3:0] byte-enable bits is also swapped such that: ++ * BE[3,2,1,0] becomes BE[1,0,3,2] ++ * ++ * Luckily for us, the byte-enable bits are the top four MSbits of ++ * the address register and the CIDER register is at offset 0xc0. ++ * Hence, by reading address 0xc0c0, which is not impacted by endian ++ * swapping, we assert either BE[3:2] or BE[1:0] while reading the ++ * CIDER register. ++ * ++ * If the bus configuration is correct, reading 0xc0c0 asserts ++ * BE[3:2] and this read returns 0x0000, because to read register ++ * with bottom two LSbits of address set to 0, BE[1:0] must be ++ * asserted. ++ * ++ * If the bus configuration is NOT correct, reading 0xc0c0 asserts ++ * BE[1:0] and this read returns non-zero 0x8872 value. ++ */ ++ iowrite16(BE3 | BE2 | KS_CIDER, ks->hw_addr_cmd); ++ cider = ioread16(ks->hw_addr); ++ if (!cider) ++ return 0; ++ ++ netdev_err(ks->netdev, "incorrect EESK endian strap setting\n"); ++ ++ return -EINVAL; ++} ++ ++/** + * ks_rdreg16 - read 16 bit register from device + * @ks : The chip information + * @offset: The register address +@@ -484,7 +528,7 @@ static int msg_enable; + + static u16 ks_rdreg16(struct ks_net *ks, int offset) + { +- ks->cmd_reg_cache = (u16)offset | ((BE3 | BE2) >> (offset & 0x02)); ++ ks->cmd_reg_cache = (u16)offset | ((BE1 | BE0) << (offset & 0x02)); + iowrite16(ks->cmd_reg_cache, ks->hw_addr_cmd); + return ioread16(ks->hw_addr); + } +@@ -499,7 +543,7 @@ static u16 ks_rdreg16(struct ks_net *ks, + + static void ks_wrreg16(struct ks_net *ks, int offset, u16 value) + { +- ks->cmd_reg_cache = (u16)offset | ((BE3 | BE2) >> (offset & 0x02)); ++ ks->cmd_reg_cache = (u16)offset | ((BE1 | BE0) << (offset & 0x02)); + iowrite16(ks->cmd_reg_cache, ks->hw_addr_cmd); + iowrite16(value, ks->hw_addr); + } +@@ -515,7 +559,7 @@ static inline void ks_inblk(struct ks_ne + { + len >>= 1; + while (len--) +- *wptr++ = be16_to_cpu(ioread16(ks->hw_addr)); ++ *wptr++ = (u16)ioread16(ks->hw_addr); + } + + /** +@@ -529,7 +573,7 @@ static inline void ks_outblk(struct ks_n + { + len >>= 1; + while (len--) +- iowrite16(cpu_to_be16(*wptr++), ks->hw_addr); ++ iowrite16(*wptr++, ks->hw_addr); + } + + static void ks_disable_int(struct ks_net *ks) +@@ -1535,6 +1579,10 @@ static int ks8851_probe(struct platform_ + goto err_free; + } + ++ err = ks_check_endian(ks); ++ if (err) ++ goto err_free; ++ + netdev->irq = platform_get_irq(pdev, 0); + + if ((int)netdev->irq < 0) { diff --git a/queue-4.9/perf-map-fix-off-by-one-in-strncpy-size-argument.patch b/queue-4.9/perf-map-fix-off-by-one-in-strncpy-size-argument.patch new file mode 100644 index 00000000000..d40ee44b648 --- /dev/null +++ b/queue-4.9/perf-map-fix-off-by-one-in-strncpy-size-argument.patch @@ -0,0 +1,55 @@ +From db2c549407d4a76563c579e4768f7d6d32afefba Mon Sep 17 00:00:00 2001 +From: disconnect3d +Date: Mon, 9 Mar 2020 11:48:53 +0100 +Subject: perf map: Fix off by one in strncpy() size argument + +From: disconnect3d + +commit db2c549407d4a76563c579e4768f7d6d32afefba upstream. + +This patch fixes an off-by-one error in strncpy size argument in +tools/perf/util/map.c. The issue is that in: + + strncmp(filename, "/system/lib/", 11) + +the passed string literal: "/system/lib/" has 12 bytes (without the NULL +byte) and the passed size argument is 11. As a result, the logic won't +match the ending "/" byte and will pass filepaths that are stored in +other directories e.g. "/system/libmalicious/bin" or just +"/system/libmalicious". + +This functionality seems to be present only on Android. I assume the +/system/ directory is only writable by the root user, so I don't think +this bug has much (or any) security impact. + +Fixes: eca818369996 ("perf tools: Add automatic remapping of Android libraries") +Signed-off-by: disconnect3d +Cc: Alexander Shishkin +Cc: Changbin Du +Cc: Jiri Olsa +Cc: John Keeping +Cc: Mark Rutland +Cc: Michael Lentine +Cc: Namhyung Kim +Cc: Peter Zijlstra +Cc: Song Liu +Cc: Stephane Eranian +Link: http://lore.kernel.org/lkml/20200309104855.3775-1-dominik.b.czarnota@gmail.com +Signed-off-by: Arnaldo Carvalho de Melo +Signed-off-by: Greg Kroah-Hartman + +--- + tools/perf/util/map.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/tools/perf/util/map.c ++++ b/tools/perf/util/map.c +@@ -88,7 +88,7 @@ static inline bool replace_android_lib(c + return true; + } + +- if (!strncmp(filename, "/system/lib/", 11)) { ++ if (!strncmp(filename, "/system/lib/", 12)) { + char *ndk, *app; + const char *arch; + size_t ndk_length; diff --git a/queue-4.9/series b/queue-4.9/series index c92398b059b..570d81cfc99 100644 --- a/queue-4.9/series +++ b/queue-4.9/series @@ -97,3 +97,6 @@ vt-vt_ioctl-fix-vt_disallocate-freeing-in-use-virtual-console.patch locking-atomic-kref-add-kref_read.patch vt-vt_ioctl-fix-use-after-free-in-vt_in_use.patch bpf-explicitly-memset-the-bpf_attr-structure.patch +net-ks8851-ml-fix-io-operations-again.patch +arm64-alternative-fix-build-with-clang-integrated-assembler.patch +perf-map-fix-off-by-one-in-strncpy-size-argument.patch