[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <yt9dzfjz6rw5.fsf@linux.ibm.com>
Date: Fri, 10 Jan 2025 08:37:46 +0100
From: Sven Schnelle <svens@...ux.ibm.com>
To: "Dmitry V. Levin" <ldv@...ace.io>
Cc: Oleg Nesterov <oleg@...hat.com>, Eugene Syromyatnikov
<evgsyr@...il.com>,
Mike Frysinger <vapier@...too.org>, Renzo Davoli
<renzo@...unibo.it>,
Davide Berardi <berardi.dav@...il.com>, strace-devel@...ts.strace.io,
Vineet Gupta <vgupta@...nel.org>,
Russell
King <linux@...linux.org.uk>,
Catalin Marinas <catalin.marinas@....com>,
Will Deacon <will@...nel.org>, Brian Cain <bcain@...cinc.com>,
Huacai
Chen <chenhuacai@...nel.org>, WANG Xuerui <kernel@...0n.name>,
Geert
Uytterhoeven <geert@...ux-m68k.org>,
Michal Simek <monstr@...str.eu>,
Thomas Bogendoerfer <tsbogend@...ha.franken.de>,
Dinh Nguyen
<dinguyen@...nel.org>, Jonas Bonn <jonas@...thpole.se>,
Stefan
Kristiansson <stefan.kristiansson@...nalahti.fi>,
Stafford Horne
<shorne@...il.com>,
"James E.J. Bottomley"
<James.Bottomley@...senPartnership.com>,
Helge Deller <deller@....de>, Michael Ellerman <mpe@...erman.id.au>,
Nicholas Piggin
<npiggin@...il.com>,
Christophe Leroy <christophe.leroy@...roup.eu>,
Naveen N Rao <naveen@...nel.org>,
Madhavan Srinivasan
<maddy@...ux.ibm.com>,
Paul Walmsley <paul.walmsley@...ive.com>,
Palmer
Dabbelt <palmer@...belt.com>,
Albert Ou <aou@...s.berkeley.edu>, Heiko
Carstens <hca@...ux.ibm.com>,
Vasily Gorbik <gor@...ux.ibm.com>,
Alexander Gordeev <agordeev@...ux.ibm.com>,
Christian Borntraeger
<borntraeger@...ux.ibm.com>,
Yoshinori Sato <ysato@...rs.sourceforge.jp>,
Rich Felker <dalias@...c.org>,
John Paul Adrian Glaubitz
<glaubitz@...sik.fu-berlin.de>,
"David S. Miller" <davem@...emloft.net>,
Andreas Larsson <andreas@...sler.com>,
Richard Weinberger
<richard@....at>,
Anton Ivanov <anton.ivanov@...bridgegreys.com>,
Johannes Berg <johannes@...solutions.net>,
Thomas Gleixner
<tglx@...utronix.de>, Ingo Molnar <mingo@...hat.com>,
Borislav Petkov
<bp@...en8.de>,
Dave Hansen <dave.hansen@...ux.intel.com>, x86@...nel.org,
"H. Peter Anvin" <hpa@...or.com>, Chris Zankel
<chris@...kel.net>,
Max Filippov <jcmvbkbc@...il.com>, Arnd Bergmann
<arnd@...db.de>,
linux-snps-arc@...ts.infradead.org, linux-kernel@...r.kernel.org,
linux-arm-kernel@...ts.infradead.org, linux-hexagon@...r.kernel.org,
loongarch@...ts.linux.dev, linux-m68k@...ts.linux-m68k.org,
linux-mips@...r.kernel.org, linux-openrisc@...r.kernel.org,
linux-parisc@...r.kernel.org, linuxppc-dev@...ts.ozlabs.org,
linux-riscv@...ts.infradead.org, linux-s390@...r.kernel.org,
linux-sh@...r.kernel.org, sparclinux@...r.kernel.org,
linux-um@...ts.infradead.org, linux-arch@...r.kernel.org
Subject: Re: [PATCH 3/6] syscall.h: introduce syscall_set_nr()
"Dmitry V. Levin" <ldv@...ace.io> writes:
> Similar to syscall_set_arguments() that complements
> syscall_get_arguments(), introduce syscall_set_nr()
> that complements syscall_get_nr().
>
> syscall_set_nr() is going to be needed along with
> syscall_set_arguments() on all HAVE_ARCH_TRACEHOOK
> architectures to implement PTRACE_SET_SYSCALL_INFO API.
>
> Signed-off-by: Dmitry V. Levin <ldv@...ace.io>
> ---
> arch/arc/include/asm/syscall.h | 6 ++++++
> arch/arm/include/asm/syscall.h | 12 ++++++++++++
> arch/arm64/include/asm/syscall.h | 7 +++++++
> arch/hexagon/include/asm/syscall.h | 7 +++++++
> arch/loongarch/include/asm/syscall.h | 7 +++++++
> arch/m68k/include/asm/syscall.h | 7 +++++++
> arch/microblaze/include/asm/syscall.h | 7 +++++++
> arch/mips/include/asm/syscall.h | 7 +++++++
> arch/nios2/include/asm/syscall.h | 5 +++++
> arch/openrisc/include/asm/syscall.h | 6 ++++++
> arch/parisc/include/asm/syscall.h | 7 +++++++
> arch/powerpc/include/asm/syscall.h | 5 +++++
> arch/riscv/include/asm/syscall.h | 7 +++++++
> arch/s390/include/asm/syscall.h | 7 +++++++
> arch/sh/include/asm/syscall_32.h | 7 +++++++
> arch/sparc/include/asm/syscall.h | 7 +++++++
> arch/um/include/asm/syscall-generic.h | 5 +++++
> arch/x86/include/asm/syscall.h | 7 +++++++
> arch/xtensa/include/asm/syscall.h | 7 +++++++
> include/asm-generic/syscall.h | 14 ++++++++++++++
> 20 files changed, 144 insertions(+)
>
> diff --git a/arch/s390/include/asm/syscall.h b/arch/s390/include/asm/syscall.h
> index b3dd883699e7..1c0e349fd5c9 100644
> --- a/arch/s390/include/asm/syscall.h
> +++ b/arch/s390/include/asm/syscall.h
> @@ -24,6 +24,13 @@ static inline long syscall_get_nr(struct task_struct *task,
> (regs->int_code & 0xffff) : -1;
> }
>
> +static inline void syscall_set_nr(struct task_struct *task,
> + struct pt_regs *regs,
> + int nr)
> +{
I think there should be a
if (!test_pt_regs_flags(regs, PIF_SYSCALL))
return;
before the modification so a user can't accidentally change int_code
when ptrace stopped in a non-syscall path.
> + regs->int_code = (regs->int_code & ~0xffff) | (nr & 0xffff);
> +}
> +
> static inline void syscall_rollback(struct task_struct *task,
> struct pt_regs *regs)
> {
Powered by blists - more mailing lists