]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
4.19-stable patches
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 20 Nov 2020 09:20:37 +0000 (10:20 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 20 Nov 2020 09:20:37 +0000 (10:20 +0100)
added patches:
input-sunkbd-avoid-use-after-free-in-teardown-paths.patch
powerpc-8xx-always-fault-when-_page_accessed-is-not-set.patch

queue-4.19/input-sunkbd-avoid-use-after-free-in-teardown-paths.patch [new file with mode: 0644]
queue-4.19/powerpc-8xx-always-fault-when-_page_accessed-is-not-set.patch [new file with mode: 0644]
queue-4.19/series

diff --git a/queue-4.19/input-sunkbd-avoid-use-after-free-in-teardown-paths.patch b/queue-4.19/input-sunkbd-avoid-use-after-free-in-teardown-paths.patch
new file mode 100644 (file)
index 0000000..cf0b043
--- /dev/null
@@ -0,0 +1,94 @@
+From 77e70d351db7de07a46ac49b87a6c3c7a60fca7e Mon Sep 17 00:00:00 2001
+From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
+Date: Mon, 26 Oct 2020 13:36:17 -0700
+Subject: Input: sunkbd - avoid use-after-free in teardown paths
+
+From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
+
+commit 77e70d351db7de07a46ac49b87a6c3c7a60fca7e upstream.
+
+We need to make sure we cancel the reinit work before we tear down the
+driver structures.
+
+Reported-by: Bodong Zhao <nopitydays@gmail.com>
+Tested-by: Bodong Zhao <nopitydays@gmail.com>
+Cc: stable@vger.kernel.org
+Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/input/keyboard/sunkbd.c |   41 ++++++++++++++++++++++++++++++++--------
+ 1 file changed, 33 insertions(+), 8 deletions(-)
+
+--- a/drivers/input/keyboard/sunkbd.c
++++ b/drivers/input/keyboard/sunkbd.c
+@@ -111,7 +111,8 @@ static irqreturn_t sunkbd_interrupt(stru
+       switch (data) {
+       case SUNKBD_RET_RESET:
+-              schedule_work(&sunkbd->tq);
++              if (sunkbd->enabled)
++                      schedule_work(&sunkbd->tq);
+               sunkbd->reset = -1;
+               break;
+@@ -212,16 +213,12 @@ static int sunkbd_initialize(struct sunk
+ }
+ /*
+- * sunkbd_reinit() sets leds and beeps to a state the computer remembers they
+- * were in.
++ * sunkbd_set_leds_beeps() sets leds and beeps to a state the computer remembers
++ * they were in.
+  */
+-static void sunkbd_reinit(struct work_struct *work)
++static void sunkbd_set_leds_beeps(struct sunkbd *sunkbd)
+ {
+-      struct sunkbd *sunkbd = container_of(work, struct sunkbd, tq);
+-
+-      wait_event_interruptible_timeout(sunkbd->wait, sunkbd->reset >= 0, HZ);
+-
+       serio_write(sunkbd->serio, SUNKBD_CMD_SETLED);
+       serio_write(sunkbd->serio,
+               (!!test_bit(LED_CAPSL,   sunkbd->dev->led) << 3) |
+@@ -234,11 +231,39 @@ static void sunkbd_reinit(struct work_st
+               SUNKBD_CMD_BELLOFF - !!test_bit(SND_BELL, sunkbd->dev->snd));
+ }
++
++/*
++ * sunkbd_reinit() wait for the keyboard reset to complete and restores state
++ * of leds and beeps.
++ */
++
++static void sunkbd_reinit(struct work_struct *work)
++{
++      struct sunkbd *sunkbd = container_of(work, struct sunkbd, tq);
++
++      /*
++       * It is OK that we check sunkbd->enabled without pausing serio,
++       * as we only want to catch true->false transition that will
++       * happen once and we will be woken up for it.
++       */
++      wait_event_interruptible_timeout(sunkbd->wait,
++                                       sunkbd->reset >= 0 || !sunkbd->enabled,
++                                       HZ);
++
++      if (sunkbd->reset >= 0 && sunkbd->enabled)
++              sunkbd_set_leds_beeps(sunkbd);
++}
++
+ static void sunkbd_enable(struct sunkbd *sunkbd, bool enable)
+ {
+       serio_pause_rx(sunkbd->serio);
+       sunkbd->enabled = enable;
+       serio_continue_rx(sunkbd->serio);
++
++      if (!enable) {
++              wake_up_interruptible(&sunkbd->wait);
++              cancel_work_sync(&sunkbd->tq);
++      }
+ }
+ /*
diff --git a/queue-4.19/powerpc-8xx-always-fault-when-_page_accessed-is-not-set.patch b/queue-4.19/powerpc-8xx-always-fault-when-_page_accessed-is-not-set.patch
new file mode 100644 (file)
index 0000000..60f45fc
--- /dev/null
@@ -0,0 +1,63 @@
+From 29daf869cbab69088fe1755d9dd224e99ba78b56 Mon Sep 17 00:00:00 2001
+From: Christophe Leroy <christophe.leroy@csgroup.eu>
+Date: Mon, 12 Oct 2020 08:54:31 +0000
+Subject: powerpc/8xx: Always fault when _PAGE_ACCESSED is not set
+
+From: Christophe Leroy <christophe.leroy@csgroup.eu>
+
+commit 29daf869cbab69088fe1755d9dd224e99ba78b56 upstream.
+
+The kernel expects pte_young() to work regardless of CONFIG_SWAP.
+
+Make sure a minor fault is taken to set _PAGE_ACCESSED when it
+is not already set, regardless of the selection of CONFIG_SWAP.
+
+This adds at least 3 instructions to the TLB miss exception
+handlers fast path. Following patch will reduce this overhead.
+
+Also update the rotation instruction to the correct number of bits
+to reflect all changes done to _PAGE_ACCESSED over time.
+
+Fixes: d069cb4373fe ("powerpc/8xx: Don't touch ACCESSED when no SWAP.")
+Fixes: 5f356497c384 ("powerpc/8xx: remove unused _PAGE_WRITETHRU")
+Fixes: e0a8e0d90a9f ("powerpc/8xx: Handle PAGE_USER via APG bits")
+Fixes: 5b2753fc3e8a ("powerpc/8xx: Implementation of PAGE_EXEC")
+Fixes: a891c43b97d3 ("powerpc/8xx: Prepare handlers for _PAGE_HUGE for 512k pages.")
+Cc: stable@vger.kernel.org
+Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
+Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
+Link: https://lore.kernel.org/r/af834e8a0f1fa97bfae65664950f0984a70c4750.1602492856.git.christophe.leroy@csgroup.eu
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ arch/powerpc/kernel/head_8xx.S |    8 ++------
+ 1 file changed, 2 insertions(+), 6 deletions(-)
+
+--- a/arch/powerpc/kernel/head_8xx.S
++++ b/arch/powerpc/kernel/head_8xx.S
+@@ -356,11 +356,9 @@ _ENTRY(ITLBMiss_cmp)
+       /* Load the MI_TWC with the attributes for this "segment." */
+       mtspr   SPRN_MI_TWC, r11        /* Set segment attributes */
+-#ifdef CONFIG_SWAP
+-      rlwinm  r11, r10, 32-5, _PAGE_PRESENT
++      rlwinm  r11, r10, 32-7, _PAGE_PRESENT
+       and     r11, r11, r10
+       rlwimi  r10, r11, 0, _PAGE_PRESENT
+-#endif
+       li      r11, RPN_PATTERN | 0x200
+       /* The Linux PTE won't go exactly into the MMU TLB.
+        * Software indicator bits 20 and 23 must be clear.
+@@ -482,11 +480,9 @@ _ENTRY(DTLBMiss_jmp)
+        * r11 = ((r10 & PRESENT) & ((r10 & ACCESSED) >> 5));
+        * r10 = (r10 & ~PRESENT) | r11;
+        */
+-#ifdef CONFIG_SWAP
+-      rlwinm  r11, r10, 32-5, _PAGE_PRESENT
++      rlwinm  r11, r10, 32-7, _PAGE_PRESENT
+       and     r11, r11, r10
+       rlwimi  r10, r11, 0, _PAGE_PRESENT
+-#endif
+       /* The Linux PTE won't go exactly into the MMU TLB.
+        * Software indicator bits 24, 25, 26, and 27 must be
+        * set.  All other Linux PTE bits control the behavior
index 98f80a39cd5937f9e2a0e513f3131fe9d337687c..eb0cbc927a963bbee6871f1571e803f9378112ca 100644 (file)
@@ -6,3 +6,5 @@ powerpc-fix-__clear_user-with-kuap-enabled.patch
 powerpc-uaccess-evaluate-macro-arguments-once-before-user-access-is-allowed.patch
 powerpc-64s-flush-l1d-after-user-accesses.patch
 revert-perf-cs-etm-move-definition-of-traceid_list-global-variable-from-header-file.patch
+powerpc-8xx-always-fault-when-_page_accessed-is-not-set.patch
+input-sunkbd-avoid-use-after-free-in-teardown-paths.patch