]> git.itanic.dy.fi Git - linux-stable/commit
parisc: Flush kernel data mapping in set_pte_at() when installing pte for user page
authorJohn David Anglin <dave.anglin@bell.net>
Mon, 8 Nov 2021 21:48:16 +0000 (16:48 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 23 Sep 2022 12:16:56 +0000 (14:16 +0200)
commit7bbdf49e2624a318b5e08f3a1acb0503ecd107d9
tree83d337b97b72d16ef0642ba7b67deb464d2927a6
parentb00a56e64713cf3e8f5ca00a943140b294c5f24e
parisc: Flush kernel data mapping in set_pte_at() when installing pte for user page

[ Upstream commit 38860b2c8bb1b92f61396eb06a63adff916fc31d ]

For years, there have been random segmentation faults in userspace on
SMP PA-RISC machines.  It occurred to me that this might be a problem in
set_pte_at().  MIPS and some other architectures do cache flushes when
installing PTEs with the present bit set.

Here I have adapted the code in update_mmu_cache() to flush the kernel
mapping when the kernel flush is deferred, or when the kernel mapping
may alias with the user mapping.  This simplifies calls to
update_mmu_cache().

I also changed the barrier in set_pte() from a compiler barrier to a
full memory barrier.  I know this change is not sufficient to fix the
problem.  It might not be needed.

I have had a few days of operation with 5.14.16 to 5.15.1 and haven't
seen any random segmentation faults on rp3440 or c8000 so far.

Signed-off-by: John David Anglin <dave.anglin@bell.net>
Signed-off-by: Helge Deller <deller@gmx.de>
Cc: stable@kernel.org # 5.12+
Signed-off-by: Sasha Levin <sashal@kernel.org>
arch/parisc/include/asm/pgtable.h
arch/parisc/kernel/cache.c