From: Greg Kroah-Hartman Date: Wed, 24 Apr 2019 13:53:41 +0000 (+0200) Subject: 4.19-stable patches X-Git-Tag: v3.18.139~22 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=e608a319048a76091c04c22c763ebfef0cfe3de9;p=thirdparty%2Fkernel%2Fstable-queue.git 4.19-stable patches added patches: alsa-info-fix-racy-addition-deletion-of-nodes.patch device_cgroup-fix-rcu-imbalance-in-error-case.patch mm-vmstat.c-fix-proc-vmstat-format-for-config_debug_tlbflush-y-config_smp-n.patch percpu-stop-printing-kernel-addresses.patch tools-include-adopt-linux-bits.h.patch --- diff --git a/queue-4.19/alsa-info-fix-racy-addition-deletion-of-nodes.patch b/queue-4.19/alsa-info-fix-racy-addition-deletion-of-nodes.patch new file mode 100644 index 00000000000..984d97d731c --- /dev/null +++ b/queue-4.19/alsa-info-fix-racy-addition-deletion-of-nodes.patch @@ -0,0 +1,59 @@ +From 8c2f870890fd28e023b0fcf49dcee333f2c8bad7 Mon Sep 17 00:00:00 2001 +From: Takashi Iwai +Date: Tue, 16 Apr 2019 15:25:00 +0200 +Subject: ALSA: info: Fix racy addition/deletion of nodes + +From: Takashi Iwai + +commit 8c2f870890fd28e023b0fcf49dcee333f2c8bad7 upstream. + +The ALSA proc helper manages the child nodes in a linked list, but its +addition and deletion is done without any lock. This leads to a +corruption if they are operated concurrently. Usually this isn't a +problem because the proc entries are added sequentially in the driver +probe procedure itself. But the card registrations are done often +asynchronously, and the crash could be actually reproduced with +syzkaller. + +This patch papers over it by protecting the link addition and deletion +with the parent's mutex. There is "access" mutex that is used for the +file access, and this can be reused for this purpose as well. + +Reported-by: syzbot+48df349490c36f9f54ab@syzkaller.appspotmail.com +Cc: +Signed-off-by: Takashi Iwai +Signed-off-by: Greg Kroah-Hartman + +--- + sound/core/info.c | 12 ++++++++++-- + 1 file changed, 10 insertions(+), 2 deletions(-) + +--- a/sound/core/info.c ++++ b/sound/core/info.c +@@ -722,8 +722,11 @@ snd_info_create_entry(const char *name, + INIT_LIST_HEAD(&entry->children); + INIT_LIST_HEAD(&entry->list); + entry->parent = parent; +- if (parent) ++ if (parent) { ++ mutex_lock(&parent->access); + list_add_tail(&entry->list, &parent->children); ++ mutex_unlock(&parent->access); ++ } + return entry; + } + +@@ -805,7 +808,12 @@ void snd_info_free_entry(struct snd_info + list_for_each_entry_safe(p, n, &entry->children, list) + snd_info_free_entry(p); + +- list_del(&entry->list); ++ p = entry->parent; ++ if (p) { ++ mutex_lock(&p->access); ++ list_del(&entry->list); ++ mutex_unlock(&p->access); ++ } + kfree(entry->name); + if (entry->private_free) + entry->private_free(entry); diff --git a/queue-4.19/device_cgroup-fix-rcu-imbalance-in-error-case.patch b/queue-4.19/device_cgroup-fix-rcu-imbalance-in-error-case.patch new file mode 100644 index 00000000000..593340ed35c --- /dev/null +++ b/queue-4.19/device_cgroup-fix-rcu-imbalance-in-error-case.patch @@ -0,0 +1,42 @@ +From 0fcc4c8c044e117ac126ab6df4138ea9a67fa2a9 Mon Sep 17 00:00:00 2001 +From: Jann Horn +Date: Tue, 19 Mar 2019 02:36:59 +0100 +Subject: device_cgroup: fix RCU imbalance in error case + +From: Jann Horn + +commit 0fcc4c8c044e117ac126ab6df4138ea9a67fa2a9 upstream. + +When dev_exception_add() returns an error (due to a failed memory +allocation), make sure that we move the RCU preemption count back to where +it was before we were called. We dropped the RCU read lock inside the loop +body, so we can't just "break". + +sparse complains about this, too: + +$ make -s C=2 security/device_cgroup.o +./include/linux/rcupdate.h:647:9: warning: context imbalance in +'propagate_exception' - unexpected unlock + +Fixes: d591fb56618f ("device_cgroup: simplify cgroup tree walk in propagate_exception()") +Cc: stable@vger.kernel.org +Signed-off-by: Jann Horn +Acked-by: Michal Hocko +Signed-off-by: Tejun Heo +Signed-off-by: Greg Kroah-Hartman + +--- + security/device_cgroup.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/security/device_cgroup.c ++++ b/security/device_cgroup.c +@@ -560,7 +560,7 @@ static int propagate_exception(struct de + devcg->behavior == DEVCG_DEFAULT_ALLOW) { + rc = dev_exception_add(devcg, ex); + if (rc) +- break; ++ return rc; + } else { + /* + * in the other possible cases: diff --git a/queue-4.19/mm-vmstat.c-fix-proc-vmstat-format-for-config_debug_tlbflush-y-config_smp-n.patch b/queue-4.19/mm-vmstat.c-fix-proc-vmstat-format-for-config_debug_tlbflush-y-config_smp-n.patch new file mode 100644 index 00000000000..89852606897 --- /dev/null +++ b/queue-4.19/mm-vmstat.c-fix-proc-vmstat-format-for-config_debug_tlbflush-y-config_smp-n.patch @@ -0,0 +1,50 @@ +From e8277b3b52240ec1caad8e6df278863e4bf42eac Mon Sep 17 00:00:00 2001 +From: Konstantin Khlebnikov +Date: Thu, 18 Apr 2019 17:50:20 -0700 +Subject: mm/vmstat.c: fix /proc/vmstat format for CONFIG_DEBUG_TLBFLUSH=y CONFIG_SMP=n + +From: Konstantin Khlebnikov + +commit e8277b3b52240ec1caad8e6df278863e4bf42eac upstream. + +Commit 58bc4c34d249 ("mm/vmstat.c: skip NR_TLB_REMOTE_FLUSH* properly") +depends on skipping vmstat entries with empty name introduced in +7aaf77272358 ("mm: don't show nr_indirectly_reclaimable in +/proc/vmstat") but reverted in b29940c1abd7 ("mm: rename and change +semantics of nr_indirectly_reclaimable_bytes"). + +So skipping no longer works and /proc/vmstat has misformatted lines " 0". + +This patch simply shows debug counters "nr_tlb_remote_*" for UP. + +Link: http://lkml.kernel.org/r/155481488468.467.4295519102880913454.stgit@buzz +Fixes: 58bc4c34d249 ("mm/vmstat.c: skip NR_TLB_REMOTE_FLUSH* properly") +Signed-off-by: Konstantin Khlebnikov +Acked-by: Vlastimil Babka +Cc: Roman Gushchin +Cc: Jann Horn +Cc: +Signed-off-by: Andrew Morton +Signed-off-by: Linus Torvalds +Signed-off-by: Greg Kroah-Hartman + +--- + mm/vmstat.c | 5 ----- + 1 file changed, 5 deletions(-) + +--- a/mm/vmstat.c ++++ b/mm/vmstat.c +@@ -1272,13 +1272,8 @@ const char * const vmstat_text[] = { + #endif + #endif /* CONFIG_MEMORY_BALLOON */ + #ifdef CONFIG_DEBUG_TLBFLUSH +-#ifdef CONFIG_SMP + "nr_tlb_remote_flush", + "nr_tlb_remote_flush_received", +-#else +- "", /* nr_tlb_remote_flush */ +- "", /* nr_tlb_remote_flush_received */ +-#endif /* CONFIG_SMP */ + "nr_tlb_local_flush_all", + "nr_tlb_local_flush_one", + #endif /* CONFIG_DEBUG_TLBFLUSH */ diff --git a/queue-4.19/percpu-stop-printing-kernel-addresses.patch b/queue-4.19/percpu-stop-printing-kernel-addresses.patch new file mode 100644 index 00000000000..1037b7b7d9b --- /dev/null +++ b/queue-4.19/percpu-stop-printing-kernel-addresses.patch @@ -0,0 +1,50 @@ +From 00206a69ee32f03e6f40837684dcbe475ea02266 Mon Sep 17 00:00:00 2001 +From: Matteo Croce +Date: Mon, 18 Mar 2019 02:32:36 +0100 +Subject: percpu: stop printing kernel addresses + +From: Matteo Croce + +commit 00206a69ee32f03e6f40837684dcbe475ea02266 upstream. + +Since commit ad67b74d2469d9b8 ("printk: hash addresses printed with %p"), +at boot "____ptrval____" is printed instead of actual addresses: + + percpu: Embedded 38 pages/cpu @(____ptrval____) s124376 r0 d31272 u524288 + +Instead of changing the print to "%px", and leaking kernel addresses, +just remove the print completely, cfr. e.g. commit 071929dbdd865f77 +("arm64: Stop printing the virtual memory layout"). + +Signed-off-by: Matteo Croce +Signed-off-by: Dennis Zhou +Signed-off-by: Greg Kroah-Hartman + +--- + mm/percpu.c | 8 ++++---- + 1 file changed, 4 insertions(+), 4 deletions(-) + +--- a/mm/percpu.c ++++ b/mm/percpu.c +@@ -2529,8 +2529,8 @@ int __init pcpu_embed_first_chunk(size_t + ai->groups[group].base_offset = areas[group] - base; + } + +- pr_info("Embedded %zu pages/cpu @%p s%zu r%zu d%zu u%zu\n", +- PFN_DOWN(size_sum), base, ai->static_size, ai->reserved_size, ++ pr_info("Embedded %zu pages/cpu s%zu r%zu d%zu u%zu\n", ++ PFN_DOWN(size_sum), ai->static_size, ai->reserved_size, + ai->dyn_size, ai->unit_size); + + rc = pcpu_setup_first_chunk(ai, base); +@@ -2651,8 +2651,8 @@ int __init pcpu_page_first_chunk(size_t + } + + /* we're ready, commit */ +- pr_info("%d %s pages/cpu @%p s%zu r%zu d%zu\n", +- unit_pages, psize_str, vm.addr, ai->static_size, ++ pr_info("%d %s pages/cpu s%zu r%zu d%zu\n", ++ unit_pages, psize_str, ai->static_size, + ai->reserved_size, ai->dyn_size); + + rc = pcpu_setup_first_chunk(ai, vm.addr); diff --git a/queue-4.19/series b/queue-4.19/series index fab235f0929..c0b45320042 100644 --- a/queue-4.19/series +++ b/queue-4.19/series @@ -87,3 +87,8 @@ tpm-tpm_i2c_atmel-return-e2big-when-the-transfer-is-.patch tpm-fix-the-type-of-the-return-value-in-calc_tpm2_ev.patch revert-kbuild-use-oz-instead-of-os-when-using-clang.patch sched-fair-limit-sched_cfs_period_timer-loop-to-avoi.patch +device_cgroup-fix-rcu-imbalance-in-error-case.patch +mm-vmstat.c-fix-proc-vmstat-format-for-config_debug_tlbflush-y-config_smp-n.patch +alsa-info-fix-racy-addition-deletion-of-nodes.patch +percpu-stop-printing-kernel-addresses.patch +tools-include-adopt-linux-bits.h.patch diff --git a/queue-4.19/tools-include-adopt-linux-bits.h.patch b/queue-4.19/tools-include-adopt-linux-bits.h.patch new file mode 100644 index 00000000000..bb1d4d62516 --- /dev/null +++ b/queue-4.19/tools-include-adopt-linux-bits.h.patch @@ -0,0 +1,98 @@ +From ba4aa02b417f08a0bee5e7b8ed70cac788a7c854 Mon Sep 17 00:00:00 2001 +From: Arnaldo Carvalho de Melo +Date: Tue, 25 Sep 2018 10:55:59 -0300 +Subject: tools include: Adopt linux/bits.h + +From: Arnaldo Carvalho de Melo + +commit ba4aa02b417f08a0bee5e7b8ed70cac788a7c854 upstream. + +So that we reduce the difference of tools/include/linux/bitops.h to the +original kernel file, include/linux/bitops.h, trying to remove the need +to define BITS_PER_LONG, to avoid clashes with asm/bitsperlong.h. + +And the things removed from tools/include/linux/bitops.h are really in +linux/bits.h, so that we can have a copy and then +tools/perf/check_headers.sh will tell us when new stuff gets added to +linux/bits.h so that we can check if it is useful and if any adjustment +needs to be done to the tools/{include,arch}/ copies. + +Cc: Adrian Hunter +Cc: Alexander Sverdlin +Cc: David Ahern +Cc: Jiri Olsa +Cc: Namhyung Kim +Cc: Wang Nan +Link: https://lkml.kernel.org/n/tip-y1sqyydvfzo0bjjoj4zsl562@git.kernel.org +Signed-off-by: Arnaldo Carvalho de Melo +Signed-off-by: Greg Kroah-Hartman + +--- + tools/include/linux/bitops.h | 7 ++----- + tools/include/linux/bits.h | 26 ++++++++++++++++++++++++++ + tools/perf/check-headers.sh | 1 + + 3 files changed, 29 insertions(+), 5 deletions(-) + +--- a/tools/include/linux/bitops.h ++++ b/tools/include/linux/bitops.h +@@ -3,8 +3,6 @@ + #define _TOOLS_LINUX_BITOPS_H_ + + #include +-#include +- + #ifndef __WORDSIZE + #define __WORDSIZE (__SIZEOF_LONG__ * 8) + #endif +@@ -12,10 +10,9 @@ + #ifndef BITS_PER_LONG + # define BITS_PER_LONG __WORDSIZE + #endif ++#include ++#include + +-#define BIT_MASK(nr) (1UL << ((nr) % BITS_PER_LONG)) +-#define BIT_WORD(nr) ((nr) / BITS_PER_LONG) +-#define BITS_PER_BYTE 8 + #define BITS_TO_LONGS(nr) DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(long)) + #define BITS_TO_U64(nr) DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(u64)) + #define BITS_TO_U32(nr) DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(u32)) +--- /dev/null ++++ b/tools/include/linux/bits.h +@@ -0,0 +1,26 @@ ++/* SPDX-License-Identifier: GPL-2.0 */ ++#ifndef __LINUX_BITS_H ++#define __LINUX_BITS_H ++#include ++ ++#define BIT(nr) (1UL << (nr)) ++#define BIT_ULL(nr) (1ULL << (nr)) ++#define BIT_MASK(nr) (1UL << ((nr) % BITS_PER_LONG)) ++#define BIT_WORD(nr) ((nr) / BITS_PER_LONG) ++#define BIT_ULL_MASK(nr) (1ULL << ((nr) % BITS_PER_LONG_LONG)) ++#define BIT_ULL_WORD(nr) ((nr) / BITS_PER_LONG_LONG) ++#define BITS_PER_BYTE 8 ++ ++/* ++ * Create a contiguous bitmask starting at bit position @l and ending at ++ * position @h. For example ++ * GENMASK_ULL(39, 21) gives us the 64bit vector 0x000000ffffe00000. ++ */ ++#define GENMASK(h, l) \ ++ (((~0UL) - (1UL << (l)) + 1) & (~0UL >> (BITS_PER_LONG - 1 - (h)))) ++ ++#define GENMASK_ULL(h, l) \ ++ (((~0ULL) - (1ULL << (l)) + 1) & \ ++ (~0ULL >> (BITS_PER_LONG_LONG - 1 - (h)))) ++ ++#endif /* __LINUX_BITS_H */ +--- a/tools/perf/check-headers.sh ++++ b/tools/perf/check-headers.sh +@@ -14,6 +14,7 @@ include/uapi/linux/sched.h + include/uapi/linux/stat.h + include/uapi/linux/vhost.h + include/uapi/sound/asound.h ++include/linux/bits.h + include/linux/hash.h + include/uapi/linux/hw_breakpoint.h + arch/x86/include/asm/disabled-features.h