]> git.baikalelectronics.ru Git - kernel.git/commit
powerpc/mm: Fix false detection of read faults
authorRussell Currey <ruscur@russell.cc>
Fri, 10 Mar 2023 05:08:34 +0000 (16:08 +1100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 22 Mar 2023 12:33:47 +0000 (13:33 +0100)
commit7efa32f298e86132c3c6d9b290165ae4cff40dc8
tree82cc98a47c954117292e445cc44b44e15778dda8
parent99ab56ed2a2d119f2de940fb7337d9150ce2f614
powerpc/mm: Fix false detection of read faults

[ Upstream commit e929aad89efe5e7f38c4b868721e6c9b64a47fe8 ]

To support detection of read faults with Radix execute-only memory, the
vma_is_accessible() check in access_error() (which checks for PROT_NONE)
was replaced with a check to see if VM_READ was missing, and if so,
returns true to assert the fault was caused by a bad read.

This is incorrect, as it ignores that both VM_WRITE and VM_EXEC imply
read on powerpc, as defined in protection_map[].  This causes mappings
containing VM_WRITE or VM_EXEC without VM_READ to misreport the cause of
page faults, since the MMU is still allowing reads.

Correct this by restoring the original vma_is_accessible() check for
PROT_NONE mappings, and adding a separate check for Radix PROT_EXEC-only
mappings.

Fixes: 1ae105b49f87 ("powerpc/mm: Support execute-only memory on the Radix MMU")
Reported-by: Michal Suchánek <msuchanek@suse.de>
Link: https://lore.kernel.org/r/20230308152702.GR19419@kitsune.suse.cz
Tested-by: Benjamin Gray <bgray@linux.ibm.com>
Signed-off-by: Russell Currey <ruscur@russell.cc>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://msgid.link/20230310050834.63105-1-ruscur@russell.cc
Signed-off-by: Sasha Levin <sashal@kernel.org>
arch/powerpc/mm/fault.c