From: Sasha Levin Date: Tue, 14 Apr 2020 03:00:49 +0000 (-0400) Subject: Fixes for 4.14 X-Git-Tag: v4.19.116~99 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=7e5bf25167078064584b82d3b88264a720a49c19;p=thirdparty%2Fkernel%2Fstable-queue.git Fixes for 4.14 Signed-off-by: Sasha Levin --- diff --git a/queue-4.14/misc-rtsx-set-correct-pcr_ops-for-rts522a.patch b/queue-4.14/misc-rtsx-set-correct-pcr_ops-for-rts522a.patch new file mode 100644 index 00000000000..c5c28a6a8d3 --- /dev/null +++ b/queue-4.14/misc-rtsx-set-correct-pcr_ops-for-rts522a.patch @@ -0,0 +1,37 @@ +From 5ddf24382fdbf53bb543ee7b59cd4e022253cb7a Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 26 Mar 2020 11:26:18 +0800 +Subject: misc: rtsx: set correct pcr_ops for rts522A + +From: YueHaibing + +[ Upstream commit 10cea23b6aae15e8324f4101d785687f2c514fe5 ] + +rts522a should use rts522a_pcr_ops, which is +diffrent with rts5227 in phy/hw init setting. + +Fixes: ce6a5acc9387 ("mfd: rtsx: Add support for rts522A") +Signed-off-by: YueHaibing +Cc: stable +Link: https://lore.kernel.org/r/20200326032618.20472-1-yuehaibing@huawei.com +Signed-off-by: Greg Kroah-Hartman +Signed-off-by: Sasha Levin +--- + drivers/mfd/rts5227.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/drivers/mfd/rts5227.c b/drivers/mfd/rts5227.c +index ff296a4bf3d23..dc6a9432a4b65 100644 +--- a/drivers/mfd/rts5227.c ++++ b/drivers/mfd/rts5227.c +@@ -369,6 +369,7 @@ static const struct pcr_ops rts522a_pcr_ops = { + void rts522a_init_params(struct rtsx_pcr *pcr) + { + rts5227_init_params(pcr); ++ pcr->ops = &rts522a_pcr_ops; + + pcr->reg_pm_ctrl3 = RTS522A_PM_CTRL3; + } +-- +2.20.1 + diff --git a/queue-4.14/series b/queue-4.14/series index 8c68a79d564..e9268836abd 100644 --- a/queue-4.14/series +++ b/queue-4.14/series @@ -26,3 +26,6 @@ locking-lockdep-avoid-recursion-in-lockdep_count_-fo.patch block-bfq-fix-use-after-free-in-bfq_idle_slice_timer.patch btrfs-remove-a-bug_on-from-merge_reloc_roots.patch btrfs-track-reloc-roots-based-on-their-commit-root-b.patch +uapi-rename-ext2_swab-to-swab-and-share-globally-in-.patch +slub-improve-bit-diffusion-for-freelist-ptr-obfuscat.patch +misc-rtsx-set-correct-pcr_ops-for-rts522a.patch diff --git a/queue-4.14/slub-improve-bit-diffusion-for-freelist-ptr-obfuscat.patch b/queue-4.14/slub-improve-bit-diffusion-for-freelist-ptr-obfuscat.patch new file mode 100644 index 00000000000..e22d4af519a --- /dev/null +++ b/queue-4.14/slub-improve-bit-diffusion-for-freelist-ptr-obfuscat.patch @@ -0,0 +1,73 @@ +From 7719f81048b8b169b15711142fb906324a5893db Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 1 Apr 2020 21:04:23 -0700 +Subject: slub: improve bit diffusion for freelist ptr obfuscation + +From: Kees Cook + +[ Upstream commit 1ad53d9fa3f6168ebcf48a50e08b170432da2257 ] + +Under CONFIG_SLAB_FREELIST_HARDENED=y, the obfuscation was relatively weak +in that the ptr and ptr address were usually so close that the first XOR +would result in an almost entirely 0-byte value[1], leaving most of the +"secret" number ultimately being stored after the third XOR. A single +blind memory content exposure of the freelist was generally sufficient to +learn the secret. + +Add a swab() call to mix bits a little more. This is a cheap way (1 +cycle) to make attacks need more than a single exposure to learn the +secret (or to know _where_ the exposure is in memory). + +kmalloc-32 freelist walk, before: + +ptr ptr_addr stored value secret +ffff90c22e019020@ffff90c22e019000 is 86528eb656b3b5bd (86528eb656b3b59d) +ffff90c22e019040@ffff90c22e019020 is 86528eb656b3b5fd (86528eb656b3b59d) +ffff90c22e019060@ffff90c22e019040 is 86528eb656b3b5bd (86528eb656b3b59d) +ffff90c22e019080@ffff90c22e019060 is 86528eb656b3b57d (86528eb656b3b59d) +ffff90c22e0190a0@ffff90c22e019080 is 86528eb656b3b5bd (86528eb656b3b59d) +... + +after: + +ptr ptr_addr stored value secret +ffff9eed6e019020@ffff9eed6e019000 is 793d1135d52cda42 (86528eb656b3b59d) +ffff9eed6e019040@ffff9eed6e019020 is 593d1135d52cda22 (86528eb656b3b59d) +ffff9eed6e019060@ffff9eed6e019040 is 393d1135d52cda02 (86528eb656b3b59d) +ffff9eed6e019080@ffff9eed6e019060 is 193d1135d52cdae2 (86528eb656b3b59d) +ffff9eed6e0190a0@ffff9eed6e019080 is f93d1135d52cdac2 (86528eb656b3b59d) + +[1] https://blog.infosectcbr.com.au/2020/03/weaknesses-in-linux-kernel-heap.html + +Fixes: 2482ddec670f ("mm: add SLUB free list pointer obfuscation") +Reported-by: Silvio Cesare +Signed-off-by: Kees Cook +Signed-off-by: Andrew Morton +Cc: Christoph Lameter +Cc: Pekka Enberg +Cc: David Rientjes +Cc: Joonsoo Kim +Cc: +Link: http://lkml.kernel.org/r/202003051623.AF4F8CB@keescook +Signed-off-by: Linus Torvalds +Signed-off-by: Sasha Levin +--- + mm/slub.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/mm/slub.c b/mm/slub.c +index 958a8f7a3c253..d2db6bc5e788b 100644 +--- a/mm/slub.c ++++ b/mm/slub.c +@@ -248,7 +248,7 @@ static inline void *freelist_ptr(const struct kmem_cache *s, void *ptr, + unsigned long ptr_addr) + { + #ifdef CONFIG_SLAB_FREELIST_HARDENED +- return (void *)((unsigned long)ptr ^ s->random ^ ptr_addr); ++ return (void *)swab((unsigned long)ptr ^ s->random ^ ptr_addr); + #else + return ptr; + #endif +-- +2.20.1 + diff --git a/queue-4.14/uapi-rename-ext2_swab-to-swab-and-share-globally-in-.patch b/queue-4.14/uapi-rename-ext2_swab-to-swab-and-share-globally-in-.patch new file mode 100644 index 00000000000..fda22638adc --- /dev/null +++ b/queue-4.14/uapi-rename-ext2_swab-to-swab-and-share-globally-in-.patch @@ -0,0 +1,117 @@ +From 0bbeedcd728f7204a8385a306fb150a931219614 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 30 Jan 2020 22:16:40 -0800 +Subject: uapi: rename ext2_swab() to swab() and share globally in swab.h + +From: Yury Norov + +[ Upstream commit d5767057c9a76a29f073dad66b7fa12a90e8c748 ] + +ext2_swab() is defined locally in lib/find_bit.c However it is not +specific to ext2, neither to bitmaps. + +There are many potential users of it, so rename it to just swab() and +move to include/uapi/linux/swab.h + +ABI guarantees that size of unsigned long corresponds to BITS_PER_LONG, +therefore drop unneeded cast. + +Link: http://lkml.kernel.org/r/20200103202846.21616-1-yury.norov@gmail.com +Signed-off-by: Yury Norov +Cc: Allison Randal +Cc: Joe Perches +Cc: Thomas Gleixner +Cc: William Breathitt Gray +Signed-off-by: Andrew Morton +Signed-off-by: Linus Torvalds +Signed-off-by: Sasha Levin +--- + include/linux/swab.h | 1 + + include/uapi/linux/swab.h | 10 ++++++++++ + lib/find_bit.c | 16 ++-------------- + 3 files changed, 13 insertions(+), 14 deletions(-) + +diff --git a/include/linux/swab.h b/include/linux/swab.h +index e466fd159c857..bcff5149861a9 100644 +--- a/include/linux/swab.h ++++ b/include/linux/swab.h +@@ -7,6 +7,7 @@ + # define swab16 __swab16 + # define swab32 __swab32 + # define swab64 __swab64 ++# define swab __swab + # define swahw32 __swahw32 + # define swahb32 __swahb32 + # define swab16p __swab16p +diff --git a/include/uapi/linux/swab.h b/include/uapi/linux/swab.h +index 23cd84868cc3b..fa7f97da5b768 100644 +--- a/include/uapi/linux/swab.h ++++ b/include/uapi/linux/swab.h +@@ -4,6 +4,7 @@ + + #include + #include ++#include + #include + + /* +@@ -132,6 +133,15 @@ static inline __attribute_const__ __u32 __fswahb32(__u32 val) + __fswab64(x)) + #endif + ++static __always_inline unsigned long __swab(const unsigned long y) ++{ ++#if BITS_PER_LONG == 64 ++ return __swab64(y); ++#else /* BITS_PER_LONG == 32 */ ++ return __swab32(y); ++#endif ++} ++ + /** + * __swahw32 - return a word-swapped 32-bit value + * @x: value to wordswap +diff --git a/lib/find_bit.c b/lib/find_bit.c +index 6ed74f78380ce..883ef3755a1cb 100644 +--- a/lib/find_bit.c ++++ b/lib/find_bit.c +@@ -133,18 +133,6 @@ EXPORT_SYMBOL(find_last_bit); + + #ifdef __BIG_ENDIAN + +-/* include/linux/byteorder does not support "unsigned long" type */ +-static inline unsigned long ext2_swab(const unsigned long y) +-{ +-#if BITS_PER_LONG == 64 +- return (unsigned long) __swab64((u64) y); +-#elif BITS_PER_LONG == 32 +- return (unsigned long) __swab32((u32) y); +-#else +-#error BITS_PER_LONG not defined +-#endif +-} +- + #if !defined(find_next_bit_le) || !defined(find_next_zero_bit_le) + static unsigned long _find_next_bit_le(const unsigned long *addr, + unsigned long nbits, unsigned long start, unsigned long invert) +@@ -157,7 +145,7 @@ static unsigned long _find_next_bit_le(const unsigned long *addr, + tmp = addr[start / BITS_PER_LONG] ^ invert; + + /* Handle 1st word. */ +- tmp &= ext2_swab(BITMAP_FIRST_WORD_MASK(start)); ++ tmp &= swab(BITMAP_FIRST_WORD_MASK(start)); + start = round_down(start, BITS_PER_LONG); + + while (!tmp) { +@@ -168,7 +156,7 @@ static unsigned long _find_next_bit_le(const unsigned long *addr, + tmp = addr[start / BITS_PER_LONG] ^ invert; + } + +- return min(start + __ffs(ext2_swab(tmp)), nbits); ++ return min(start + __ffs(swab(tmp)), nbits); + } + #endif + +-- +2.20.1 +