linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	stable@vger.kernel.org, "Dmitry V. Levin" <ldv@altlinux.org>,
	Nicholas Piggin <npiggin@gmail.com>,
	Michael Ellerman <mpe@ellerman.id.au>
Subject: [PATCH 5.10 064/104] powerpc/64s/syscall: Use pt_regs.trap to distinguish syscall ABI difference between sc and scv syscalls
Date: Mon, 24 May 2021 17:25:59 +0200	[thread overview]
Message-ID: <20210524152334.971284393@linuxfoundation.org> (raw)
In-Reply-To: <20210524152332.844251980@linuxfoundation.org>

From: Nicholas Piggin <npiggin@gmail.com>

commit 5665bc35c1ed917ac8fd06cb651317bb47a65b10 upstream.

The sc and scv 0 system calls have different ABI conventions, and
ptracers need to know which system call type is being used if they want
to look at the syscall registers.

Document that pt_regs.trap can be used for this, and fix one in-tree user
to work with scv 0 syscalls.

Fixes: 7fa95f9adaee ("powerpc/64s: system call support for scv/rfscv instructions")
Cc: stable@vger.kernel.org # v5.9+
Reported-by: "Dmitry V. Levin" <ldv@altlinux.org>
Suggested-by: "Dmitry V. Levin" <ldv@altlinux.org>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20210520111931.2597127-1-npiggin@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 Documentation/powerpc/syscall64-abi.rst       |   10 +++++++++
 tools/testing/selftests/seccomp/seccomp_bpf.c |   27 +++++++++++++++++---------
 2 files changed, 28 insertions(+), 9 deletions(-)

--- a/Documentation/powerpc/syscall64-abi.rst
+++ b/Documentation/powerpc/syscall64-abi.rst
@@ -96,6 +96,16 @@ auxiliary vector.
 
 scv 0 syscalls will always behave as PPC_FEATURE2_HTM_NOSC.
 
+ptrace
+------
+When ptracing system calls (PTRACE_SYSCALL), the pt_regs.trap value contains
+the system call type that can be used to distinguish between sc and scv 0
+system calls, and the different register conventions can be accounted for.
+
+If the value of (pt_regs.trap & 0xfff0) is 0xc00 then the system call was
+performed with the sc instruction, if it is 0x3000 then the system call was
+performed with the scv 0 instruction.
+
 vsyscall
 ========
 
--- a/tools/testing/selftests/seccomp/seccomp_bpf.c
+++ b/tools/testing/selftests/seccomp/seccomp_bpf.c
@@ -1753,16 +1753,25 @@ TEST_F(TRACE_poke, getpid_runs_normally)
 # define SYSCALL_RET_SET(_regs, _val)				\
 	do {							\
 		typeof(_val) _result = (_val);			\
-		/*						\
-		 * A syscall error is signaled by CR0 SO bit	\
-		 * and the code is stored as a positive value.	\
-		 */						\
-		if (_result < 0) {				\
-			SYSCALL_RET(_regs) = -_result;		\
-			(_regs).ccr |= 0x10000000;		\
-		} else {					\
+		if ((_regs.trap & 0xfff0) == 0x3000) {		\
+			/*					\
+			 * scv 0 system call uses -ve result	\
+			 * for error, so no need to adjust.	\
+			 */					\
 			SYSCALL_RET(_regs) = _result;		\
-			(_regs).ccr &= ~0x10000000;		\
+		} else {					\
+			/*					\
+			 * A syscall error is signaled by the	\
+			 * CR0 SO bit and the code is stored as	\
+			 * a positive value.			\
+			 */					\
+			if (_result < 0) {			\
+				SYSCALL_RET(_regs) = -_result;	\
+				(_regs).ccr |= 0x10000000;	\
+			} else {				\
+				SYSCALL_RET(_regs) = _result;	\
+				(_regs).ccr &= ~0x10000000;	\
+			}					\
 		}						\
 	} while (0)
 # define SYSCALL_RET_SET_ON_PTRACE_EXIT



  parent reply	other threads:[~2021-05-24 15:57 UTC|newest]

Thread overview: 116+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-24 15:24 [PATCH 5.10 000/104] 5.10.40-rc1 review Greg Kroah-Hartman
2021-05-24 15:24 ` [PATCH 5.10 001/104] firmware: arm_scpi: Prevent the ternary sign expansion bug Greg Kroah-Hartman
2021-05-24 15:24 ` [PATCH 5.10 002/104] openrisc: Fix a memory leak Greg Kroah-Hartman
2021-05-24 15:24 ` [PATCH 5.10 003/104] tee: amdtee: unload TA only when its refcount becomes 0 Greg Kroah-Hartman
2021-05-24 15:24 ` [PATCH 5.10 004/104] RDMA/siw: Properly check send and receive CQ pointers Greg Kroah-Hartman
2021-05-24 15:25 ` [PATCH 5.10 005/104] RDMA/siw: Release xarray entry Greg Kroah-Hartman
2021-05-24 15:25 ` [PATCH 5.10 006/104] RDMA/core: Prevent divide-by-zero error triggered by the user Greg Kroah-Hartman
2021-05-24 15:25 ` [PATCH 5.10 007/104] RDMA/rxe: Clear all QP fields if creation failed Greg Kroah-Hartman
2021-05-24 15:25 ` [PATCH 5.10 008/104] scsi: ufs: core: Increase the usable queue depth Greg Kroah-Hartman
2021-05-24 15:25 ` [PATCH 5.10 009/104] scsi: qedf: Add pointer checks in qedf_update_link_speed() Greg Kroah-Hartman
2021-05-24 15:25 ` [PATCH 5.10 010/104] scsi: qla2xxx: Fix error return code in qla82xx_write_flash_dword() Greg Kroah-Hartman
2021-05-24 15:25 ` [PATCH 5.10 011/104] RDMA/mlx5: Recover from fatal event in dual port mode Greg Kroah-Hartman
2021-05-24 15:25 ` [PATCH 5.10 012/104] RDMA/core: Dont access cm_id after its destruction Greg Kroah-Hartman
2021-05-24 15:25 ` [PATCH 5.10 013/104] nvmet: remove unused ctrl->cqs Greg Kroah-Hartman
2021-05-24 15:25 ` [PATCH 5.10 014/104] nvmet: fix memory leak in nvmet_alloc_ctrl() Greg Kroah-Hartman
2021-05-24 15:25 ` [PATCH 5.10 015/104] nvme-loop: fix memory leak in nvme_loop_create_ctrl() Greg Kroah-Hartman
2021-05-24 15:25 ` [PATCH 5.10 016/104] nvme-tcp: rerun io_work if req_list is not empty Greg Kroah-Hartman
2021-05-24 15:25 ` [PATCH 5.10 017/104] nvme-fc: clear q_live at beginning of association teardown Greg Kroah-Hartman
2021-05-24 15:25 ` [PATCH 5.10 018/104] platform/mellanox: mlxbf-tmfifo: Fix a memory barrier issue Greg Kroah-Hartman
2021-05-24 15:25 ` [PATCH 5.10 019/104] platform/x86: intel_int0002_vgpio: Only call enable_irq_wake() when using s2idle Greg Kroah-Hartman
2021-05-24 15:25 ` [PATCH 5.10 020/104] platform/x86: dell-smbios-wmi: Fix oops on rmmod dell_smbios Greg Kroah-Hartman
2021-05-24 15:25 ` [PATCH 5.10 021/104] RDMA/mlx5: Fix query DCT via DEVX Greg Kroah-Hartman
2021-05-24 15:25 ` [PATCH 5.10 022/104] RDMA/uverbs: Fix a NULL vs IS_ERR() bug Greg Kroah-Hartman
2021-05-24 15:25 ` [PATCH 5.10 023/104] tools/testing/selftests/exec: fix link error Greg Kroah-Hartman
2021-05-24 15:25 ` [PATCH 5.10 024/104] powerpc/pseries: Fix hcall tracing recursion in pv queued spinlocks Greg Kroah-Hartman
2021-05-24 15:25 ` [PATCH 5.10 025/104] ptrace: make ptrace() fail if the tracee changed its pid unexpectedly Greg Kroah-Hartman
2021-05-24 15:25 ` [PATCH 5.10 026/104] nvmet: seset ns->file when open fails Greg Kroah-Hartman
2021-05-24 15:25 ` [PATCH 5.10 027/104] perf/x86: Avoid touching LBR_TOS MSR for Arch LBR Greg Kroah-Hartman
2021-05-24 15:25 ` [PATCH 5.10 028/104] locking/lockdep: Correct calling tracepoints Greg Kroah-Hartman
2021-05-24 15:25 ` [PATCH 5.10 029/104] locking/mutex: clear MUTEX_FLAGS if wait_list is empty due to signal Greg Kroah-Hartman
2021-05-24 15:25 ` [PATCH 5.10 030/104] powerpc: Fix early setup to make early_ioremap() work Greg Kroah-Hartman
2021-05-24 15:25 ` [PATCH 5.10 031/104] btrfs: avoid RCU stalls while running delayed iputs Greg Kroah-Hartman
2021-05-24 15:25 ` [PATCH 5.10 032/104] cifs: fix memory leak in smb2_copychunk_range Greg Kroah-Hartman
2021-05-24 15:25 ` [PATCH 5.10 033/104] misc: eeprom: at24: check suspend status before disable regulator Greg Kroah-Hartman
2021-05-24 15:25 ` [PATCH 5.10 034/104] ALSA: dice: fix stream format for TC Electronic Konnekt Live at high sampling transfer frequency Greg Kroah-Hartman
2021-05-24 15:25 ` [PATCH 5.10 035/104] ALSA: intel8x0: Dont update period unless prepared Greg Kroah-Hartman
2021-05-24 15:25 ` [PATCH 5.10 036/104] ALSA: firewire-lib: fix amdtp_packet tracepoints event for packet_index field Greg Kroah-Hartman
2021-05-24 15:25 ` [PATCH 5.10 037/104] ALSA: line6: Fix racy initialization of LINE6 MIDI Greg Kroah-Hartman
2021-05-24 15:25 ` [PATCH 5.10 038/104] ALSA: dice: fix stream format at middle sampling rate for Alesis iO 26 Greg Kroah-Hartman
2021-05-24 15:25 ` [PATCH 5.10 039/104] ALSA: firewire-lib: fix calculation for size of IR context payload Greg Kroah-Hartman
2021-05-24 15:25 ` [PATCH 5.10 040/104] ALSA: usb-audio: Validate MS endpoint descriptors Greg Kroah-Hartman
2021-05-24 15:25 ` [PATCH 5.10 041/104] ALSA: bebob/oxfw: fix Kconfig entry for Mackie d.2 Pro Greg Kroah-Hartman
2021-05-24 15:25 ` [PATCH 5.10 042/104] ALSA: hda: fixup headset for ASUS GU502 laptop Greg Kroah-Hartman
2021-05-24 15:25 ` [PATCH 5.10 043/104] Revert "ALSA: sb8: add a check for request_region" Greg Kroah-Hartman
2021-05-24 15:25 ` [PATCH 5.10 044/104] ALSA: firewire-lib: fix check for the size of isochronous packet payload Greg Kroah-Hartman
2021-05-24 15:25 ` [PATCH 5.10 045/104] ALSA: hda/realtek: reset eapd coeff to default value for alc287 Greg Kroah-Hartman
2021-05-24 15:25 ` [PATCH 5.10 046/104] ALSA: hda/realtek: Add some CLOVE SSIDs of ALC293 Greg Kroah-Hartman
2021-05-24 15:25 ` [PATCH 5.10 047/104] ALSA: hda/realtek: Fix silent headphone output on ASUS UX430UA Greg Kroah-Hartman
2021-05-24 15:25 ` [PATCH 5.10 048/104] ALSA: hda/realtek: Add fixup for HP OMEN laptop Greg Kroah-Hartman
2021-05-24 15:25 ` [PATCH 5.10 049/104] ALSA: hda/realtek: Add fixup for HP Spectre x360 15-df0xxx Greg Kroah-Hartman
2021-05-24 15:25 ` [PATCH 5.10 050/104] uio_hv_generic: Fix a memory leak in error handling paths Greg Kroah-Hartman
2021-05-24 15:25 ` [PATCH 5.10 051/104] Revert "rapidio: fix a NULL pointer dereference when create_workqueue() fails" Greg Kroah-Hartman
2021-05-24 15:25 ` [PATCH 5.10 052/104] rapidio: handle create_workqueue() failure Greg Kroah-Hartman
2021-05-24 15:25 ` [PATCH 5.10 053/104] Revert "serial: mvebu-uart: Fix to avoid a potential NULL pointer dereference" Greg Kroah-Hartman
2021-05-24 15:25 ` [PATCH 5.10 054/104] nvme-tcp: fix possible use-after-completion Greg Kroah-Hartman
2021-05-24 15:25 ` [PATCH 5.10 055/104] x86/sev-es: Move sev_es_put_ghcb() in prep for follow on patch Greg Kroah-Hartman
2021-05-24 15:25 ` [PATCH 5.10 056/104] x86/sev-es: Invalidate the GHCB after completing VMGEXIT Greg Kroah-Hartman
2021-05-24 15:25 ` [PATCH 5.10 057/104] x86/sev-es: Dont return NULL from sev_es_get_ghcb() Greg Kroah-Hartman
2021-05-24 15:25 ` [PATCH 5.10 058/104] x86/sev-es: Use __put_user()/__get_user() for data accesses Greg Kroah-Hartman
2021-05-24 15:25 ` [PATCH 5.10 059/104] x86/sev-es: Forward page-faults which happen during emulation Greg Kroah-Hartman
2021-05-24 15:25 ` [PATCH 5.10 060/104] drm/amdgpu: Fix GPU TLB update error when PAGE_SIZE > AMDGPU_PAGE_SIZE Greg Kroah-Hartman
2021-05-24 15:25 ` [PATCH 5.10 061/104] drm/amdgpu: disable 3DCGCG on picasso/raven1 to avoid compute hang Greg Kroah-Hartman
2021-05-24 15:25 ` [PATCH 5.10 062/104] drm/amdgpu: update gc golden setting for Navi12 Greg Kroah-Hartman
2021-05-24 15:25 ` [PATCH 5.10 063/104] drm/amdgpu: update sdma " Greg Kroah-Hartman
2021-05-24 15:25 ` Greg Kroah-Hartman [this message]
2021-05-24 15:26 ` [PATCH 5.10 065/104] powerpc/64s/syscall: Fix ptrace syscall info with scv syscalls Greg Kroah-Hartman
2021-05-24 15:26 ` [PATCH 5.10 066/104] mmc: sdhci-pci-gli: increase 1.8V regulator wait Greg Kroah-Hartman
2021-05-24 15:26 ` [PATCH 5.10 067/104] xen-pciback: redo VF placement in the virtual topology Greg Kroah-Hartman
2021-05-24 15:26 ` [PATCH 5.10 068/104] xen-pciback: reconfigure also from backend watch handler Greg Kroah-Hartman
2021-05-24 15:26 ` [PATCH 5.10 069/104] ipc/mqueue, msg, sem: avoid relying on a stack reference past its expiry Greg Kroah-Hartman
2021-05-24 15:26 ` [PATCH 5.10 070/104] dm snapshot: fix a crash when an origin has no snapshots Greg Kroah-Hartman
2021-05-25 11:36   ` Patch regression - " Mikulas Patocka
2021-05-25 11:52     ` Greg Kroah-Hartman
2021-05-25 11:58       ` Mikulas Patocka
2021-05-24 15:26 ` [PATCH 5.10 071/104] dm snapshot: fix crash with transient storage and zero chunk size Greg Kroah-Hartman
2021-05-24 15:26 ` [PATCH 5.10 072/104] kcsan: Fix debugfs initcall return type Greg Kroah-Hartman
2021-05-24 15:26 ` [PATCH 5.10 073/104] Revert "video: hgafb: fix potential NULL pointer dereference" Greg Kroah-Hartman
2021-05-24 15:26 ` [PATCH 5.10 074/104] Revert "net: stmicro: fix a missing check of clk_prepare" Greg Kroah-Hartman
2021-05-24 15:26 ` [PATCH 5.10 075/104] Revert "leds: lp5523: fix a missing check of return value of lp55xx_read" Greg Kroah-Hartman
2021-05-24 15:26 ` [PATCH 5.10 076/104] Revert "hwmon: (lm80) fix a missing check of bus read in lm80 probe" Greg Kroah-Hartman
2021-05-24 15:26 ` [PATCH 5.10 077/104] Revert "video: imsttfb: fix potential NULL pointer dereferences" Greg Kroah-Hartman
2021-05-24 15:26 ` [PATCH 5.10 078/104] Revert "ecryptfs: replace BUG_ON with error handling code" Greg Kroah-Hartman
2021-05-24 15:26 ` [PATCH 5.10 079/104] Revert "scsi: ufs: fix a missing check of devm_reset_control_get" Greg Kroah-Hartman
2021-05-24 15:26 ` [PATCH 5.10 080/104] Revert "gdrom: fix a memory leak bug" Greg Kroah-Hartman
2021-05-24 15:26 ` [PATCH 5.10 081/104] cdrom: gdrom: deallocate struct gdrom_unit fields in remove_gdrom Greg Kroah-Hartman
2021-05-24 15:26 ` [PATCH 5.10 082/104] cdrom: gdrom: initialize global variable at init time Greg Kroah-Hartman
2021-05-24 15:26 ` [PATCH 5.10 083/104] Revert "media: rcar_drif: fix a memory disclosure" Greg Kroah-Hartman
2021-05-24 15:26 ` [PATCH 5.10 084/104] Revert "rtlwifi: fix a potential NULL pointer dereference" Greg Kroah-Hartman
2021-05-24 15:26 ` [PATCH 5.10 085/104] Revert "qlcnic: Avoid " Greg Kroah-Hartman
2021-05-24 15:26 ` [PATCH 5.10 086/104] Revert "niu: fix missing checks of niu_pci_eeprom_read" Greg Kroah-Hartman
2021-05-24 15:26 ` [PATCH 5.10 087/104] ethernet: sun: niu: fix missing checks of niu_pci_eeprom_read() Greg Kroah-Hartman
2021-05-24 15:26 ` [PATCH 5.10 088/104] net: stmicro: handle clk_prepare() failure during init Greg Kroah-Hartman
2021-05-24 15:26 ` [PATCH 5.10 089/104] scsi: ufs: handle cleanup correctly on devm_reset_control_get error Greg Kroah-Hartman
2021-05-24 15:26 ` [PATCH 5.10 090/104] net: rtlwifi: properly check for alloc_workqueue() failure Greg Kroah-Hartman
2021-05-24 15:26 ` [PATCH 5.10 091/104] ics932s401: fix broken handling of errors when word reading fails Greg Kroah-Hartman
2021-05-24 15:26 ` [PATCH 5.10 092/104] leds: lp5523: check return value of lp5xx_read and jump to cleanup code Greg Kroah-Hartman
2021-05-24 15:26 ` [PATCH 5.10 093/104] qlcnic: Add null check after calling netdev_alloc_skb Greg Kroah-Hartman
2021-05-24 15:26 ` [PATCH 5.10 094/104] video: hgafb: fix potential NULL pointer dereference Greg Kroah-Hartman
2021-05-24 15:26 ` [PATCH 5.10 095/104] vgacon: Record video mode changes with VT_RESIZEX Greg Kroah-Hartman
2021-05-24 15:26 ` [PATCH 5.10 096/104] vt_ioctl: Revert VT_RESIZEX parameter handling removal Greg Kroah-Hartman
2021-05-24 15:26 ` [PATCH 5.10 097/104] vt: Fix character height handling with VT_RESIZEX Greg Kroah-Hartman
2021-05-24 15:26 ` [PATCH 5.10 098/104] tty: vt: always invoke vc->vc_sw->con_resize callback Greg Kroah-Hartman
2021-05-24 15:26 ` [PATCH 5.10 099/104] drm/i915/gt: Disable HiZ Raw Stall Optimization on broken gen7 Greg Kroah-Hartman
2021-05-24 15:26 ` [PATCH 5.10 100/104] openrisc: mm/init.c: remove unused memblock_region variable in map_ram() Greg Kroah-Hartman
2021-05-24 15:26 ` [PATCH 5.10 101/104] x86/Xen: swap NX determination and GDT setup on BSP Greg Kroah-Hartman
2021-05-24 15:26 ` [PATCH 5.10 102/104] nvme-multipath: fix double initialization of ANA state Greg Kroah-Hartman
2021-05-24 15:26 ` [PATCH 5.10 103/104] rtc: pcf85063: fallback to parent of_node Greg Kroah-Hartman
2021-05-24 15:26 ` [PATCH 5.10 104/104] x86/boot/compressed/64: Check SEV encryption in the 32-bit boot-path Greg Kroah-Hartman
2021-05-24 21:27 ` [PATCH 5.10 000/104] 5.10.40-rc1 review Fox Chen
2021-05-24 21:58 ` Florian Fainelli
2021-05-24 22:03 ` Shuah Khan
2021-05-25  7:22 ` Naresh Kamboju
2021-05-25 14:26 ` Sudip Mukherjee
2021-05-25 14:32 ` Pavel Machek
2021-05-25 21:26 ` Guenter Roeck
2021-05-26  1:00 ` Samuel Zou

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210524152334.971284393@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=ldv@altlinux.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mpe@ellerman.id.au \
    --cc=npiggin@gmail.com \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).