linux/arch/parisc/kernel
John David Anglin 9b2f4e7385 parisc: Update comments in make_insert_tlb
commit cb22f247f3 upstream.

The following testcase exposed a problem with our read access checks
in get_user() and raw_copy_from_user():

#include <stdint.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
#include <sys/mman.h>
#include <sys/types.h>

int main(int argc, char **argv)
{
  unsigned long page_size = sysconf(_SC_PAGESIZE);
  char *p = malloc(3 * page_size);
  char *p_aligned;

  /* initialize memory region. If not initialized, write syscall below will correctly return EFAULT. */
  if (1)
	memset(p, 'X', 3 * page_size);

  p_aligned = (char *) ((((uintptr_t) p) + (2*page_size - 1)) & ~(page_size - 1));
  /* Drop PROT_READ protection. Kernel and userspace should fault when accessing that memory region */
  mprotect(p_aligned, page_size, PROT_NONE);

  /* the following write() should return EFAULT, since PROT_READ was dropped by previous mprotect() */
  int ret = write(2, p_aligned, 1);
  if (!ret || errno != EFAULT)
	printf("\n FAILURE: write() did not returned expected EFAULT value\n");

  return 0;
}

Because of the way _PAGE_READ is handled, kernel code never generates
a read access fault when it access a page as the kernel privilege level
is always less than PL1 in the PTE.

This patch reworks the comments in the make_insert_tlb macro to try
to make this clearer.

Signed-off-by: John David Anglin <dave.anglin@bell.net>
Signed-off-by: Helge Deller <deller@gmx.de>
Cc: stable@vger.kernel.org # v5.12+
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
History 2025-08-28 16:26:08 +02:00
..
syscalls parisc: use generic sys_fanotify_mark implementation 2024-07-05 09:31:51 +02:00
vdso32 parisc: Add missing FORCE prerequisites in Makefile 2023-01-07 11:11:56 +01:00
vdso64 parisc: Add missing FORCE prerequisites in Makefile 2023-01-07 11:11:56 +01:00
.gitignore .gitignore: add SPDX License Identifier 2020-03-25 11:50:48 +01:00
alternative.c parisc: Use num_present_cpus() in alternative patching code 2023-05-30 14:03:18 +01:00
asm-offsets.c parisc: Fix vDSO signal breakage on 32-bit kernel 2022-07-02 18:36:58 +02:00
audit.c audit: add support for the openat2 syscall 2021-10-01 16:52:48 -04:00
cache.c parisc: Fix flush_dcache_page() for usage from irq context 2023-05-30 14:03:18 +01:00
compat_audit.c audit: add support for the openat2 syscall 2021-10-01 16:52:48 -04:00
drivers.c parisc: Prevent hung tasks when printing inventory on serial console 2024-02-23 09:12:33 +01:00
entry.S parisc: Update comments in make_insert_tlb 2025-08-28 16:26:08 +02:00
firmware.c parisc/firmware: Fix F-extend for PDC addresses 2024-01-31 16:16:59 -08:00
ftrace.c parisc/ftrace: Fix function graph tracing disablement 2024-12-14 19:54:02 +01:00
hardware.c parisc: Clean up names in hardware database 2022-08-01 18:43:23 +02:00
head.S parisc: Prevent booting 64-bit kernels on PA1.x machines 2023-11-28 17:07:14 +00:00
hpmc.S parisc: Re-use toc_stack as hpmc_stack 2022-01-11 11:57:37 +01:00
inventory.c parisc: Add qemu fw_cfg interface 2020-10-15 08:10:37 +02:00
irq.c parisc: Use irq_enter_rcu() to fix warning at kernel/context_tracking.c:367 2024-08-29 17:30:36 +02:00
jump_label.c jump_label: make initial NOP patching the special case 2022-06-24 09:48:55 +02:00
kexec.c parisc: add support for kexec_file_load() syscall 2019-09-08 15:41:46 +02:00
kexec_file.c parisc: add support for kexec_file_load() syscall 2019-09-08 15:41:46 +02:00
kgdb.c parisc: Drop duplicate kgdb_pdc console 2023-01-07 11:11:56 +01:00
kprobes.c parisc: Fix typos in comments 2022-05-08 20:01:12 +02:00
Makefile kbuild: use obj-y instead extra-y for objects placed at the head 2022-10-02 18:04:05 +09:00
module.c mm: don't include asm/pgtable.h if linux/mm.h is already included 2020-06-09 09:39:13 -07:00
pa7300lc.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
pacache.S parisc: Ensure page alignment in flush functions 2023-05-11 23:03:38 +09:00
parisc_ksyms.c parisc: add missing export of __cmpxchg_u8() 2024-06-12 11:03:04 +02:00
patch.c parisc: Fix patch code locking and flushing 2022-05-17 21:52:59 +02:00
pci-dma.c parisc: Improve cache flushing for PCXL in arch_sync_dma_for_cpu() 2023-06-21 16:00:53 +02:00
pci.c parisc: Drop comments which are already in pci.h 2019-09-05 16:41:11 +02:00
pdc_chassis.c kernel.h: split out panic and oops helpers 2021-07-01 11:06:04 -07:00
pdc_cons.c parisc: Drop locking in pdc console code 2023-01-07 11:11:56 +01:00
pdt.c parisc: PDT: Fix missing prototype warning 2025-05-02 07:47:01 +02:00
perf.c parisc/perf: open access for CAP_PERFMON privileged process 2020-04-16 12:19:08 -03:00
perf_asm.S treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 156 2019-05-30 11:26:35 -07:00
perf_images.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 156 2019-05-30 11:26:35 -07:00
process.c parisc: Allow to reboot machine after system halt 2023-05-30 14:03:18 +01:00
processor.c Revert "parisc: Only list existing CPUs in cpu_possible_mask" 2024-03-01 13:26:31 +01:00
ptrace.c parisc: Wire up PTRACE_GETREGS/PTRACE_SETREGS for compat case 2023-02-09 11:28:20 +01:00
real2.S parisc: Fix argument pointer in real64_call_asm() 2023-05-11 23:03:38 +09:00
relocate_kernel.S parisc: add kexec syscall support 2019-09-08 15:37:04 +02:00
setup.c parisc: Convert PDC console to an early console 2022-10-11 12:01:24 +02:00
signal.c ptrace: Cleanups for v5.18 2022-03-28 17:29:53 -07:00
signal32.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 156 2019-05-30 11:26:35 -07:00
signal32.h parisc: Add vDSO support 2022-03-11 19:49:30 +01:00
smp.c parisc: Fix crash with nr_cpus=1 option 2023-10-10 22:00:44 +02:00
stacktrace.c parisc: Fix implicit declaration of function '__kernel_text_address' 2021-11-13 22:10:56 +01:00
sys_parisc.c parisc: sys_parisc: parisc_personality() is called from asm code 2023-09-02 09:16:19 +02:00
sys_parisc32.c parisc: use generic sys_fanotify_mark implementation 2024-07-05 09:31:51 +02:00
syscall.S parisc: Revise gateway LWS calls to probe user read access 2025-08-28 16:26:08 +02:00
time.c parisc: Mark cr16 clock unstable on all SMP machines 2022-05-08 20:01:12 +02:00
toc.c parisc: Fix missing prototype for 'toc_intr' warning in toc.c 2022-01-20 20:39:19 +01:00
toc_asm.S parisc: Enable TOC (transfer of contents) feature unconditionally 2022-01-11 11:57:37 +01:00
topology.c parisc: fix a crash with multicore scheduler 2022-06-03 09:54:01 +02:00
traps.c parisc: Handle kprobes breakpoints only in kernel context 2023-05-30 14:03:18 +01:00
unaligned.c parisc/unaligned: Fix hex output to show 8 hex chars 2025-06-27 11:07:29 +01:00
unwind.c parisc: Move thread_info into task struct 2021-11-01 07:35:59 +01:00
vdso.c treewide: use prandom_u32_max() when possible, part 1 2022-10-11 17:42:55 -06:00
vmlinux.lds.S parisc: Ensure 32-bit alignment on parisc unwind section 2023-12-08 08:51:16 +01:00