mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Sven Schnelle <svens@linux.ibm.com>
To: Heiko Carstens <hca@linux.ibm.com>
Cc: Alexander Gordeev <agordeev@linux.ibm.com>,
	Vasily Gorbik <gor@linux.ibm.com>,
	Christian Borntraeger <borntraeger@linux.ibm.com>,
	linux-kernel@vger.kernel.org, linux-s390@vger.kernel.org
Subject: Re: [PATCH] s390/ptrace: Preserve ILC when updating system call number
Date: Mon, 12 Oct 2026 08:12:06 +0200	[thread overview]
Message-ID: <yt9dcxtf30sp.fsf@linux.ibm.com> (raw)
In-Reply-To: <20261009152132.1113325-1-hca@linux.ibm.com> (Heiko Carstens's message of "Fri, 9 Oct 2026 17:21:31 +0200")

Heiko Carstens <hca@linux.ibm.com> writes:

> When an attached debugger changes gpr2 via PTRACE_POKEUSR while the
> traced process has PIF_SYSCALL set, the int_code in pt_regs is also
> updated. In case of an svc it contains the instruction length code
> (ILC), as well as the system call number.
>
> The ptrace code sets the ILC unconditionally to a value which matches the
> svc instruction. However the svc instruction also may have been executed
> via the execute or execute relative long instruction, which have a
> different length. Therefore preserve the ILC and only change the system
> call number using syscall_set_nr().
>
> This makes sure that in case of a PSW rewind the instruction address
> points to the correct instruction.
>
> Fixes: 56e62a737028 ("s390: convert to generic entry")
> Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
> ---
>  arch/s390/kernel/ptrace.c | 9 ++++-----
>  1 file changed, 4 insertions(+), 5 deletions(-)
>
> diff --git a/arch/s390/kernel/ptrace.c b/arch/s390/kernel/ptrace.c
> index 125ca4c4e30c..d8d5e843859c 100644
> --- a/arch/s390/kernel/ptrace.c
> +++ b/arch/s390/kernel/ptrace.c
> @@ -34,6 +34,7 @@
>  #include <asm/ptrace.h>
>  #include <asm/rwonce.h>
>  #include <asm/fpu.h>
> +#include <asm/syscall.h>
>  
>  #include "entry.h"
>  
> @@ -345,11 +346,9 @@ static int __poke_user(struct task_struct *child, addr_t addr, addr_t data)
>  				return -EINVAL;
>  		}
>  
> -		if (test_pt_regs_flag(regs, PIF_SYSCALL) &&
> -			addr == offsetof(struct user, regs.gprs[2])) {
> -			struct pt_regs *regs = task_pt_regs(child);
> -
> -			regs->int_code = 0x20000 | (data & 0xffff);
> +		if (addr == offsetof(struct user, regs.gprs[2])) {
> +			if (test_pt_regs_flag(regs, PIF_SYSCALL))
> +				syscall_set_nr(child, regs, data);
>  		}
>  		*(addr_t *)((addr_t) &regs->psw + addr) = data;
>  	} else if (addr < offsetof(struct user, regs.orig_gpr2)) {

Reviewed-by: Sven Schnelle <svens@linux.ibm.com>

      reply	other threads:[~2026-10-12  6:12 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-09 15:21 Heiko Carstens
2026-10-12  6:12 ` Sven Schnelle [this message]

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=yt9dcxtf30sp.fsf@linux.ibm.com \
    --to=svens@linux.ibm.com \
    --cc=agordeev@linux.ibm.com \
    --cc=borntraeger@linux.ibm.com \
    --cc=gor@linux.ibm.com \
    --cc=hca@linux.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-s390@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

all inboxes | Powered by JetHome®