mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Mukesh Kumar Chaurasiya <mkchauras@gmail.com>
To: Renzo Davoli <renzo@cs.unibo.it>
Cc: "Madhavan Srinivasan" <maddy@linux.ibm.com>,
	"Michael Ellerman" <mpe@ellerman.id.au>,
	"Nicholas Piggin" <npiggin@gmail.com>,
	"Christophe Leroy" <chleroy@kernel.org>,
	"Ritesh Harjani" <ritesh.list@gmail.com>,
	"Michal Suchánek" <msuchanek@suse.de>,
	"Shrikanth Hegde" <sshegde@linux.ibm.com>,
	"Thomas Gleixner" <tglx@kernel.org>,
	"Oleg Nesterov" <oleg@redhat.com>,
	"Dmitry V . Levin" <ldv@strace.io>,
	"Thomas Bogendoerfer" <tsbogend@alpha.franken.de>,
	"Andrew Morton" <akpm@linux-foundation.org>,
	linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org,
	stable@vger.kernel.org
Subject: Re: [PATCH v3 1/2] powerpc/syscall: Remove TIF_SYSCALL_RET
Date: Tue, 1 Dec 2026 23:45:47 +0530	[thread overview]
Message-ID: <aw8Oo7pyPGECQFNl@li-1a3e774c-28e4-11b2-a85c-acc9f2883e29.ibm.com> (raw)
In-Reply-To: <20261030084926.1068384-2-renzo@cs.unibo.it>

On Fri, Oct 30, 2026 at 09:49:24AM +0100, Renzo Davoli wrote:
> Commit 69cb2be898be ("powerpc/syscall: Fix syscall skip handling for
> seccomp and ptrace") added TIF_SYSCALL_RET, set by
> syscall_set_return_value(), so that system_call_exception() skips a
> system call whose return value has already been set.
> 
> The flag is set with set_thread_flag(), i.e. on current rather than on
> the task passed to syscall_set_return_value().  When the caller is a
> tracer, as with PTRACE_SET_SYSCALL_INFO and op ==
> PTRACE_SYSCALL_INFO_EXIT, the flag ends up on the tracer, and the next
> system call of the tracer is silently not executed.  Setting it on the
> right task would not be enough either: at a syscall-exit stop the flag
> would then skip the next system call of the tracee.
> 
> The flag is not needed anymore.  Commit 05c033db7e9a ("entry, treewide:
> Make syscall_enter_from_user_mode[_work]() indicate syscall execution")
> made syscall_enter_from_user_mode_randomize_stack() return false when
> ptrace or seccomp skip the system call, and every in-kernel caller of
> syscall_set_return_value() on the syscall entry path (SECCOMP_RET_ERRNO,
> SECCOMP_RET_TRACE without a tracer, SECCOMP_RET_USER_NOTIF) also makes
> it return false.  A system call with an invalid number, including
> syscall(-1), still gets -ENOSYS.
> 
> Remove the flag.
> 
Yeah it's not needed anymore.

Reviewed-by: Mukesh Kumar Chaurasiya (IBM) <mkchauras@gmail.com>
> Fixes: 69cb2be898be ("powerpc/syscall: Fix syscall skip handling for seccomp and ptrace")
> Cc: stable@vger.kernel.org # v7.3
> Suggested-by: Michal Suchánek <msuchanek@suse.de>
> Assisted-by: claude-opus-5-5
> Signed-off-by: Renzo Davoli <renzo@cs.unibo.it>
> ---
>  arch/powerpc/include/asm/syscall.h     | 6 ------
>  arch/powerpc/include/asm/thread_info.h | 1 -
>  arch/powerpc/kernel/syscall.c          | 4 +---
>  3 files changed, 1 insertion(+), 10 deletions(-)
> 
> diff --git a/arch/powerpc/include/asm/syscall.h b/arch/powerpc/include/asm/syscall.h
> index 32be22b995cc..4b3c52ed6e9d 100644
> --- a/arch/powerpc/include/asm/syscall.h
> +++ b/arch/powerpc/include/asm/syscall.h
> @@ -98,12 +98,6 @@ static inline void syscall_set_return_value(struct task_struct *task,
>  			regs->gpr[3] = val;
>  		}
>  	}
> -	/*
> -	 * Mark that a return value has been explicitly set by seccomp or
> -	 * ptrace so that system_call_exception() can skip the syscall
> -	 * unconditionally, even when the user requested syscall(-1).
> -	 */
> -	set_thread_flag(TIF_SYSCALL_RET);
>  }
>  
>  static inline void syscall_get_arguments(struct task_struct *task,
> diff --git a/arch/powerpc/include/asm/thread_info.h b/arch/powerpc/include/asm/thread_info.h
> index 1e069a2e7ce8..0487e94d3416 100644
> --- a/arch/powerpc/include/asm/thread_info.h
> +++ b/arch/powerpc/include/asm/thread_info.h
> @@ -120,7 +120,6 @@ void arch_setup_new_exec(void);
>  #endif
>  #define TIF_POLLING_NRFLAG	19	/* true if poll_idle() is polling TIF_NEED_RESCHED */
>  #define TIF_32BIT		20	/* 32 bit binary */
> -#define TIF_SYSCALL_RET		21	/* syscall error value set */
>  
>  /* as above, but as bit values */
>  #define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
> diff --git a/arch/powerpc/kernel/syscall.c b/arch/powerpc/kernel/syscall.c
> index 8529827d697f..f7412556a9e8 100644
> --- a/arch/powerpc/kernel/syscall.c
> +++ b/arch/powerpc/kernel/syscall.c
> @@ -18,9 +18,7 @@ notrace long system_call_exception(struct pt_regs *regs, unsigned long r0)
>  	long ret;
>  	syscall_fn f;
>  
> -	if (unlikely(!syscall_enter_from_user_mode_randomize_stack(regs, &r0) ||
> -			test_thread_flag(TIF_SYSCALL_RET))) {
> -		clear_thread_flag(TIF_SYSCALL_RET);
> +	if (unlikely(!syscall_enter_from_user_mode_randomize_stack(regs, &r0))) {
>  		return syscall_get_error(current, regs);
>  	}
>  
> -- 
> 2.55.0
> 

  reply	other threads:[~2026-12-01 18:15 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-30  8:49 [PATCH v3 0/2] powerpc/syscall: Fix the return value of skipped syscalls Renzo Davoli
2026-10-30  8:49 ` [PATCH v3 1/2] powerpc/syscall: Remove TIF_SYSCALL_RET Renzo Davoli
2026-12-01 18:15   ` Mukesh Kumar Chaurasiya [this message]
2026-10-30  8:49 ` [PATCH v3 2/2] powerpc/syscall: Return the preset value of skipped syscalls Renzo Davoli
2026-12-01 18:16   ` Mukesh Kumar Chaurasiya
2026-11-19 10:34 ` [PATCH v3 0/2] powerpc/syscall: Fix the return " Renzo Davoli
2026-12-02  5:20 ` Athira Rajeev

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=aw8Oo7pyPGECQFNl@li-1a3e774c-28e4-11b2-a85c-acc9f2883e29.ibm.com \
    --to=mkchauras@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=chleroy@kernel.org \
    --cc=ldv@strace.io \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=maddy@linux.ibm.com \
    --cc=mpe@ellerman.id.au \
    --cc=msuchanek@suse.de \
    --cc=npiggin@gmail.com \
    --cc=oleg@redhat.com \
    --cc=renzo@cs.unibo.it \
    --cc=ritesh.list@gmail.com \
    --cc=sshegde@linux.ibm.com \
    --cc=stable@vger.kernel.org \
    --cc=tglx@kernel.org \
    --cc=tsbogend@alpha.franken.de \
    /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®