From: Greg Kroah-Hartman Date: Tue, 24 Mar 2020 09:34:06 +0000 (+0100) Subject: 4.19-stable patches X-Git-Tag: v4.19.113~5 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=56e639af302285ed92f0b7a358b3438466190b31;p=thirdparty%2Fkernel%2Fstable-queue.git 4.19-stable patches added patches: alsa-hda-realtek-fix-pop-noise-on-alc225.patch arm64-smp-fix-crash_smp_send_stop-behaviour.patch arm64-smp-fix-smp_send_stop-behaviour.patch drm-bridge-dw-hdmi-fix-avi-frame-colorimetry.patch staging-greybus-loopback_test-fix-potential-path-truncation.patch staging-greybus-loopback_test-fix-potential-path-truncations.patch --- diff --git a/queue-4.19/alsa-hda-realtek-fix-pop-noise-on-alc225.patch b/queue-4.19/alsa-hda-realtek-fix-pop-noise-on-alc225.patch new file mode 100644 index 00000000000..95b4ee12bcd --- /dev/null +++ b/queue-4.19/alsa-hda-realtek-fix-pop-noise-on-alc225.patch @@ -0,0 +1,36 @@ +From 3b36b13d5e69d6f51ff1c55d1b404a74646c9757 Mon Sep 17 00:00:00 2001 +From: Kai-Heng Feng +Date: Wed, 11 Mar 2020 14:13:28 +0800 +Subject: ALSA: hda/realtek: Fix pop noise on ALC225 + +From: Kai-Heng Feng + +commit 3b36b13d5e69d6f51ff1c55d1b404a74646c9757 upstream. + +Commit 317d9313925c ("ALSA: hda/realtek - Set default power save node to +0") makes the ALC225 have pop noise on S3 resume and cold boot. + +So partially revert this commit for ALC225 to fix the regression. + +Fixes: 317d9313925c ("ALSA: hda/realtek - Set default power save node to 0") +BugLink: https://bugs.launchpad.net/bugs/1866357 +Signed-off-by: Kai-Heng Feng +Link: https://lore.kernel.org/r/20200311061328.17614-1-kai.heng.feng@canonical.com +Signed-off-by: Takashi Iwai +Signed-off-by: Greg Kroah-Hartman + +--- + sound/pci/hda/patch_realtek.c | 2 ++ + 1 file changed, 2 insertions(+) + +--- a/sound/pci/hda/patch_realtek.c ++++ b/sound/pci/hda/patch_realtek.c +@@ -7828,6 +7828,8 @@ static int patch_alc269(struct hda_codec + spec->gen.mixer_nid = 0; + break; + case 0x10ec0225: ++ codec->power_save_node = 1; ++ /* fall through */ + case 0x10ec0295: + case 0x10ec0299: + spec->codec_variant = ALC269_TYPE_ALC225; diff --git a/queue-4.19/arm64-smp-fix-crash_smp_send_stop-behaviour.patch b/queue-4.19/arm64-smp-fix-crash_smp_send_stop-behaviour.patch new file mode 100644 index 00000000000..d570c2a8c9d --- /dev/null +++ b/queue-4.19/arm64-smp-fix-crash_smp_send_stop-behaviour.patch @@ -0,0 +1,118 @@ +From f50b7dacccbab2b9e3ef18f52a6dcc18ed2050b9 Mon Sep 17 00:00:00 2001 +From: Cristian Marussi +Date: Wed, 11 Mar 2020 17:12:45 +0000 +Subject: arm64: smp: fix crash_smp_send_stop() behaviour + +From: Cristian Marussi + +commit f50b7dacccbab2b9e3ef18f52a6dcc18ed2050b9 upstream. + +On a system configured to trigger a crash_kexec() reboot, when only one CPU +is online and another CPU panics while starting-up, crash_smp_send_stop() +will fail to send any STOP message to the other already online core, +resulting in fail to freeze and registers not properly saved. + +Moreover even if the proper messages are sent (case CPUs > 2) +it will similarly fail to account for the booting CPU when executing +the final stop wait-loop, so potentially resulting in some CPU not +been waited for shutdown before rebooting. + +A tangible effect of this behaviour can be observed when, after a panic +with kexec enabled and loaded, on the following reboot triggered by kexec, +the cpu that could not be successfully stopped fails to come back online: + +[ 362.291022] ------------[ cut here ]------------ +[ 362.291525] kernel BUG at arch/arm64/kernel/cpufeature.c:886! +[ 362.292023] Internal error: Oops - BUG: 0 [#1] PREEMPT SMP +[ 362.292400] Modules linked in: +[ 362.292970] CPU: 3 PID: 0 Comm: swapper/3 Kdump: loaded Not tainted 5.6.0-rc4-00003-gc780b890948a #105 +[ 362.293136] Hardware name: Foundation-v8A (DT) +[ 362.293382] pstate: 200001c5 (nzCv dAIF -PAN -UAO) +[ 362.294063] pc : has_cpuid_feature+0xf0/0x348 +[ 362.294177] lr : verify_local_elf_hwcaps+0x84/0xe8 +[ 362.294280] sp : ffff800011b1bf60 +[ 362.294362] x29: ffff800011b1bf60 x28: 0000000000000000 +[ 362.294534] x27: 0000000000000000 x26: 0000000000000000 +[ 362.294631] x25: 0000000000000000 x24: ffff80001189a25c +[ 362.294718] x23: 0000000000000000 x22: 0000000000000000 +[ 362.294803] x21: ffff8000114aa018 x20: ffff800011156a00 +[ 362.294897] x19: ffff800010c944a0 x18: 0000000000000004 +[ 362.294987] x17: 0000000000000000 x16: 0000000000000000 +[ 362.295073] x15: 00004e53b831ae3c x14: 00004e53b831ae3c +[ 362.295165] x13: 0000000000000384 x12: 0000000000000000 +[ 362.295251] x11: 0000000000000000 x10: 00400032b5503510 +[ 362.295334] x9 : 0000000000000000 x8 : ffff800010c7e204 +[ 362.295426] x7 : 00000000410fd0f0 x6 : 0000000000000001 +[ 362.295508] x5 : 00000000410fd0f0 x4 : 0000000000000000 +[ 362.295592] x3 : 0000000000000000 x2 : ffff8000100939d8 +[ 362.295683] x1 : 0000000000180420 x0 : 0000000000180480 +[ 362.296011] Call trace: +[ 362.296257] has_cpuid_feature+0xf0/0x348 +[ 362.296350] verify_local_elf_hwcaps+0x84/0xe8 +[ 362.296424] check_local_cpu_capabilities+0x44/0x128 +[ 362.296497] secondary_start_kernel+0xf4/0x188 +[ 362.296998] Code: 52805001 72a00301 6b01001f 54000ec0 (d4210000) +[ 362.298652] SMP: stopping secondary CPUs +[ 362.300615] Starting crashdump kernel... +[ 362.301168] Bye! +[ 0.000000] Booting Linux on physical CPU 0x0000000003 [0x410fd0f0] +[ 0.000000] Linux version 5.6.0-rc4-00003-gc780b890948a (crimar01@e120937-lin) (gcc version 8.3.0 (GNU Toolchain for the A-profile Architecture 8.3-2019.03 (arm-rel-8.36))) #105 SMP PREEMPT Fri Mar 6 17:00:42 GMT 2020 +[ 0.000000] Machine model: Foundation-v8A +[ 0.000000] earlycon: pl11 at MMIO 0x000000001c090000 (options '') +[ 0.000000] printk: bootconsole [pl11] enabled +..... +[ 0.138024] rcu: Hierarchical SRCU implementation. +[ 0.153472] its@2f020000: unable to locate ITS domain +[ 0.154078] its@2f020000: Unable to locate ITS domain +[ 0.157541] EFI services will not be available. +[ 0.175395] smp: Bringing up secondary CPUs ... +[ 0.209182] psci: failed to boot CPU1 (-22) +[ 0.209377] CPU1: failed to boot: -22 +[ 0.274598] Detected PIPT I-cache on CPU2 +[ 0.278707] GICv3: CPU2: found redistributor 1 region 0:0x000000002f120000 +[ 0.285212] CPU2: Booted secondary processor 0x0000000001 [0x410fd0f0] +[ 0.369053] Detected PIPT I-cache on CPU3 +[ 0.372947] GICv3: CPU3: found redistributor 2 region 0:0x000000002f140000 +[ 0.378664] CPU3: Booted secondary processor 0x0000000002 [0x410fd0f0] +[ 0.401707] smp: Brought up 1 node, 3 CPUs +[ 0.404057] SMP: Total of 3 processors activated. + +Make crash_smp_send_stop() account also for the online status of the +calling CPU while evaluating how many CPUs are effectively online: this way +the right number of STOPs is sent and all other stopped-cores's registers +are properly saved. + +Fixes: 78fd584cdec05 ("arm64: kdump: implement machine_crash_shutdown()") +Acked-by: Mark Rutland +Signed-off-by: Cristian Marussi +Signed-off-by: Will Deacon +Signed-off-by: Greg Kroah-Hartman + +--- + arch/arm64/kernel/smp.c | 8 ++++++-- + 1 file changed, 6 insertions(+), 2 deletions(-) + +--- a/arch/arm64/kernel/smp.c ++++ b/arch/arm64/kernel/smp.c +@@ -990,7 +990,11 @@ void crash_smp_send_stop(void) + + cpus_stopped = 1; + +- if (num_online_cpus() == 1) { ++ /* ++ * If this cpu is the only one alive at this point in time, online or ++ * not, there are no stop messages to be sent around, so just back out. ++ */ ++ if (num_other_online_cpus() == 0) { + sdei_mask_local_cpu(); + return; + } +@@ -998,7 +1002,7 @@ void crash_smp_send_stop(void) + cpumask_copy(&mask, cpu_online_mask); + cpumask_clear_cpu(smp_processor_id(), &mask); + +- atomic_set(&waiting_for_crash_ipi, num_online_cpus() - 1); ++ atomic_set(&waiting_for_crash_ipi, num_other_online_cpus()); + + pr_crit("SMP: stopping secondary CPUs\n"); + smp_cross_call(&mask, IPI_CPU_CRASH_STOP); diff --git a/queue-4.19/arm64-smp-fix-smp_send_stop-behaviour.patch b/queue-4.19/arm64-smp-fix-smp_send_stop-behaviour.patch new file mode 100644 index 00000000000..1ba415c16d3 --- /dev/null +++ b/queue-4.19/arm64-smp-fix-smp_send_stop-behaviour.patch @@ -0,0 +1,115 @@ +From d0bab0c39e32d39a8c5cddca72e5b4a3059fe050 Mon Sep 17 00:00:00 2001 +From: Cristian Marussi +Date: Wed, 11 Mar 2020 17:12:44 +0000 +Subject: arm64: smp: fix smp_send_stop() behaviour + +From: Cristian Marussi + +commit d0bab0c39e32d39a8c5cddca72e5b4a3059fe050 upstream. + +On a system with only one CPU online, when another one CPU panics while +starting-up, smp_send_stop() will fail to send any STOP message to the +other already online core, resulting in a system still responsive and +alive at the end of the panic procedure. + +[ 186.700083] CPU3: shutdown +[ 187.075462] CPU2: shutdown +[ 187.162869] CPU1: shutdown +[ 188.689998] ------------[ cut here ]------------ +[ 188.691645] kernel BUG at arch/arm64/kernel/cpufeature.c:886! +[ 188.692079] Internal error: Oops - BUG: 0 [#1] PREEMPT SMP +[ 188.692444] Modules linked in: +[ 188.693031] CPU: 3 PID: 0 Comm: swapper/3 Not tainted 5.6.0-rc4-00001-g338d25c35a98 #104 +[ 188.693175] Hardware name: Foundation-v8A (DT) +[ 188.693492] pstate: 200001c5 (nzCv dAIF -PAN -UAO) +[ 188.694183] pc : has_cpuid_feature+0xf0/0x348 +[ 188.694311] lr : verify_local_elf_hwcaps+0x84/0xe8 +[ 188.694410] sp : ffff800011b1bf60 +[ 188.694536] x29: ffff800011b1bf60 x28: 0000000000000000 +[ 188.694707] x27: 0000000000000000 x26: 0000000000000000 +[ 188.694801] x25: 0000000000000000 x24: ffff80001189a25c +[ 188.694905] x23: 0000000000000000 x22: 0000000000000000 +[ 188.694996] x21: ffff8000114aa018 x20: ffff800011156a38 +[ 188.695089] x19: ffff800010c944a0 x18: 0000000000000004 +[ 188.695187] x17: 0000000000000000 x16: 0000000000000000 +[ 188.695280] x15: 0000249dbde5431e x14: 0262cbe497efa1fa +[ 188.695371] x13: 0000000000000002 x12: 0000000000002592 +[ 188.695472] x11: 0000000000000080 x10: 00400032b5503510 +[ 188.695572] x9 : 0000000000000000 x8 : ffff800010c80204 +[ 188.695659] x7 : 00000000410fd0f0 x6 : 0000000000000001 +[ 188.695750] x5 : 00000000410fd0f0 x4 : 0000000000000000 +[ 188.695836] x3 : 0000000000000000 x2 : ffff8000100939d8 +[ 188.695919] x1 : 0000000000180420 x0 : 0000000000180480 +[ 188.696253] Call trace: +[ 188.696410] has_cpuid_feature+0xf0/0x348 +[ 188.696504] verify_local_elf_hwcaps+0x84/0xe8 +[ 188.696591] check_local_cpu_capabilities+0x44/0x128 +[ 188.696666] secondary_start_kernel+0xf4/0x188 +[ 188.697150] Code: 52805001 72a00301 6b01001f 54000ec0 (d4210000) +[ 188.698639] ---[ end trace 3f12ca47652f7b72 ]--- +[ 188.699160] Kernel panic - not syncing: Attempted to kill the idle task! +[ 188.699546] Kernel Offset: disabled +[ 188.699828] CPU features: 0x00004,20c02008 +[ 188.700012] Memory Limit: none +[ 188.700538] ---[ end Kernel panic - not syncing: Attempted to kill the idle task! ]--- + +[root@arch ~]# echo Helo +Helo +[root@arch ~]# cat /proc/cpuinfo | grep proce +processor : 0 + +Make smp_send_stop() account also for the online status of the calling CPU +while evaluating how many CPUs are effectively online: this way, the right +number of STOPs is sent, so enforcing a proper freeze of the system at the +end of panic even under the above conditions. + +Fixes: 08e875c16a16c ("arm64: SMP support") +Reported-by: Dave Martin +Acked-by: Mark Rutland +Signed-off-by: Cristian Marussi +Signed-off-by: Will Deacon +Signed-off-by: Greg Kroah-Hartman + +--- + arch/arm64/kernel/smp.c | 17 ++++++++++++++--- + 1 file changed, 14 insertions(+), 3 deletions(-) + +--- a/arch/arm64/kernel/smp.c ++++ b/arch/arm64/kernel/smp.c +@@ -936,11 +936,22 @@ void tick_broadcast(const struct cpumask + } + #endif + ++/* ++ * The number of CPUs online, not counting this CPU (which may not be ++ * fully online and so not counted in num_online_cpus()). ++ */ ++static inline unsigned int num_other_online_cpus(void) ++{ ++ unsigned int this_cpu_online = cpu_online(smp_processor_id()); ++ ++ return num_online_cpus() - this_cpu_online; ++} ++ + void smp_send_stop(void) + { + unsigned long timeout; + +- if (num_online_cpus() > 1) { ++ if (num_other_online_cpus()) { + cpumask_t mask; + + cpumask_copy(&mask, cpu_online_mask); +@@ -953,10 +964,10 @@ void smp_send_stop(void) + + /* Wait up to one second for other CPUs to stop */ + timeout = USEC_PER_SEC; +- while (num_online_cpus() > 1 && timeout--) ++ while (num_other_online_cpus() && timeout--) + udelay(1); + +- if (num_online_cpus() > 1) ++ if (num_other_online_cpus()) + pr_warning("SMP: failed to stop secondary CPUs %*pbl\n", + cpumask_pr_args(cpu_online_mask)); + diff --git a/queue-4.19/drm-bridge-dw-hdmi-fix-avi-frame-colorimetry.patch b/queue-4.19/drm-bridge-dw-hdmi-fix-avi-frame-colorimetry.patch new file mode 100644 index 00000000000..8beedd22239 --- /dev/null +++ b/queue-4.19/drm-bridge-dw-hdmi-fix-avi-frame-colorimetry.patch @@ -0,0 +1,79 @@ +From e8dca30f7118461d47e1c3510d0e31b277439151 Mon Sep 17 00:00:00 2001 +From: Jernej Skrabec +Date: Thu, 5 Mar 2020 00:25:09 +0100 +Subject: drm/bridge: dw-hdmi: fix AVI frame colorimetry + +From: Jernej Skrabec + +commit e8dca30f7118461d47e1c3510d0e31b277439151 upstream. + +CTA-861-F explicitly states that for RGB colorspace colorimetry should +be set to "none". Fix that. + +Acked-by: Laurent Pinchart +Fixes: def23aa7e982 ("drm: bridge: dw-hdmi: Switch to V4L bus format and encodings") +Signed-off-by: Jernej Skrabec +Link: https://patchwork.freedesktop.org/patch/msgid/20200304232512.51616-2-jernej.skrabec@siol.net +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/gpu/drm/bridge/synopsys/dw-hdmi.c | 46 ++++++++++++++++-------------- + 1 file changed, 26 insertions(+), 20 deletions(-) + +--- a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c ++++ b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +@@ -1364,28 +1364,34 @@ static void hdmi_config_AVI(struct dw_hd + frame.colorspace = HDMI_COLORSPACE_RGB; + + /* Set up colorimetry */ +- switch (hdmi->hdmi_data.enc_out_encoding) { +- case V4L2_YCBCR_ENC_601: +- if (hdmi->hdmi_data.enc_in_encoding == V4L2_YCBCR_ENC_XV601) +- frame.colorimetry = HDMI_COLORIMETRY_EXTENDED; +- else ++ if (!hdmi_bus_fmt_is_rgb(hdmi->hdmi_data.enc_out_bus_format)) { ++ switch (hdmi->hdmi_data.enc_out_encoding) { ++ case V4L2_YCBCR_ENC_601: ++ if (hdmi->hdmi_data.enc_in_encoding == V4L2_YCBCR_ENC_XV601) ++ frame.colorimetry = HDMI_COLORIMETRY_EXTENDED; ++ else ++ frame.colorimetry = HDMI_COLORIMETRY_ITU_601; ++ frame.extended_colorimetry = ++ HDMI_EXTENDED_COLORIMETRY_XV_YCC_601; ++ break; ++ case V4L2_YCBCR_ENC_709: ++ if (hdmi->hdmi_data.enc_in_encoding == V4L2_YCBCR_ENC_XV709) ++ frame.colorimetry = HDMI_COLORIMETRY_EXTENDED; ++ else ++ frame.colorimetry = HDMI_COLORIMETRY_ITU_709; ++ frame.extended_colorimetry = ++ HDMI_EXTENDED_COLORIMETRY_XV_YCC_709; ++ break; ++ default: /* Carries no data */ + frame.colorimetry = HDMI_COLORIMETRY_ITU_601; ++ frame.extended_colorimetry = ++ HDMI_EXTENDED_COLORIMETRY_XV_YCC_601; ++ break; ++ } ++ } else { ++ frame.colorimetry = HDMI_COLORIMETRY_NONE; + frame.extended_colorimetry = +- HDMI_EXTENDED_COLORIMETRY_XV_YCC_601; +- break; +- case V4L2_YCBCR_ENC_709: +- if (hdmi->hdmi_data.enc_in_encoding == V4L2_YCBCR_ENC_XV709) +- frame.colorimetry = HDMI_COLORIMETRY_EXTENDED; +- else +- frame.colorimetry = HDMI_COLORIMETRY_ITU_709; +- frame.extended_colorimetry = +- HDMI_EXTENDED_COLORIMETRY_XV_YCC_709; +- break; +- default: /* Carries no data */ +- frame.colorimetry = HDMI_COLORIMETRY_ITU_601; +- frame.extended_colorimetry = +- HDMI_EXTENDED_COLORIMETRY_XV_YCC_601; +- break; ++ HDMI_EXTENDED_COLORIMETRY_XV_YCC_601; + } + + frame.scan_mode = HDMI_SCAN_MODE_NONE; diff --git a/queue-4.19/series b/queue-4.19/series index ecc81ccd31b..c28f64ff200 100644 --- a/queue-4.19/series +++ b/queue-4.19/series @@ -57,3 +57,9 @@ futex-fix-inode-life-time-issue.patch futex-unbreak-futex-hashing.patch revert-vrf-mark-skb-for-multicast-or-link-local-as-e.patch revert-ipv6-fix-handling-of-lla-with-vrf-and-sockets.patch +alsa-hda-realtek-fix-pop-noise-on-alc225.patch +arm64-smp-fix-smp_send_stop-behaviour.patch +arm64-smp-fix-crash_smp_send_stop-behaviour.patch +drm-bridge-dw-hdmi-fix-avi-frame-colorimetry.patch +staging-greybus-loopback_test-fix-potential-path-truncation.patch +staging-greybus-loopback_test-fix-potential-path-truncations.patch diff --git a/queue-4.19/staging-greybus-loopback_test-fix-potential-path-truncation.patch b/queue-4.19/staging-greybus-loopback_test-fix-potential-path-truncation.patch new file mode 100644 index 00000000000..dbb1aaf81bc --- /dev/null +++ b/queue-4.19/staging-greybus-loopback_test-fix-potential-path-truncation.patch @@ -0,0 +1,46 @@ +From f16023834863932f95dfad13fac3fc47f77d2f29 Mon Sep 17 00:00:00 2001 +From: Johan Hovold +Date: Thu, 12 Mar 2020 12:01:50 +0100 +Subject: staging: greybus: loopback_test: fix potential path truncation + +From: Johan Hovold + +commit f16023834863932f95dfad13fac3fc47f77d2f29 upstream. + +Newer GCC warns about a possible truncation of a generated sysfs path +name as we're concatenating a directory path with a file name and +placing the result in a buffer that is half the size of the maximum +length of the directory path (which is user controlled). + +loopback_test.c: In function 'open_poll_files': +loopback_test.c:651:31: warning: '%s' directive output may be truncated writing up to 511 bytes into a region of size 255 [-Wformat-truncation=] + 651 | snprintf(buf, sizeof(buf), "%s%s", dev->sysfs_entry, "iteration_count"); + | ^~ +loopback_test.c:651:3: note: 'snprintf' output between 16 and 527 bytes into a destination of size 255 + 651 | snprintf(buf, sizeof(buf), "%s%s", dev->sysfs_entry, "iteration_count"); + | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Fix this by making sure the buffer is large enough the concatenated +strings. + +Fixes: 6b0658f68786 ("greybus: tools: Add tools directory to greybus repo and add loopback") +Fixes: 9250c0ee2626 ("greybus: Loopback_test: use poll instead of inotify") +Signed-off-by: Johan Hovold +Link: https://lore.kernel.org/r/20200312110151.22028-3-johan@kernel.org +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/staging/greybus/tools/loopback_test.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/drivers/staging/greybus/tools/loopback_test.c ++++ b/drivers/staging/greybus/tools/loopback_test.c +@@ -645,7 +645,7 @@ baddir: + static int open_poll_files(struct loopback_test *t) + { + struct loopback_device *dev; +- char buf[MAX_STR_LEN]; ++ char buf[MAX_SYSFS_PATH + MAX_STR_LEN]; + char dummy; + int fds_idx = 0; + int i; diff --git a/queue-4.19/staging-greybus-loopback_test-fix-potential-path-truncations.patch b/queue-4.19/staging-greybus-loopback_test-fix-potential-path-truncations.patch new file mode 100644 index 00000000000..a078bb78428 --- /dev/null +++ b/queue-4.19/staging-greybus-loopback_test-fix-potential-path-truncations.patch @@ -0,0 +1,94 @@ +From ae62cf5eb2792d9a818c2d93728ed92119357017 Mon Sep 17 00:00:00 2001 +From: Johan Hovold +Date: Thu, 12 Mar 2020 12:01:51 +0100 +Subject: staging: greybus: loopback_test: fix potential path truncations + +From: Johan Hovold + +commit ae62cf5eb2792d9a818c2d93728ed92119357017 upstream. + +Newer GCC warns about possible truncations of two generated path names as +we're concatenating the configurable sysfs and debugfs path prefixes +with a filename and placing the results in buffers of the same size as +the maximum length of the prefixes. + + snprintf(d->name, MAX_STR_LEN, "gb_loopback%u", dev_id); + + snprintf(d->sysfs_entry, MAX_SYSFS_PATH, "%s%s/", + t->sysfs_prefix, d->name); + + snprintf(d->debugfs_entry, MAX_SYSFS_PATH, "%sraw_latency_%s", + t->debugfs_prefix, d->name); + +Fix this by separating the maximum path length from the maximum prefix +length and reducing the latter enough to fit the generated strings. + +Note that we also need to reduce the device-name buffer size as GCC +isn't smart enough to figure out that we ever only used MAX_STR_LEN +bytes of it. + +Fixes: 6b0658f68786 ("greybus: tools: Add tools directory to greybus repo and add loopback") +Signed-off-by: Johan Hovold +Link: https://lore.kernel.org/r/20200312110151.22028-4-johan@kernel.org +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/staging/greybus/tools/loopback_test.c | 15 ++++++++------- + 1 file changed, 8 insertions(+), 7 deletions(-) + +--- a/drivers/staging/greybus/tools/loopback_test.c ++++ b/drivers/staging/greybus/tools/loopback_test.c +@@ -21,6 +21,7 @@ + #include + + #define MAX_NUM_DEVICES 10 ++#define MAX_SYSFS_PREFIX 0x80 + #define MAX_SYSFS_PATH 0x200 + #define CSV_MAX_LINE 0x1000 + #define SYSFS_MAX_INT 0x20 +@@ -69,7 +70,7 @@ struct loopback_results { + }; + + struct loopback_device { +- char name[MAX_SYSFS_PATH]; ++ char name[MAX_STR_LEN]; + char sysfs_entry[MAX_SYSFS_PATH]; + char debugfs_entry[MAX_SYSFS_PATH]; + struct loopback_results results; +@@ -95,8 +96,8 @@ struct loopback_test { + int stop_all; + int poll_count; + char test_name[MAX_STR_LEN]; +- char sysfs_prefix[MAX_SYSFS_PATH]; +- char debugfs_prefix[MAX_SYSFS_PATH]; ++ char sysfs_prefix[MAX_SYSFS_PREFIX]; ++ char debugfs_prefix[MAX_SYSFS_PREFIX]; + struct timespec poll_timeout; + struct loopback_device devices[MAX_NUM_DEVICES]; + struct loopback_results aggregate_results; +@@ -915,10 +916,10 @@ int main(int argc, char *argv[]) + t.iteration_max = atoi(optarg); + break; + case 'S': +- snprintf(t.sysfs_prefix, MAX_SYSFS_PATH, "%s", optarg); ++ snprintf(t.sysfs_prefix, MAX_SYSFS_PREFIX, "%s", optarg); + break; + case 'D': +- snprintf(t.debugfs_prefix, MAX_SYSFS_PATH, "%s", optarg); ++ snprintf(t.debugfs_prefix, MAX_SYSFS_PREFIX, "%s", optarg); + break; + case 'm': + t.mask = atol(optarg); +@@ -969,10 +970,10 @@ int main(int argc, char *argv[]) + } + + if (!strcmp(t.sysfs_prefix, "")) +- snprintf(t.sysfs_prefix, MAX_SYSFS_PATH, "%s", sysfs_prefix); ++ snprintf(t.sysfs_prefix, MAX_SYSFS_PREFIX, "%s", sysfs_prefix); + + if (!strcmp(t.debugfs_prefix, "")) +- snprintf(t.debugfs_prefix, MAX_SYSFS_PATH, "%s", debugfs_prefix); ++ snprintf(t.debugfs_prefix, MAX_SYSFS_PREFIX, "%s", debugfs_prefix); + + ret = find_loopback_devices(&t); + if (ret)