WSL2-Linux-Kernel/arch/powerpc/platforms/pseries
Anjali K e59822f9d7 powerpc/pseries: Whitelist dtl slub object for copying to userspace
[ Upstream commit 1a14150e1656f7a332a943154fc486504db4d586 ]

Reading the dispatch trace log from /sys/kernel/debug/powerpc/dtl/cpu-*
results in a BUG() when the config CONFIG_HARDENED_USERCOPY is enabled as
shown below.

    kernel BUG at mm/usercopy.c:102!
    Oops: Exception in kernel mode, sig: 5 [#1]
    LE PAGE_SIZE=64K MMU=Radix SMP NR_CPUS=2048 NUMA pSeries
    Modules linked in: xfs libcrc32c dm_service_time sd_mod t10_pi sg ibmvfc
    scsi_transport_fc ibmveth pseries_wdt dm_multipath dm_mirror dm_region_hash dm_log dm_mod fuse
    CPU: 27 PID: 1815 Comm: python3 Not tainted 6.10.0-rc3 #85
    Hardware name: IBM,9040-MRX POWER10 (raw) 0x800200 0xf000006 of:IBM,FW1060.00 (NM1060_042) hv:phyp pSeries
    NIP:  c0000000005d23d4 LR: c0000000005d23d0 CTR: 00000000006ee6f8
    REGS: c000000120c078c0 TRAP: 0700   Not tainted  (6.10.0-rc3)
    MSR:  8000000000029033 <SF,EE,ME,IR,DR,RI,LE>  CR: 2828220f  XER: 0000000e
    CFAR: c0000000001fdc80 IRQMASK: 0
    [ ... GPRs omitted ... ]
    NIP [c0000000005d23d4] usercopy_abort+0x78/0xb0
    LR [c0000000005d23d0] usercopy_abort+0x74/0xb0
    Call Trace:
     usercopy_abort+0x74/0xb0 (unreliable)
     __check_heap_object+0xf8/0x120
     check_heap_object+0x218/0x240
     __check_object_size+0x84/0x1a4
     dtl_file_read+0x17c/0x2c4
     full_proxy_read+0x8c/0x110
     vfs_read+0xdc/0x3a0
     ksys_read+0x84/0x144
     system_call_exception+0x124/0x330
     system_call_vectored_common+0x15c/0x2ec
    --- interrupt: 3000 at 0x7fff81f3ab34

Commit 6d07d1cd30 ("usercopy: Restrict non-usercopy caches to size 0")
requires that only whitelisted areas in slab/slub objects can be copied to
userspace when usercopy hardening is enabled using CONFIG_HARDENED_USERCOPY.
Dtl contains hypervisor dispatch events which are expected to be read by
privileged users. Hence mark this safe for user access.
Specify useroffset=0 and usersize=DISPATCH_LOG_BYTES to whitelist the
entire object.

Co-developed-by: Vishal Chourasia <vishalc@linux.ibm.com>
Signed-off-by: Vishal Chourasia <vishalc@linux.ibm.com>
Signed-off-by: Anjali K <anjalik@linux.ibm.com>
Reviewed-by: Srikar Dronamraju <srikar@linux.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://msgid.link/20240614173844.746818-1-anjalik@linux.ibm.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-07-27 10:46:13 +02:00
..
Kconfig powerpc/pseries: Implement paravirt qspinlocks for SPLPAR 2020-07-27 00:01:29 +10:00
Makefile powerpc/pseries/vas: Integrate API with open/close windows 2021-06-20 21:58:57 +10:00
cmm.c mm: remove unneeded includes of <asm/pgalloc.h> 2020-08-07 11:33:26 -07:00
dlpar.c powerpc/pseries/dlpar: use rtas_get_sensor() 2021-06-25 14:47:20 +10:00
dtl.c powerpc: rename powerpc_debugfs_root to arch_debugfs_dir 2021-08-13 22:04:26 +10:00
eeh_pseries.c powerpc/pseries/eeh: use correct API for error log size 2022-12-31 13:14:36 +01:00
event_sources.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 156 2019-05-30 11:26:35 -07:00
firmware.c powerpc/pseries: Add support for FORM2 associativity 2021-08-13 22:04:27 +10:00
hotplug-cpu.c powerpc/pseries: Fix build error when NUMA=n 2021-08-16 14:11:00 +10:00
hotplug-memory.c powerpc/pseries/memhp: Fix access beyond end of drmem array 2024-01-25 14:52:32 -08:00
hvCall.S powerpc/64s: avoid reloading (H)SRR registers if they are still valid 2021-06-25 00:06:55 +10:00
hvCall_inst.c powerpc/pseries: Make symbol '__pcpu_scope_hcall_stats' static 2021-04-14 23:04:17 +10:00
hvconsole.c powerpc updates for 5.3 2019-07-13 16:08:36 -07:00
hvcserver.c powerpc: Use fallthrough pseudo-keyword 2020-07-29 21:09:37 +10:00
ibmebus.c powerpc/pseries: fix possible memory leak in ibmebus_bus_init() 2023-09-23 11:09:58 +02:00
io_event_irq.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
iommu.c powerpc/pseries/ddw: simplify enable_ddw() 2023-11-28 16:56:33 +00:00
kexec.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
lpar.c powerpc/pseries: Add failure related checks for h_get_mpp and h_get_ppp 2024-06-16 13:39:44 +02:00
lparcfg.c powerpc/pseries: Add failure related checks for h_get_mpp and h_get_ppp 2024-06-16 13:39:44 +02:00
mobility.c powerpc/pseries/mobility: ignore ibm, platform-facilities updates 2021-11-18 19:17:19 +01:00
msi.c powerpc/pseries/msi: Add an empty irq_write_msi_msg() handler 2021-10-07 23:33:25 +11:00
nvram.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
of_helpers.c powerpc/pseries: Fix of_read_drc_info_cell() to point at next record 2020-03-25 12:06:43 +11:00
of_helpers.h
papr_scm.c powerpc/papr_scm: Update the NUMA distance table for the target node 2023-04-20 12:13:56 +02:00
pci.c powerpc/powernv: remove the nvlink support 2021-05-02 23:35:32 +10:00
pci_dlpar.c powerpc/pseries: Fix use after free in remove_phb_dynamic() 2022-04-08 14:23:42 +02:00
pmem.c powerpc/pseries/pmem: Make symbol 'drc_pmem_match' static 2021-04-14 23:04:17 +10:00
power.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 167 2019-05-30 11:26:39 -07:00
pseries.h powerpc/pseries: wire up rng during setup_arch() 2022-06-29 09:03:32 +02:00
pseries_energy.c powerpc/pseries: Fix drc-info mappings of logical cpus to drc-index 2019-11-13 16:57:57 +11:00
ras.c powerpc: Refactor verification of MSR_RI 2021-08-26 21:21:07 +10:00
reconfig.c proc: convert everything to "struct proc_ops" 2020-02-04 03:05:26 +00:00
rng.c powerpc/pseries: wire up rng during setup_arch() 2022-06-29 09:03:32 +02:00
rtas-fadump.c powerpc/fadump: make symbol 'rtas_fadump_set_regval' static 2021-04-14 23:04:19 +10:00
rtas-fadump.h powerpc/fadump: support holes in kernel boot memory area 2019-09-14 00:04:46 +10:00
scanlog.c proc: convert everything to "struct proc_ops" 2020-02-04 03:05:26 +00:00
setup.c powerpc/pseries: Whitelist dtl slub object for copying to userspace 2024-07-27 10:46:13 +02:00
smp.c powerpc/preempt: Don't touch the idle task's preempt_count during hotplug 2021-07-08 23:38:10 +10:00
suspend.c powerpc/pseries/hibernation: remove prepare_late() callback 2020-12-08 21:41:02 +11:00
svm.c powerpc/svm: Don't issue ultracalls if !mem_encrypt_active() 2021-07-31 22:28:39 -04:00
vas.c powerpc/64s: Fix VAS mm use after free 2023-07-23 13:47:12 +02:00
vas.h powerpc/pseries/vas: Define VAS/NXGZIP hcalls and structs 2021-06-20 21:58:56 +10:00
vio.c dma-mapping updates for Linux 5.15 2021-09-02 10:32:06 -07:00
vphn.c powerpc/vphn: Check for error from hcall_vphn 2020-03-04 22:44:30 +11:00