From: Sasha Levin Date: Mon, 18 Jul 2022 01:29:48 +0000 (-0400) Subject: Fixes for 4.9 X-Git-Tag: v4.9.324~29 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=d71d41222c298957730af07134deb615f83ca6e2;p=thirdparty%2Fkernel%2Fstable-queue.git Fixes for 4.9 Signed-off-by: Sasha Levin --- diff --git a/queue-4.9/asoc-ops-fix-off-by-one-in-range-control-validation.patch b/queue-4.9/asoc-ops-fix-off-by-one-in-range-control-validation.patch new file mode 100644 index 00000000000..1f4f1afb360 --- /dev/null +++ b/queue-4.9/asoc-ops-fix-off-by-one-in-range-control-validation.patch @@ -0,0 +1,45 @@ +From 8df13b4b7eb19fe48248156c2ea818c6a7f5ae1f Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Sat, 4 Jun 2022 11:52:46 +0100 +Subject: ASoC: ops: Fix off by one in range control validation + +From: Mark Brown + +[ Upstream commit 5871321fb4558c55bf9567052b618ff0be6b975e ] + +We currently report that range controls accept a range of 0..(max-min) but +accept writes in the range 0..(max-min+1). Remove that extra +1. + +Signed-off-by: Mark Brown +Link: https://lore.kernel.org/r/20220604105246.4055214-1-broonie@kernel.org +Signed-off-by: Mark Brown +Signed-off-by: Sasha Levin +--- + sound/soc/soc-ops.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/sound/soc/soc-ops.c b/sound/soc/soc-ops.c +index 90ba5521c189..4fda8c24be29 100644 +--- a/sound/soc/soc-ops.c ++++ b/sound/soc/soc-ops.c +@@ -535,7 +535,7 @@ int snd_soc_put_volsw_range(struct snd_kcontrol *kcontrol, + return -EINVAL; + if (mc->platform_max && tmp > mc->platform_max) + return -EINVAL; +- if (tmp > mc->max - mc->min + 1) ++ if (tmp > mc->max - mc->min) + return -EINVAL; + + if (invert) +@@ -556,7 +556,7 @@ int snd_soc_put_volsw_range(struct snd_kcontrol *kcontrol, + return -EINVAL; + if (mc->platform_max && tmp > mc->platform_max) + return -EINVAL; +- if (tmp > mc->max - mc->min + 1) ++ if (tmp > mc->max - mc->min) + return -EINVAL; + + if (invert) +-- +2.35.1 + diff --git a/queue-4.9/asoc-wm5110-fix-dre-control.patch b/queue-4.9/asoc-wm5110-fix-dre-control.patch new file mode 100644 index 00000000000..dea43db5b91 --- /dev/null +++ b/queue-4.9/asoc-wm5110-fix-dre-control.patch @@ -0,0 +1,56 @@ +From 02d6abf27e7680a42871089a44d2abdb2c285797 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Tue, 21 Jun 2022 11:20:39 +0100 +Subject: ASoC: wm5110: Fix DRE control + +From: Charles Keepax + +[ Upstream commit 0bc0ae9a5938d512fd5d44f11c9c04892dcf4961 ] + +The DRE controls on wm5110 should return a value of 1 if the DRE state +is actually changed, update to fix this. + +Signed-off-by: Charles Keepax +Link: https://lore.kernel.org/r/20220621102041.1713504-2-ckeepax@opensource.cirrus.com +Signed-off-by: Mark Brown +Signed-off-by: Sasha Levin +--- + sound/soc/codecs/wm5110.c | 8 ++++++-- + 1 file changed, 6 insertions(+), 2 deletions(-) + +diff --git a/sound/soc/codecs/wm5110.c b/sound/soc/codecs/wm5110.c +index 06bae3b23fce..2b0342bcede4 100644 +--- a/sound/soc/codecs/wm5110.c ++++ b/sound/soc/codecs/wm5110.c +@@ -404,6 +404,7 @@ static int wm5110_put_dre(struct snd_kcontrol *kcontrol, + unsigned int rnew = (!!ucontrol->value.integer.value[1]) << mc->rshift; + unsigned int lold, rold; + unsigned int lena, rena; ++ bool change = false; + int ret; + + snd_soc_dapm_mutex_lock(dapm); +@@ -431,8 +432,8 @@ static int wm5110_put_dre(struct snd_kcontrol *kcontrol, + goto err; + } + +- ret = regmap_update_bits(arizona->regmap, ARIZONA_DRE_ENABLE, +- mask, lnew | rnew); ++ ret = regmap_update_bits_check(arizona->regmap, ARIZONA_DRE_ENABLE, ++ mask, lnew | rnew, &change); + if (ret) { + dev_err(arizona->dev, "Failed to set DRE: %d\n", ret); + goto err; +@@ -445,6 +446,9 @@ static int wm5110_put_dre(struct snd_kcontrol *kcontrol, + if (!rnew && rold) + wm5110_clear_pga_volume(arizona, mc->rshift); + ++ if (change) ++ ret = 1; ++ + err: + snd_soc_dapm_mutex_unlock(dapm); + +-- +2.35.1 + diff --git a/queue-4.9/cpufreq-pmac32-cpufreq-fix-refcount-leak-bug.patch b/queue-4.9/cpufreq-pmac32-cpufreq-fix-refcount-leak-bug.patch new file mode 100644 index 00000000000..29700acd0c2 --- /dev/null +++ b/queue-4.9/cpufreq-pmac32-cpufreq-fix-refcount-leak-bug.patch @@ -0,0 +1,38 @@ +From 7eb69592bda9f8f9f48e4942a0ea7f66218bb6b3 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Sat, 18 Jun 2022 10:25:45 +0800 +Subject: cpufreq: pmac32-cpufreq: Fix refcount leak bug + +From: Liang He + +[ Upstream commit ccd7567d4b6cf187fdfa55f003a9e461ee629e36 ] + +In pmac_cpufreq_init_MacRISC3(), we need to add corresponding +of_node_put() for the three node pointers whose refcount have +been incremented by of_find_node_by_name(). + +Signed-off-by: Liang He +Signed-off-by: Viresh Kumar +Signed-off-by: Sasha Levin +--- + drivers/cpufreq/pmac32-cpufreq.c | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/drivers/cpufreq/pmac32-cpufreq.c b/drivers/cpufreq/pmac32-cpufreq.c +index 641f8021855a..62e86f7ca04a 100644 +--- a/drivers/cpufreq/pmac32-cpufreq.c ++++ b/drivers/cpufreq/pmac32-cpufreq.c +@@ -473,6 +473,10 @@ static int pmac_cpufreq_init_MacRISC3(struct device_node *cpunode) + if (slew_done_gpio_np) + slew_done_gpio = read_gpio(slew_done_gpio_np); + ++ of_node_put(volt_gpio_np); ++ of_node_put(freq_gpio_np); ++ of_node_put(slew_done_gpio_np); ++ + /* If we use the frequency GPIOs, calculate the min/max speeds based + * on the bus frequencies + */ +-- +2.35.1 + diff --git a/queue-4.9/net-tipc-fix-possible-refcount-leak-in-tipc_sk_creat.patch b/queue-4.9/net-tipc-fix-possible-refcount-leak-in-tipc_sk_creat.patch new file mode 100644 index 00000000000..ebde74f75cc --- /dev/null +++ b/queue-4.9/net-tipc-fix-possible-refcount-leak-in-tipc_sk_creat.patch @@ -0,0 +1,34 @@ +From 86b55ff192e093dcf6821696df75c7400f10dfe3 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 29 Jun 2022 14:34:18 +0800 +Subject: net: tipc: fix possible refcount leak in tipc_sk_create() + +From: Hangyu Hua + +[ Upstream commit 00aff3590fc0a73bddd3b743863c14e76fd35c0c ] + +Free sk in case tipc_sk_insert() fails. + +Signed-off-by: Hangyu Hua +Reviewed-by: Tung Nguyen +Signed-off-by: David S. Miller +Signed-off-by: Sasha Levin +--- + net/tipc/socket.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/net/tipc/socket.c b/net/tipc/socket.c +index 9f39276e5d4e..1b3516368057 100644 +--- a/net/tipc/socket.c ++++ b/net/tipc/socket.c +@@ -341,6 +341,7 @@ static int tipc_sk_create(struct net *net, struct socket *sock, + sock->state = state; + sock_init_data(sock, sk); + if (tipc_sk_insert(tsk)) { ++ sk_free(sk); + pr_warn("Socket create failed; port number exhausted\n"); + return -EINVAL; + } +-- +2.35.1 + diff --git a/queue-4.9/nfc-nxp-nci-don-t-print-header-length-mismatch-on-i2.patch b/queue-4.9/nfc-nxp-nci-don-t-print-header-length-mismatch-on-i2.patch new file mode 100644 index 00000000000..949fcf16f6d --- /dev/null +++ b/queue-4.9/nfc-nxp-nci-don-t-print-header-length-mismatch-on-i2.patch @@ -0,0 +1,50 @@ +From 3b2da948f34e92c60b2bfe7899840fa5bf9ca8dd Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 27 Jun 2022 19:06:43 +0200 +Subject: NFC: nxp-nci: don't print header length mismatch on i2c error + +From: Michael Walle + +[ Upstream commit 9577fc5fdc8b07b891709af6453545db405e24ad ] + +Don't print a misleading header length mismatch error if the i2c call +returns an error. Instead just return the error code without any error +message. + +Signed-off-by: Michael Walle +Reviewed-by: Krzysztof Kozlowski +Signed-off-by: David S. Miller +Signed-off-by: Sasha Levin +--- + drivers/nfc/nxp-nci/i2c.c | 8 ++++++-- + 1 file changed, 6 insertions(+), 2 deletions(-) + +diff --git a/drivers/nfc/nxp-nci/i2c.c b/drivers/nfc/nxp-nci/i2c.c +index a4f1a981e2dd..a9c8bfb62ebe 100644 +--- a/drivers/nfc/nxp-nci/i2c.c ++++ b/drivers/nfc/nxp-nci/i2c.c +@@ -139,7 +139,9 @@ static int nxp_nci_i2c_fw_read(struct nxp_nci_i2c_phy *phy, + memcpy(skb_put(*skb, NXP_NCI_FW_HDR_LEN), &header, NXP_NCI_FW_HDR_LEN); + + r = i2c_master_recv(client, skb_put(*skb, frame_len), frame_len); +- if (r != frame_len) { ++ if (r < 0) { ++ goto fw_read_exit_free_skb; ++ } else if (r != frame_len) { + nfc_err(&client->dev, + "Invalid frame length: %u (expected %zu)\n", + r, frame_len); +@@ -184,7 +186,9 @@ static int nxp_nci_i2c_nci_read(struct nxp_nci_i2c_phy *phy, + return 0; + + r = i2c_master_recv(client, skb_put(*skb, header.plen), header.plen); +- if (r != header.plen) { ++ if (r < 0) { ++ goto nci_read_exit_free_skb; ++ } else if (r != header.plen) { + nfc_err(&client->dev, + "Invalid frame payload length: %u (expected %u)\n", + r, header.plen); +-- +2.35.1 + diff --git a/queue-4.9/series b/queue-4.9/series index 4c2d4078311..b74f8aeab08 100644 --- a/queue-4.9/series +++ b/queue-4.9/series @@ -11,3 +11,12 @@ icmp-fix-data-races-around-sysctl.patch ipv4-fix-data-races-around-sysctl_ip_dynaddr.patch sfc-fix-use-after-free-when-disabling-sriov.patch sfc-fix-kernel-panic-when-creating-vf.patch +virtio_mmio-add-missing-pm-calls-to-freeze-restore.patch +virtio_mmio-restore-guest-page-size-on-resume.patch +cpufreq-pmac32-cpufreq-fix-refcount-leak-bug.patch +net-tipc-fix-possible-refcount-leak-in-tipc_sk_creat.patch +nfc-nxp-nci-don-t-print-header-length-mismatch-on-i2.patch +asoc-ops-fix-off-by-one-in-range-control-validation.patch +asoc-wm5110-fix-dre-control.patch +x86-clear-.brk-area-at-early-boot.patch +signal-handling-don-t-use-bug_on-for-debugging.patch diff --git a/queue-4.9/signal-handling-don-t-use-bug_on-for-debugging.patch b/queue-4.9/signal-handling-don-t-use-bug_on-for-debugging.patch new file mode 100644 index 00000000000..07793a95d73 --- /dev/null +++ b/queue-4.9/signal-handling-don-t-use-bug_on-for-debugging.patch @@ -0,0 +1,54 @@ +From 11c262cee4f7226206ac4c45c2a662f842dc181f Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 6 Jul 2022 12:20:59 -0700 +Subject: signal handling: don't use BUG_ON() for debugging + +From: Linus Torvalds + +[ Upstream commit a382f8fee42ca10c9bfce0d2352d4153f931f5dc ] + +These are indeed "should not happen" situations, but it turns out recent +changes made the 'task_is_stopped_or_trace()' case trigger (fix for that +exists, is pending more testing), and the BUG_ON() makes it +unnecessarily hard to actually debug for no good reason. + +It's been that way for a long time, but let's make it clear: BUG_ON() is +not good for debugging, and should never be used in situations where you +could just say "this shouldn't happen, but we can continue". + +Use WARN_ON_ONCE() instead to make sure it gets logged, and then just +continue running. Instead of making the system basically unusuable +because you crashed the machine while potentially holding some very core +locks (eg this function is commonly called while holding 'tasklist_lock' +for writing). + +Signed-off-by: Linus Torvalds +Signed-off-by: Sasha Levin +--- + kernel/signal.c | 8 ++++---- + 1 file changed, 4 insertions(+), 4 deletions(-) + +diff --git a/kernel/signal.c b/kernel/signal.c +index 2c26af848e68..670755212d35 100644 +--- a/kernel/signal.c ++++ b/kernel/signal.c +@@ -1647,12 +1647,12 @@ bool do_notify_parent(struct task_struct *tsk, int sig) + bool autoreap = false; + cputime_t utime, stime; + +- BUG_ON(sig == -1); ++ WARN_ON_ONCE(sig == -1); + +- /* do_notify_parent_cldstop should have been called instead. */ +- BUG_ON(task_is_stopped_or_traced(tsk)); ++ /* do_notify_parent_cldstop should have been called instead. */ ++ WARN_ON_ONCE(task_is_stopped_or_traced(tsk)); + +- BUG_ON(!tsk->ptrace && ++ WARN_ON_ONCE(!tsk->ptrace && + (tsk->group_leader != tsk || !thread_group_empty(tsk))); + + if (sig != SIGCHLD) { +-- +2.35.1 + diff --git a/queue-4.9/virtio_mmio-add-missing-pm-calls-to-freeze-restore.patch b/queue-4.9/virtio_mmio-add-missing-pm-calls-to-freeze-restore.patch new file mode 100644 index 00000000000..80b4cd2fff7 --- /dev/null +++ b/queue-4.9/virtio_mmio-add-missing-pm-calls-to-freeze-restore.patch @@ -0,0 +1,81 @@ +From 16cdd6e407c6b019664e5234d0ded7a7fe862317 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Tue, 21 Jun 2022 13:06:20 +0200 +Subject: virtio_mmio: Add missing PM calls to freeze/restore + +From: Stephan Gerhold + +[ Upstream commit ed7ac37fde33ccd84e4bd2b9363c191f925364c7 ] + +Most virtio drivers provide freeze/restore callbacks to finish up +device usage before suspend and to reinitialize the virtio device after +resume. However, these callbacks are currently only called when using +virtio_pci. virtio_mmio does not have any PM ops defined. + +This causes problems for example after suspend to disk (hibernation), +since the virtio devices might lose their state after the VMM is +restarted. Calling virtio_device_freeze()/restore() ensures that +the virtio devices are re-initialized correctly. + +Fix this by implementing the dev_pm_ops for virtio_mmio, +similar to virtio_pci_common. + +Signed-off-by: Stephan Gerhold +Message-Id: <20220621110621.3638025-2-stephan.gerhold@kernkonzept.com> +Signed-off-by: Michael S. Tsirkin +Signed-off-by: Sasha Levin +--- + drivers/virtio/virtio_mmio.c | 23 +++++++++++++++++++++++ + 1 file changed, 23 insertions(+) + +diff --git a/drivers/virtio/virtio_mmio.c b/drivers/virtio/virtio_mmio.c +index f62da3b7c27b..d69f0c5135ff 100644 +--- a/drivers/virtio/virtio_mmio.c ++++ b/drivers/virtio/virtio_mmio.c +@@ -66,6 +66,7 @@ + #include + #include + #include ++#include + #include + #include + #include +@@ -489,6 +490,25 @@ static const struct virtio_config_ops virtio_mmio_config_ops = { + .bus_name = vm_bus_name, + }; + ++#ifdef CONFIG_PM_SLEEP ++static int virtio_mmio_freeze(struct device *dev) ++{ ++ struct virtio_mmio_device *vm_dev = dev_get_drvdata(dev); ++ ++ return virtio_device_freeze(&vm_dev->vdev); ++} ++ ++static int virtio_mmio_restore(struct device *dev) ++{ ++ struct virtio_mmio_device *vm_dev = dev_get_drvdata(dev); ++ ++ return virtio_device_restore(&vm_dev->vdev); ++} ++ ++static const struct dev_pm_ops virtio_mmio_pm_ops = { ++ SET_SYSTEM_SLEEP_PM_OPS(virtio_mmio_freeze, virtio_mmio_restore) ++}; ++#endif + + + /* Platform device */ +@@ -730,6 +750,9 @@ static struct platform_driver virtio_mmio_driver = { + .name = "virtio-mmio", + .of_match_table = virtio_mmio_match, + .acpi_match_table = ACPI_PTR(virtio_mmio_acpi_match), ++#ifdef CONFIG_PM_SLEEP ++ .pm = &virtio_mmio_pm_ops, ++#endif + }, + }; + +-- +2.35.1 + diff --git a/queue-4.9/virtio_mmio-restore-guest-page-size-on-resume.patch b/queue-4.9/virtio_mmio-restore-guest-page-size-on-resume.patch new file mode 100644 index 00000000000..db34553c34a --- /dev/null +++ b/queue-4.9/virtio_mmio-restore-guest-page-size-on-resume.patch @@ -0,0 +1,44 @@ +From 030eb331d7836164a98c414d943798d30d36265f Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Tue, 21 Jun 2022 13:06:21 +0200 +Subject: virtio_mmio: Restore guest page size on resume + +From: Stephan Gerhold + +[ Upstream commit e0c2ce8217955537dd5434baeba061f209797119 ] + +Virtio devices might lose their state when the VMM is restarted +after a suspend to disk (hibernation) cycle. This means that the +guest page size register must be restored for the virtio_mmio legacy +interface, since otherwise the virtio queues are not functional. + +This is particularly problematic for QEMU that currently still defaults +to using the legacy interface for virtio_mmio. Write the guest page +size register again in virtio_mmio_restore() to make legacy virtio_mmio +devices work correctly after hibernation. + +Signed-off-by: Stephan Gerhold +Message-Id: <20220621110621.3638025-3-stephan.gerhold@kernkonzept.com> +Signed-off-by: Michael S. Tsirkin +Signed-off-by: Sasha Levin +--- + drivers/virtio/virtio_mmio.c | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/drivers/virtio/virtio_mmio.c b/drivers/virtio/virtio_mmio.c +index d69f0c5135ff..413f6af4d132 100644 +--- a/drivers/virtio/virtio_mmio.c ++++ b/drivers/virtio/virtio_mmio.c +@@ -502,6 +502,9 @@ static int virtio_mmio_restore(struct device *dev) + { + struct virtio_mmio_device *vm_dev = dev_get_drvdata(dev); + ++ if (vm_dev->version == 1) ++ writel(PAGE_SIZE, vm_dev->base + VIRTIO_MMIO_GUEST_PAGE_SIZE); ++ + return virtio_device_restore(&vm_dev->vdev); + } + +-- +2.35.1 + diff --git a/queue-4.9/x86-clear-.brk-area-at-early-boot.patch b/queue-4.9/x86-clear-.brk-area-at-early-boot.patch new file mode 100644 index 00000000000..3dafb649f3a --- /dev/null +++ b/queue-4.9/x86-clear-.brk-area-at-early-boot.patch @@ -0,0 +1,43 @@ +From 20fb105c1a81359e381711b193842df6c91fdfb6 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 30 Jun 2022 09:14:40 +0200 +Subject: x86: Clear .brk area at early boot + +From: Juergen Gross + +[ Upstream commit 38fa5479b41376dc9d7f57e71c83514285a25ca0 ] + +The .brk section has the same properties as .bss: it is an alloc-only +section and should be cleared before being used. + +Not doing so is especially a problem for Xen PV guests, as the +hypervisor will validate page tables (check for writable page tables +and hypervisor private bits) before accepting them to be used. + +Make sure .brk is initially zero by letting clear_bss() clear the brk +area, too. + +Signed-off-by: Juergen Gross +Signed-off-by: Borislav Petkov +Link: https://lore.kernel.org/r/20220630071441.28576-3-jgross@suse.com +Signed-off-by: Sasha Levin +--- + arch/x86/kernel/head64.c | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/arch/x86/kernel/head64.c b/arch/x86/kernel/head64.c +index b5785c197e53..2b2060d842d1 100644 +--- a/arch/x86/kernel/head64.c ++++ b/arch/x86/kernel/head64.c +@@ -106,6 +106,8 @@ static void __init clear_bss(void) + { + memset(__bss_start, 0, + (unsigned long) __bss_stop - (unsigned long) __bss_start); ++ memset(__brk_base, 0, ++ (unsigned long) __brk_limit - (unsigned long) __brk_base); + } + + static unsigned long get_cmd_line_ptr(void) +-- +2.35.1 +