From: Aurelien Jarno <aurelien@aurel32.net>
To: "Björn Töpel" <bjorn@kernel.org>
Cc: "Thomas Gleixner" <tglx@linutronix.de>,
"Celeste Liu" <coelacanthushex@gmail.com>,
"Celeste Liu via B4 Relay"
<devnull+CoelacanthusHex.gmail.com@kernel.org>,
"Paul Walmsley" <paul.walmsley@sifive.com>,
"Palmer Dabbelt" <palmer@dabbelt.com>,
"Albert Ou" <aou@eecs.berkeley.edu>,
"Björn Töpel" <bjorn@rivosinc.com>,
"Palmer Dabbelt" <palmer@rivosinc.com>,
"Alexandre Ghiti" <alex@ghiti.fr>,
"Dmitry V. Levin" <ldv@strace.io>,
"Andrea Bolognani" <abologna@redhat.com>,
"Felix Yan" <felixonmars@archlinux.org>,
"Ruizhe Pan" <c141028@gmail.com>,
"Shiqi Zhang" <shiqi@isrc.iscas.ac.cn>,
"Guo Ren" <guoren@kernel.org>, "Yao Zi" <ziyao@disroot.org>,
"Han Gao" <gaohan@iscas.ac.cn>,
linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org
Subject: Re: [PATCH] riscv/entry: get correct syscall number from syscall_get_nr()
Date: Fri, 15 Nov 2024 22:49:12 +0100 [thread overview]
Message-ID: <ZzfB2LfsD0ATjLMv@aurel32.net> (raw)
In-Reply-To: <87sesgftng.fsf@all.your.base.are.belong.to.us>
On 2024-10-28 02:45, Björn Töpel wrote:
> Thanks for helping out to dissect this! Much appreciated!
>
> Thomas Gleixner <tglx@linutronix.de> writes:
>
> > Let me look at your failure analysis from your first reply:
> >
> >> 1. strace "tracing": Requires that regs->a0 is not tampered with prior
> >> ptrace notification
> >>
> >> E.g.:
> >> | # ./strace /
> >> | execve("/", ["/"], 0x7ffffaac3890 /* 21 vars */) = -1 EACCES (Permission denied)
> >> | ./strace: exec: Permission denied
> >> | +++ exited with 1 +++
> >> | # ./disable_ptrace_get_syscall_info ./strace /
> >> | execve(0xffffffffffffffda, ["/"], 0x7fffd893ce10 /* 21 vars */) = -1 EACCES (Permission denied)
> >> | ./strace: exec: Permission denied
> >> | +++ exited with 1 +++
> >>
> >> In the second case, arg0 is prematurely set to -ENOSYS
> >> (0xffffffffffffffda).
> >
> > That's expected if ptrace_get_syscall_info() is not used. Plain dumping
> > registers will give you the current value on all architectures.
> > ptrace_get_syscall_info() exist exactly for that reason.
>
> Noted! So this shouldn't be considered as a regression. IOW, the
> existing upstream code is OK for this scenario.
Not however that it breaks some programs, for instance I arrived on this
thread by debugging python-ptrace. I'll try to look at adding support
for ptrace_get_syscall_info(), but I am afraid we will find more broken
programs.
Regards
Aurelien
[1] https://buildd.debian.org/status/fetch.php?pkg=python-ptrace&arch=riscv64&ver=0.9.9-0.1%2Bb2&stamp=1731547088&raw=0
--
Aurelien Jarno GPG: 4096R/1DDD8C9B
aurelien@aurel32.net http://aurel32.net
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
WARNING: multiple messages have this Message-ID (diff)
From: Aurelien Jarno <aurelien@aurel32.net>
To: "Björn Töpel" <bjorn@kernel.org>
Cc: "Thomas Gleixner" <tglx@linutronix.de>,
"Celeste Liu" <coelacanthushex@gmail.com>,
"Celeste Liu via B4 Relay"
<devnull+CoelacanthusHex.gmail.com@kernel.org>,
"Paul Walmsley" <paul.walmsley@sifive.com>,
"Palmer Dabbelt" <palmer@dabbelt.com>,
"Albert Ou" <aou@eecs.berkeley.edu>,
"Björn Töpel" <bjorn@rivosinc.com>,
"Palmer Dabbelt" <palmer@rivosinc.com>,
"Alexandre Ghiti" <alex@ghiti.fr>,
"Dmitry V. Levin" <ldv@strace.io>,
"Andrea Bolognani" <abologna@redhat.com>,
"Felix Yan" <felixonmars@archlinux.org>,
"Ruizhe Pan" <c141028@gmail.com>,
"Shiqi Zhang" <shiqi@isrc.iscas.ac.cn>,
"Guo Ren" <guoren@kernel.org>, "Yao Zi" <ziyao@disroot.org>,
"Han Gao" <gaohan@iscas.ac.cn>,
linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org
Subject: Re: [PATCH] riscv/entry: get correct syscall number from syscall_get_nr()
Date: Fri, 15 Nov 2024 22:49:12 +0100 [thread overview]
Message-ID: <ZzfB2LfsD0ATjLMv@aurel32.net> (raw)
In-Reply-To: <87sesgftng.fsf@all.your.base.are.belong.to.us>
On 2024-10-28 02:45, Björn Töpel wrote:
> Thanks for helping out to dissect this! Much appreciated!
>
> Thomas Gleixner <tglx@linutronix.de> writes:
>
> > Let me look at your failure analysis from your first reply:
> >
> >> 1. strace "tracing": Requires that regs->a0 is not tampered with prior
> >> ptrace notification
> >>
> >> E.g.:
> >> | # ./strace /
> >> | execve("/", ["/"], 0x7ffffaac3890 /* 21 vars */) = -1 EACCES (Permission denied)
> >> | ./strace: exec: Permission denied
> >> | +++ exited with 1 +++
> >> | # ./disable_ptrace_get_syscall_info ./strace /
> >> | execve(0xffffffffffffffda, ["/"], 0x7fffd893ce10 /* 21 vars */) = -1 EACCES (Permission denied)
> >> | ./strace: exec: Permission denied
> >> | +++ exited with 1 +++
> >>
> >> In the second case, arg0 is prematurely set to -ENOSYS
> >> (0xffffffffffffffda).
> >
> > That's expected if ptrace_get_syscall_info() is not used. Plain dumping
> > registers will give you the current value on all architectures.
> > ptrace_get_syscall_info() exist exactly for that reason.
>
> Noted! So this shouldn't be considered as a regression. IOW, the
> existing upstream code is OK for this scenario.
Not however that it breaks some programs, for instance I arrived on this
thread by debugging python-ptrace. I'll try to look at adding support
for ptrace_get_syscall_info(), but I am afraid we will find more broken
programs.
Regards
Aurelien
[1] https://buildd.debian.org/status/fetch.php?pkg=python-ptrace&arch=riscv64&ver=0.9.9-0.1%2Bb2&stamp=1731547088&raw=0
--
Aurelien Jarno GPG: 4096R/1DDD8C9B
aurelien@aurel32.net http://aurel32.net
next prev parent reply other threads:[~2024-11-15 21:50 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-16 17:49 [PATCH] riscv/entry: get correct syscall number from syscall_get_nr() Celeste Liu
2024-10-16 17:49 ` Celeste Liu via B4 Relay
2024-10-16 17:49 ` Celeste Liu via B4 Relay
2024-10-16 17:51 ` kernel test robot
2024-10-21 14:00 ` Björn Töpel
2024-10-21 14:00 ` Björn Töpel
2024-10-21 15:23 ` Celeste Liu
2024-10-21 15:23 ` Celeste Liu
2024-10-21 16:46 ` Björn Töpel
2024-10-21 16:46 ` Björn Töpel
2024-10-25 13:12 ` Thomas Gleixner
2024-10-25 13:12 ` Thomas Gleixner
2024-10-25 14:30 ` Björn Töpel
2024-10-25 14:30 ` Björn Töpel
2024-10-26 20:21 ` Thomas Gleixner
2024-10-26 20:21 ` Thomas Gleixner
2024-10-27 15:29 ` Celeste Liu
2024-10-27 15:29 ` Celeste Liu
2024-10-27 15:56 ` Thomas Gleixner
2024-10-27 15:56 ` Thomas Gleixner
2024-10-27 17:01 ` Celeste Liu
2024-10-27 17:01 ` Celeste Liu
2024-10-27 21:52 ` Thomas Gleixner
2024-10-27 21:52 ` Thomas Gleixner
2024-10-28 0:17 ` Ron Economos
2024-10-28 0:17 ` Ron Economos
2024-10-28 16:25 ` Celeste Liu
2024-10-28 16:25 ` Celeste Liu
2024-10-28 19:33 ` Björn Töpel
2024-10-28 19:33 ` Björn Töpel
2024-11-30 22:39 ` Celeste Liu
2024-11-30 22:39 ` Celeste Liu
2024-10-28 9:45 ` Björn Töpel
2024-10-28 9:45 ` Björn Töpel
2024-11-15 21:49 ` Aurelien Jarno [this message]
2024-11-15 21:49 ` Aurelien Jarno
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=ZzfB2LfsD0ATjLMv@aurel32.net \
--to=aurelien@aurel32.net \
--cc=abologna@redhat.com \
--cc=alex@ghiti.fr \
--cc=aou@eecs.berkeley.edu \
--cc=bjorn@kernel.org \
--cc=bjorn@rivosinc.com \
--cc=c141028@gmail.com \
--cc=coelacanthushex@gmail.com \
--cc=devnull+CoelacanthusHex.gmail.com@kernel.org \
--cc=felixonmars@archlinux.org \
--cc=gaohan@iscas.ac.cn \
--cc=guoren@kernel.org \
--cc=ldv@strace.io \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=palmer@dabbelt.com \
--cc=palmer@rivosinc.com \
--cc=paul.walmsley@sifive.com \
--cc=shiqi@isrc.iscas.ac.cn \
--cc=stable@vger.kernel.org \
--cc=tglx@linutronix.de \
--cc=ziyao@disroot.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.