From 15926eb9085f92db28e342cca12cfd9d32cc248b Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Fri, 5 Feb 2021 10:02:11 +0100 Subject: [PATCH] 4.14-stable patches added patches: base-core-remove-warn_on-from-link-dependencies-check.patch driver-core-extend-device_is_dependent.patch net_sched-gen_estimator-support-large-ewma-log.patch --- ...warn_on-from-link-dependencies-check.patch | 47 ++++++++++ ...iver-core-extend-device_is_dependent.patch | 67 ++++++++++++++ ...gen_estimator-support-large-ewma-log.patch | 90 +++++++++++++++++++ queue-4.14/series | 3 + 4 files changed, 207 insertions(+) create mode 100644 queue-4.14/base-core-remove-warn_on-from-link-dependencies-check.patch create mode 100644 queue-4.14/driver-core-extend-device_is_dependent.patch create mode 100644 queue-4.14/net_sched-gen_estimator-support-large-ewma-log.patch diff --git a/queue-4.14/base-core-remove-warn_on-from-link-dependencies-check.patch b/queue-4.14/base-core-remove-warn_on-from-link-dependencies-check.patch new file mode 100644 index 00000000000..84eded646f8 --- /dev/null +++ b/queue-4.14/base-core-remove-warn_on-from-link-dependencies-check.patch @@ -0,0 +1,47 @@ +From foo@baz Fri Feb 5 09:58:09 AM CET 2021 +From: Benjamin Gaignard +Date: Mon, 16 Jul 2018 13:37:44 +0200 +Subject: base: core: Remove WARN_ON from link dependencies check + +From: Benjamin Gaignard + +commit e16f4f3e0b7daecd48d4f944ab4147c1a6cb16a8 upstream + +In some cases the link between between customer and supplier +already exist, for example when a device use its parent as a supplier. +Do not warn about already existing dependencies because device_link_add() +takes care of this case. + +Link: http://lkml.kernel.org/r/20180709111753eucas1p1f32e66fb2f7ea3216097cd72a132355d~-rzycA5Rg0378203782eucas1p1C@eucas1p1.samsung.com + +Reported-by: Marek Szyprowski +Reviewed-by: Mark Brown +Signed-off-by: Benjamin Gaignard +Reviewed-by: Rafael J. Wysocki +Signed-off-by: Greg Kroah-Hartman +Signed-off-by: Sudip Mukherjee +Signed-off-by: Greg Kroah-Hartman +--- + drivers/base/core.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +--- a/drivers/base/core.c ++++ b/drivers/base/core.c +@@ -109,7 +109,7 @@ static int device_is_dependent(struct de + struct device_link *link; + int ret; + +- if (WARN_ON(dev == target)) ++ if (dev == target) + return 1; + + ret = device_for_each_child(dev, target, device_is_dependent); +@@ -117,7 +117,7 @@ static int device_is_dependent(struct de + return ret; + + list_for_each_entry(link, &dev->links.consumers, s_node) { +- if (WARN_ON(link->consumer == target)) ++ if (link->consumer == target) + return 1; + + ret = device_is_dependent(link->consumer, target); diff --git a/queue-4.14/driver-core-extend-device_is_dependent.patch b/queue-4.14/driver-core-extend-device_is_dependent.patch new file mode 100644 index 00000000000..7c3308e6284 --- /dev/null +++ b/queue-4.14/driver-core-extend-device_is_dependent.patch @@ -0,0 +1,67 @@ +From foo@baz Fri Feb 5 09:58:31 AM CET 2021 +From: "Rafael J. Wysocki" +Date: Fri, 15 Jan 2021 19:30:51 +0100 +Subject: driver core: Extend device_is_dependent() + +From: "Rafael J. Wysocki" + +commit 3d1cf435e201d1fd63e4346b141881aed086effd upstream + +If the device passed as the target (second argument) to +device_is_dependent() is not completely registered (that is, it has +been initialized, but not added yet), but the parent pointer of it +is set, it may be missing from the list of the parent's children +and device_for_each_child() called by device_is_dependent() cannot +be relied on to catch that dependency. + +For this reason, modify device_is_dependent() to check the ancestors +of the target device by following its parent pointer in addition to +the device_for_each_child() walk. + +Fixes: 9ed9895370ae ("driver core: Functional dependencies tracking support") +Reported-by: Stephan Gerhold +Tested-by: Stephan Gerhold +Reviewed-by: Saravana Kannan +Signed-off-by: Rafael J. Wysocki +Link: https://lore.kernel.org/r/17705994.d592GUb2YH@kreacher +Cc: stable +Signed-off-by: Greg Kroah-Hartman +Signed-off-by: Sudip Mukherjee +Signed-off-by: Greg Kroah-Hartman +--- + drivers/base/core.c | 17 ++++++++++++++++- + 1 file changed, 16 insertions(+), 1 deletion(-) + +--- a/drivers/base/core.c ++++ b/drivers/base/core.c +@@ -96,6 +96,16 @@ void device_links_read_unlock(int not_us + } + #endif /* !CONFIG_SRCU */ + ++static bool device_is_ancestor(struct device *dev, struct device *target) ++{ ++ while (target->parent) { ++ target = target->parent; ++ if (dev == target) ++ return true; ++ } ++ return false; ++} ++ + /** + * device_is_dependent - Check if one device depends on another one + * @dev: Device to check dependencies for. +@@ -109,7 +119,12 @@ static int device_is_dependent(struct de + struct device_link *link; + int ret; + +- if (dev == target) ++ /* ++ * The "ancestors" check is needed to catch the case when the target ++ * device has not been completely initialized yet and it is still ++ * missing from the list of children of its parent device. ++ */ ++ if (dev == target || device_is_ancestor(dev, target)) + return 1; + + ret = device_for_each_child(dev, target, device_is_dependent); diff --git a/queue-4.14/net_sched-gen_estimator-support-large-ewma-log.patch b/queue-4.14/net_sched-gen_estimator-support-large-ewma-log.patch new file mode 100644 index 00000000000..6c5f65a6d2e --- /dev/null +++ b/queue-4.14/net_sched-gen_estimator-support-large-ewma-log.patch @@ -0,0 +1,90 @@ +From foo@baz Fri Feb 5 09:57:06 AM CET 2021 +From: Eric Dumazet +Date: Thu, 14 Jan 2021 10:19:29 -0800 +Subject: net_sched: gen_estimator: support large ewma log + +From: Eric Dumazet + +commit dd5e073381f2ada3630f36be42833c6e9c78b75e upstream + +syzbot report reminded us that very big ewma_log were supported in the past, +even if they made litle sense. + +tc qdisc replace dev xxx root est 1sec 131072sec ... + +While fixing the bug, also add boundary checks for ewma_log, in line +with range supported by iproute2. + +UBSAN: shift-out-of-bounds in net/core/gen_estimator.c:83:38 +shift exponent -1 is negative +CPU: 0 PID: 0 Comm: swapper/0 Not tainted 5.10.0-syzkaller #0 +Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 +Call Trace: + + __dump_stack lib/dump_stack.c:79 [inline] + dump_stack+0x107/0x163 lib/dump_stack.c:120 + ubsan_epilogue+0xb/0x5a lib/ubsan.c:148 + __ubsan_handle_shift_out_of_bounds.cold+0xb1/0x181 lib/ubsan.c:395 + est_timer.cold+0xbb/0x12d net/core/gen_estimator.c:83 + call_timer_fn+0x1a5/0x710 kernel/time/timer.c:1417 + expire_timers kernel/time/timer.c:1462 [inline] + __run_timers.part.0+0x692/0xa80 kernel/time/timer.c:1731 + __run_timers kernel/time/timer.c:1712 [inline] + run_timer_softirq+0xb3/0x1d0 kernel/time/timer.c:1744 + __do_softirq+0x2bc/0xa77 kernel/softirq.c:343 + asm_call_irq_on_stack+0xf/0x20 + + __run_on_irqstack arch/x86/include/asm/irq_stack.h:26 [inline] + run_on_irqstack_cond arch/x86/include/asm/irq_stack.h:77 [inline] + do_softirq_own_stack+0xaa/0xd0 arch/x86/kernel/irq_64.c:77 + invoke_softirq kernel/softirq.c:226 [inline] + __irq_exit_rcu+0x17f/0x200 kernel/softirq.c:420 + irq_exit_rcu+0x5/0x20 kernel/softirq.c:432 + sysvec_apic_timer_interrupt+0x4d/0x100 arch/x86/kernel/apic/apic.c:1096 + asm_sysvec_apic_timer_interrupt+0x12/0x20 arch/x86/include/asm/idtentry.h:628 +RIP: 0010:native_save_fl arch/x86/include/asm/irqflags.h:29 [inline] +RIP: 0010:arch_local_save_flags arch/x86/include/asm/irqflags.h:79 [inline] +RIP: 0010:arch_irqs_disabled arch/x86/include/asm/irqflags.h:169 [inline] +RIP: 0010:acpi_safe_halt drivers/acpi/processor_idle.c:111 [inline] +RIP: 0010:acpi_idle_do_entry+0x1c9/0x250 drivers/acpi/processor_idle.c:516 + +Fixes: 1c0d32fde5bd ("net_sched: gen_estimator: complete rewrite of rate estimators") +Signed-off-by: Eric Dumazet +Reported-by: syzbot +Link: https://lore.kernel.org/r/20210114181929.1717985-1-eric.dumazet@gmail.com +Signed-off-by: Jakub Kicinski +[sudip: adjust context] +Signed-off-by: Sudip Mukherjee +Signed-off-by: Greg Kroah-Hartman +--- + net/core/gen_estimator.c | 11 +++++++---- + 1 file changed, 7 insertions(+), 4 deletions(-) + +--- a/net/core/gen_estimator.c ++++ b/net/core/gen_estimator.c +@@ -84,11 +84,11 @@ static void est_timer(unsigned long arg) + u64 rate, brate; + + est_fetch_counters(est, &b); +- brate = (b.bytes - est->last_bytes) << (10 - est->ewma_log - est->intvl_log); +- brate -= (est->avbps >> est->ewma_log); ++ brate = (b.bytes - est->last_bytes) << (10 - est->intvl_log); ++ brate = (brate >> est->ewma_log) - (est->avbps >> est->ewma_log); + +- rate = (u64)(b.packets - est->last_packets) << (10 - est->ewma_log - est->intvl_log); +- rate -= (est->avpps >> est->ewma_log); ++ rate = (u64)(b.packets - est->last_packets) << (10 - est->intvl_log); ++ rate = (rate >> est->ewma_log) - (est->avpps >> est->ewma_log); + + write_seqcount_begin(&est->seq); + est->avbps += brate; +@@ -147,6 +147,9 @@ int gen_new_estimator(struct gnet_stats_ + if (parm->interval < -2 || parm->interval > 3) + return -EINVAL; + ++ if (parm->ewma_log == 0 || parm->ewma_log >= 31) ++ return -EINVAL; ++ + est = kzalloc(sizeof(*est), GFP_KERNEL); + if (!est) + return -ENOBUFS; diff --git a/queue-4.14/series b/queue-4.14/series index 15720c95a14..6ea785b422b 100644 --- a/queue-4.14/series +++ b/queue-4.14/series @@ -2,3 +2,6 @@ net-dsa-bcm_sf2-put-device-node-before-return.patch ibmvnic-ensure-that-crq-entry-read-are-correctly-ordered.patch acpi-thermal-do-not-call-acpi_thermal_check-directly.patch net_sched-reject-silly-cell_log-in-qdisc_get_rtab.patch +net_sched-gen_estimator-support-large-ewma-log.patch +base-core-remove-warn_on-from-link-dependencies-check.patch +driver-core-extend-device_is_dependent.patch -- 2.47.3