lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Tue, 10 May 2022 15:12:02 +0100
From:   Francis Laniel <flaniel@...ux.microsoft.com>
To:     Will Deacon <will@...nel.org>
Cc:     linux-arm-kernel@...ts.infradead.org,
        linux-trace-devel@...r.kernel.org,
        Catalin Marinas <catalin.marinas@....com>,
        Mark Brown <broonie@...nel.org>,
        Peter Collingbourne <pcc@...gle.com>,
        Mark Rutland <mark.rutland@....com>,
        Kees Cook <keescook@...omium.org>,
        Daniel Kiss <daniel.kiss@....com>, linux-kernel@...r.kernel.org
Subject: Re: [RFC PATCH v1 1/1] arm64: Forget syscall if different from execve*()

Le mardi 10 mai 2022, 15:03:33 BST Will Deacon a écrit :
> On Tue, May 10, 2022 at 03:00:11PM +0100, Francis Laniel wrote:
> > Le mardi 10 mai 2022, 11:59:48 BST Will Deacon a écrit :
> > > On Mon, May 09, 2022 at 04:19:57PM +0100, Francis Laniel wrote:
> > > > diff --git a/arch/arm64/include/asm/processor.h
> > > > b/arch/arm64/include/asm/processor.h index 73e38d9a540c..e12ceb363d6a
> > > > 100644
> > > > --- a/arch/arm64/include/asm/processor.h
> > > > +++ b/arch/arm64/include/asm/processor.h
> > > > @@ -34,6 +34,8 @@
> > > > 
> > > >  #include <vdso/processor.h>
> > > > 
> > > > +#include <asm-generic/unistd.h>
> > > > +
> > > > 
> > > >  #include <asm/alternative.h>
> > > >  #include <asm/cpufeature.h>
> > > >  #include <asm/hw_breakpoint.h>
> > > > 
> > > > @@ -250,8 +252,12 @@ void tls_preserve_current_state(void);
> > > > 
> > > >  static inline void start_thread_common(struct pt_regs *regs, unsigned
> > > >  long pc) {
> > > > 
> > > > +	s32 previous_syscall = regs->syscallno;
> > > > 
> > > >  	memset(regs, 0, sizeof(*regs));
> > > > 
> > > > -	forget_syscall(regs);
> > > > +	if (previous_syscall == __NR_execve || previous_syscall ==
> > > > __NR_execveat)
> > > > +		regs->syscallno = previous_syscall;
> > > > +	else
> > > > +		forget_syscall(regs);
> > > 
> > > Hmm, this really looks like a bodge and it doesn't handle the compat
> > > case
> > > either.
> > > 
> > > How do other architectures handle this?
> > 
> > My understanding of others architectures is quite limited, but here are my
> > findings and understanding of some of them:
> > * arm (32 bits) EABI: start_thread() sets r7 to previous r7 for ELF FDPIC 
> > and to 0 for other binfmts [1].
> > * arm (32 bits) OABI: syscall number is set to -1 if
> > ptrace_report_syscall_entry() failed [2].
> > * mips: start_thread() does not modify current_thread_info->syscall which
> > is taken directly from v0 [3, 4].
> > * riscv: start_thread() does not modify a7 [5].
> > * x86_64: start_thread_common() does not touch orig_ax which seems to
> > contain the syscall number [6].
> 
> Hmm, so the million dollar question is why on Earth we have that
> forget_syscall() call to start with. Amusingly I've, err, forgotten;
> forget_forget_syscall() perhaps?

I think this is maybe tied to this comment [1]:
The de-facto standard way to skip a system call using ptrace 
is to set the system call to -1 (NO_SYSCALL)

But I will let the original author explain as his/her explaination will be 
better than mine.

> Catalin? It's been there since day one afaict.
> 
> Will

---
[1] https://elixir.bootlin.com/linux/v5.18-rc6/source/arch/arm64/kernel/
syscall.c#L121


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ