From: Bradley Morgan <bradley.morgan@linux.dev>
To: Renzo Davoli <renzo@cs.unibo.it>, linux-kernel@vger.kernel.org
Cc: Oleg Nesterov <oleg@redhat.com>,
Andrew Morton <akpm@linux-foundation.org>,
"Dmitry V . Levin" <ldv@strace.io>,
Alexey Gladkov <legion@kernel.org>,
Eugene Syromyatnikov <evgsyr@gmail.com>,
Charlie Jenkins <thecharlesjenkins@gmail.com>,
strace-devel@lists.strace.io, linux-api@vger.kernel.org
Subject: Re: [PATCH v2] ptrace: reject out of range error values in PTRACE_SET_SYSCALL_INFO
Date: Sun, 15 Nov 2026 12:14:04 +0000 [thread overview]
Message-ID: <71963633-481A-4C74-AF99-043C0C694FB1@linux.dev> (raw)
In-Reply-To: <20261115082540.385386-1-renzo@cs.unibo.it>
On 15 November 2026 08:25:39 GMT, Renzo Davoli <renzo@cs.unibo.it> wrote:
>With is_error set, PTRACE_SET_SYSCALL_INFO passes info.exit.rval to
>syscall_set_return_value() as an "int" error without checking it: a
>positive value, or on 64-bit one outside the "int" range, turns the
>error into a success or is truncated.
>
>Reject with -ERANGE any error value outside [-MAX_ERRNO, -1].
>
>Fixes: 26bb32768fe6 ("ptrace: introduce PTRACE_SET_SYSCALL_INFO request")
CC:stable?
Reviewed-by: Bradley Morgan <bradley.morgan@linux.dev>
>Signed-off-by: Renzo Davoli <renzo@cs.unibo.it>
>---
>v2: shorter commit message and comment, dropped Assisted-by (Bradley Morgan)
>v1: https://lore.kernel.org/lkml/20261114184842.373304-1-renzo@cs.unibo.it/
>
>Tested on x86_64: rval 0, 1, 3, -4096, INT_MIN and 0x100000000 with
>is_error set are now rejected with -ERANGE; -ESRCH and -4095 still work.
I don't know why ai does these kinds of sections tbf. I think testing is
like a basic requirement, like so basic that it wouldn't need to be added
as a section
>
> kernel/ptrace.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
>diff --git a/kernel/ptrace.c b/kernel/ptrace.c
>index 3f2fe68ccb14..1ffacfcef8d4 100644
>--- a/kernel/ptrace.c
>+++ b/kernel/ptrace.c
>@@ -1111,6 +1111,10 @@ ptrace_set_syscall_info_exit(struct task_struct *child, struct pt_regs *regs,
> if (rval != info->exit.rval)
> return -ERANGE;
>
>+ /* An error must be a negative errno value. */
>+ if (info->exit.is_error && (rval < -MAX_ERRNO || rval >= 0))
>+ return -ERANGE;
>+
please consider Renzos comment and add a test case.
> if (info->exit.is_error)
> syscall_set_return_value(child, regs, rval, 0);
> else
>
>base-commit: 7e1392a42ea288d70a266f6553fe06f57f8647ea
>
--- Thanks!
next prev parent reply other threads:[~2026-11-15 12:14 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-14 18:48 [PATCH] ptrace: reject out of range error values in PTRACE_SET_SYSCALL_INFO Renzo Davoli
2026-11-15 0:51 ` Bradley Morgan
2026-11-15 8:25 ` [PATCH v2] " Renzo Davoli
2026-11-15 11:26 ` Dmitry V. Levin
2026-11-15 12:14 ` Bradley Morgan [this message]
2026-11-15 12:14 ` Bradley Morgan
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=71963633-481A-4C74-AF99-043C0C694FB1@linux.dev \
--to=bradley.morgan@linux.dev \
--cc=akpm@linux-foundation.org \
--cc=evgsyr@gmail.com \
--cc=ldv@strace.io \
--cc=legion@kernel.org \
--cc=linux-api@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=oleg@redhat.com \
--cc=renzo@cs.unibo.it \
--cc=strace-devel@lists.strace.io \
--cc=thecharlesjenkins@gmail.com \
/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.