From: Greg Kroah-Hartman Date: Fri, 30 Jul 2021 06:36:13 +0000 (+0200) Subject: 4.4-stable patches X-Git-Tag: v5.13.7~12 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=b78e955dd74133eababd49bd050fc7cbb8fbdaba;p=thirdparty%2Fkernel%2Fstable-queue.git 4.4-stable patches added patches: arm-ensure-the-signal-page-contains-defined-contents.patch lib-string.c-add-multibyte-memset-functions.patch --- diff --git a/queue-4.4/arm-dts-versatile-fix-up-interrupt-controller-node-n.patch b/queue-4.4/arm-dts-versatile-fix-up-interrupt-controller-node-n.patch index d0d95c0746a..19da7ca9705 100644 --- a/queue-4.4/arm-dts-versatile-fix-up-interrupt-controller-node-n.patch +++ b/queue-4.4/arm-dts-versatile-fix-up-interrupt-controller-node-n.patch @@ -27,12 +27,10 @@ Link: https://lore.kernel.org/r/20210701132118.759454-1-sudeep.holla@arm.com' Signed-off-by: Arnd Bergmann Signed-off-by: Sasha Levin --- - arch/arm/boot/dts/versatile-ab.dts | 5 ++--- - arch/arm/boot/dts/versatile-pb.dts | 2 +- + arch/arm/boot/dts/versatile-ab.dts | 5 ++--- + arch/arm/boot/dts/versatile-pb.dts | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) -diff --git a/arch/arm/boot/dts/versatile-ab.dts b/arch/arm/boot/dts/versatile-ab.dts -index 3279bf1a17a1..9bedd2478787 100644 --- a/arch/arm/boot/dts/versatile-ab.dts +++ b/arch/arm/boot/dts/versatile-ab.dts @@ -93,16 +93,15 @@ @@ -54,8 +52,6 @@ index 3279bf1a17a1..9bedd2478787 100644 compatible = "arm,versatile-sic"; interrupt-controller; #interrupt-cells = <1>; -diff --git a/arch/arm/boot/dts/versatile-pb.dts b/arch/arm/boot/dts/versatile-pb.dts -index 33a8eb28374e..3a23164c2c2d 100644 --- a/arch/arm/boot/dts/versatile-pb.dts +++ b/arch/arm/boot/dts/versatile-pb.dts @@ -6,7 +6,7 @@ @@ -67,6 +63,3 @@ index 33a8eb28374e..3a23164c2c2d 100644 clear-mask = <0xffffffff>; /* * Valid interrupt lines mask according to --- -2.30.2 - diff --git a/queue-4.4/arm-ensure-the-signal-page-contains-defined-contents.patch b/queue-4.4/arm-ensure-the-signal-page-contains-defined-contents.patch new file mode 100644 index 00000000000..c3e547a4e2b --- /dev/null +++ b/queue-4.4/arm-ensure-the-signal-page-contains-defined-contents.patch @@ -0,0 +1,50 @@ +From 9c698bff66ab4914bb3d71da7dc6112519bde23e Mon Sep 17 00:00:00 2001 +From: Russell King +Date: Fri, 29 Jan 2021 10:19:07 +0000 +Subject: ARM: ensure the signal page contains defined contents + +From: Russell King + +commit 9c698bff66ab4914bb3d71da7dc6112519bde23e upstream. + +Ensure that the signal page contains our poison instruction to increase +the protection against ROP attacks and also contains well defined +contents. + +Acked-by: Will Deacon +Signed-off-by: Russell King +Signed-off-by: Nobuhiro Iwamatsu (CIP) +Signed-off-by: Greg Kroah-Hartman +--- + arch/arm/kernel/signal.c | 14 ++++++++------ + 1 file changed, 8 insertions(+), 6 deletions(-) + +--- a/arch/arm/kernel/signal.c ++++ b/arch/arm/kernel/signal.c +@@ -625,18 +625,20 @@ struct page *get_signal_page(void) + + addr = page_address(page); + ++ /* Poison the entire page */ ++ memset32(addr, __opcode_to_mem_arm(0xe7fddef1), ++ PAGE_SIZE / sizeof(u32)); ++ + /* Give the signal return code some randomness */ + offset = 0x200 + (get_random_int() & 0x7fc); + signal_return_offset = offset; + +- /* +- * Copy signal return handlers into the vector page, and +- * set sigreturn to be a pointer to these. +- */ ++ /* Copy signal return handlers into the page */ + memcpy(addr + offset, sigreturn_codes, sizeof(sigreturn_codes)); + +- ptr = (unsigned long)addr + offset; +- flush_icache_range(ptr, ptr + sizeof(sigreturn_codes)); ++ /* Flush out all instructions in this page */ ++ ptr = (unsigned long)addr; ++ flush_icache_range(ptr, ptr + PAGE_SIZE); + + return page; + } diff --git a/queue-4.4/lib-string.c-add-multibyte-memset-functions.patch b/queue-4.4/lib-string.c-add-multibyte-memset-functions.patch new file mode 100644 index 00000000000..097ba50fa4b --- /dev/null +++ b/queue-4.4/lib-string.c-add-multibyte-memset-functions.patch @@ -0,0 +1,169 @@ +From 3b3c4babd898715926d24ae10aa64778ace33aae Mon Sep 17 00:00:00 2001 +From: Matthew Wilcox +Date: Fri, 8 Sep 2017 16:13:48 -0700 +Subject: lib/string.c: add multibyte memset functions + +From: Matthew Wilcox + +commit 3b3c4babd898715926d24ae10aa64778ace33aae upstream. + +Patch series "Multibyte memset variations", v4. + +A relatively common idiom we're missing is a function to fill an area of +memory with a pattern which is larger than a single byte. I first +noticed this with a zram patch which wanted to fill a page with an +'unsigned long' value. There turn out to be quite a few places in the +kernel which can benefit from using an optimised function rather than a +loop; sometimes text size, sometimes speed, and sometimes both. The +optimised PowerPC version (not included here) improves performance by +about 30% on POWER8 on just the raw memset_l(). + +Most of the extra lines of code come from the three testcases I added. + +This patch (of 8): + +memset16(), memset32() and memset64() are like memset(), but allow the +caller to fill the destination with a value larger than a single byte. +memset_l() and memset_p() allow the caller to use unsigned long and +pointer values respectively. + +Link: http://lkml.kernel.org/r/20170720184539.31609-2-willy@infradead.org +Signed-off-by: Matthew Wilcox +Cc: "H. Peter Anvin" +Cc: "James E.J. Bottomley" +Cc: "Martin K. Petersen" +Cc: David Miller +Cc: Ingo Molnar +Cc: Ivan Kokshaysky +Cc: Matt Turner +Cc: Michael Ellerman +Cc: Minchan Kim +Cc: Ralf Baechle +Cc: Richard Henderson +Cc: Russell King +Cc: Sam Ravnborg +Cc: Sergey Senozhatsky +Cc: Thomas Gleixner +Signed-off-by: Andrew Morton +Signed-off-by: Linus Torvalds +Signed-off-by: Nobuhiro Iwamatsu (CIP) +Signed-off-by: Greg Kroah-Hartman +--- + include/linux/string.h | 30 ++++++++++++++++++++++ + lib/string.c | 66 +++++++++++++++++++++++++++++++++++++++++++++++++ + 2 files changed, 96 insertions(+) + +--- a/include/linux/string.h ++++ b/include/linux/string.h +@@ -102,6 +102,36 @@ extern __kernel_size_t strcspn(const cha + #ifndef __HAVE_ARCH_MEMSET + extern void * memset(void *,int,__kernel_size_t); + #endif ++ ++#ifndef __HAVE_ARCH_MEMSET16 ++extern void *memset16(uint16_t *, uint16_t, __kernel_size_t); ++#endif ++ ++#ifndef __HAVE_ARCH_MEMSET32 ++extern void *memset32(uint32_t *, uint32_t, __kernel_size_t); ++#endif ++ ++#ifndef __HAVE_ARCH_MEMSET64 ++extern void *memset64(uint64_t *, uint64_t, __kernel_size_t); ++#endif ++ ++static inline void *memset_l(unsigned long *p, unsigned long v, ++ __kernel_size_t n) ++{ ++ if (BITS_PER_LONG == 32) ++ return memset32((uint32_t *)p, v, n); ++ else ++ return memset64((uint64_t *)p, v, n); ++} ++ ++static inline void *memset_p(void **p, void *v, __kernel_size_t n) ++{ ++ if (BITS_PER_LONG == 32) ++ return memset32((uint32_t *)p, (uintptr_t)v, n); ++ else ++ return memset64((uint64_t *)p, (uintptr_t)v, n); ++} ++ + #ifndef __HAVE_ARCH_MEMCPY + extern void * memcpy(void *,const void *,__kernel_size_t); + #endif +--- a/lib/string.c ++++ b/lib/string.c +@@ -728,6 +728,72 @@ void memzero_explicit(void *s, size_t co + } + EXPORT_SYMBOL(memzero_explicit); + ++#ifndef __HAVE_ARCH_MEMSET16 ++/** ++ * memset16() - Fill a memory area with a uint16_t ++ * @s: Pointer to the start of the area. ++ * @v: The value to fill the area with ++ * @count: The number of values to store ++ * ++ * Differs from memset() in that it fills with a uint16_t instead ++ * of a byte. Remember that @count is the number of uint16_ts to ++ * store, not the number of bytes. ++ */ ++void *memset16(uint16_t *s, uint16_t v, size_t count) ++{ ++ uint16_t *xs = s; ++ ++ while (count--) ++ *xs++ = v; ++ return s; ++} ++EXPORT_SYMBOL(memset16); ++#endif ++ ++#ifndef __HAVE_ARCH_MEMSET32 ++/** ++ * memset32() - Fill a memory area with a uint32_t ++ * @s: Pointer to the start of the area. ++ * @v: The value to fill the area with ++ * @count: The number of values to store ++ * ++ * Differs from memset() in that it fills with a uint32_t instead ++ * of a byte. Remember that @count is the number of uint32_ts to ++ * store, not the number of bytes. ++ */ ++void *memset32(uint32_t *s, uint32_t v, size_t count) ++{ ++ uint32_t *xs = s; ++ ++ while (count--) ++ *xs++ = v; ++ return s; ++} ++EXPORT_SYMBOL(memset32); ++#endif ++ ++#ifndef __HAVE_ARCH_MEMSET64 ++/** ++ * memset64() - Fill a memory area with a uint64_t ++ * @s: Pointer to the start of the area. ++ * @v: The value to fill the area with ++ * @count: The number of values to store ++ * ++ * Differs from memset() in that it fills with a uint64_t instead ++ * of a byte. Remember that @count is the number of uint64_ts to ++ * store, not the number of bytes. ++ */ ++void *memset64(uint64_t *s, uint64_t v, size_t count) ++{ ++ uint64_t *xs = s; ++ ++ while (count--) ++ *xs++ = v; ++ return s; ++} ++EXPORT_SYMBOL(memset64); ++#endif ++ + #ifndef __HAVE_ARCH_MEMCPY + /** + * memcpy - Copy one area of memory to another diff --git a/queue-4.4/series b/queue-4.4/series index 546a0939c58..e9bd3dce2c4 100644 --- a/queue-4.4/series +++ b/queue-4.4/series @@ -8,3 +8,5 @@ hfs-add-missing-clean-up-in-hfs_fill_super.patch hfs-fix-high-memory-mapping-in-hfs_bnode_read.patch hfs-add-lock-nesting-notation-to-hfs_find_init.patch arm-dts-versatile-fix-up-interrupt-controller-node-n.patch +lib-string.c-add-multibyte-memset-functions.patch +arm-ensure-the-signal-page-contains-defined-contents.patch