]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
4.19-stable patches
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 24 Jan 2022 15:19:13 +0000 (16:19 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 24 Jan 2022 15:19:13 +0000 (16:19 +0100)
added patches:
mips-s390-sh-sparc-gup-work-around-the-cow-can-break-either-way-issue.patch

queue-4.19/mips-s390-sh-sparc-gup-work-around-the-cow-can-break-either-way-issue.patch [new file with mode: 0644]
queue-4.19/series

diff --git a/queue-4.19/mips-s390-sh-sparc-gup-work-around-the-cow-can-break-either-way-issue.patch b/queue-4.19/mips-s390-sh-sparc-gup-work-around-the-cow-can-break-either-way-issue.patch
new file mode 100644 (file)
index 0000000..3a8bbb8
--- /dev/null
@@ -0,0 +1,97 @@
+From ben@decadent.org.uk  Mon Jan 24 16:18:27 2022
+From: Ben Hutchings <ben@decadent.org.uk>
+Date: Mon, 24 Jan 2022 16:11:18 +0100
+Subject: mips,s390,sh,sparc: gup: Work around the "COW can break either way" issue
+To: stable@vger.kernel.org
+Cc: Suren Baghdasaryan <surenb@google.com>
+Message-ID: <Ye7BluXgj+5i9VUb@decadent.org.uk>
+Content-Disposition: inline
+
+From: Ben Hutchings <ben@decadent.org.uk>
+
+In Linux 4.14 and 4.19 these architectures still have their own
+implementations of get_user_pages_fast().  These also need to force
+the write flag on when taking the fast path.
+
+Fixes: 407faed92b4a ("gup: document and work around "COW can break either way" issue")
+Fixes: 5e24029791e8 ("gup: document and work around "COW can break either way" issue")
+Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
+---
+ arch/mips/mm/gup.c  |    9 ++++++++-
+ arch/s390/mm/gup.c  |    9 ++++++++-
+ arch/sh/mm/gup.c    |    9 ++++++++-
+ arch/sparc/mm/gup.c |    9 ++++++++-
+ 4 files changed, 32 insertions(+), 4 deletions(-)
+
+--- a/arch/mips/mm/gup.c
++++ b/arch/mips/mm/gup.c
+@@ -274,7 +274,14 @@ int get_user_pages_fast(unsigned long st
+               next = pgd_addr_end(addr, end);
+               if (pgd_none(pgd))
+                       goto slow;
+-              if (!gup_pud_range(pgd, addr, next, write, pages, &nr))
++              /*
++               * The FAST_GUP case requires FOLL_WRITE even for pure reads,
++               * because get_user_pages() may need to cause an early COW in
++               * order to avoid confusing the normal COW routines. So only
++               * targets that are already writable are safe to do by just
++               * looking at the page tables.
++               */
++              if (!gup_pud_range(pgd, addr, next, 1, pages, &nr))
+                       goto slow;
+       } while (pgdp++, addr = next, addr != end);
+       local_irq_enable();
+--- a/arch/s390/mm/gup.c
++++ b/arch/s390/mm/gup.c
+@@ -287,7 +287,14 @@ int get_user_pages_fast(unsigned long st
+       might_sleep();
+       start &= PAGE_MASK;
+-      nr = __get_user_pages_fast(start, nr_pages, write, pages);
++      /*
++       * The FAST_GUP case requires FOLL_WRITE even for pure reads,
++       * because get_user_pages() may need to cause an early COW in
++       * order to avoid confusing the normal COW routines. So only
++       * targets that are already writable are safe to do by just
++       * looking at the page tables.
++       */
++      nr = __get_user_pages_fast(start, nr_pages, 1, pages);
+       if (nr == nr_pages)
+               return nr;
+--- a/arch/sh/mm/gup.c
++++ b/arch/sh/mm/gup.c
+@@ -242,7 +242,14 @@ int get_user_pages_fast(unsigned long st
+               next = pgd_addr_end(addr, end);
+               if (pgd_none(pgd))
+                       goto slow;
+-              if (!gup_pud_range(pgd, addr, next, write, pages, &nr))
++              /*
++               * The FAST_GUP case requires FOLL_WRITE even for pure reads,
++               * because get_user_pages() may need to cause an early COW in
++               * order to avoid confusing the normal COW routines. So only
++               * targets that are already writable are safe to do by just
++               * looking at the page tables.
++               */
++              if (!gup_pud_range(pgd, addr, next, 1, pages, &nr))
+                       goto slow;
+       } while (pgdp++, addr = next, addr != end);
+       local_irq_enable();
+--- a/arch/sparc/mm/gup.c
++++ b/arch/sparc/mm/gup.c
+@@ -303,7 +303,14 @@ int get_user_pages_fast(unsigned long st
+               next = pgd_addr_end(addr, end);
+               if (pgd_none(pgd))
+                       goto slow;
+-              if (!gup_pud_range(pgd, addr, next, write, pages, &nr))
++              /*
++               * The FAST_GUP case requires FOLL_WRITE even for pure reads,
++               * because get_user_pages() may need to cause an early COW in
++               * order to avoid confusing the normal COW routines. So only
++               * targets that are already writable are safe to do by just
++               * looking at the page tables.
++               */
++              if (!gup_pud_range(pgd, addr, next, 1, pages, &nr))
+                       goto slow;
+       } while (pgdp++, addr = next, addr != end);
index 0c01cf99b49358606d889d42567b3f50e35ef813..05b066e10165722af151e07a0bcf4d4a0ed59343 100644 (file)
@@ -237,3 +237,4 @@ bcmgenet-add-wol-irq-check.patch
 scripts-dtc-dtx_diff-remove-broken-example-from-help-text.patch
 lib82596-fix-irq-check-in-sni_82596_probe.patch
 mtd-nand-bbt-fix-corner-case-in-bad-block-table-handling.patch
+mips-s390-sh-sparc-gup-work-around-the-cow-can-break-either-way-issue.patch