From: Renzo Davoli <renzo@cs.unibo.it>
To: linux-kernel@vger.kernel.org
Cc: Renzo Davoli <renzo@cs.unibo.it>, 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>,
Bradley Morgan <bradley.morgan@linux.dev>,
Shuah Khan <shuah@kernel.org>,
strace-devel@lists.strace.io, linux-api@vger.kernel.org,
linux-kselftest@vger.kernel.org
Subject: [PATCH v4 1/2] ptrace: reject out of range error values in PTRACE_SET_SYSCALL_INFO
Date: Mon, 16 Nov 2026 14:40:45 +0100 [thread overview]
Message-ID: <20261116134050.505355-2-renzo@cs.unibo.it> (raw)
In-Reply-To: <20261116134050.505355-1-renzo@cs.unibo.it>
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")
Reviewed-by: Dmitry V. Levin <ldv@strace.io>
Reviewed-by: Bradley Morgan <bradley.morgan@linux.dev>
Signed-off-by: Renzo Davoli <renzo@cs.unibo.it>
---
kernel/ptrace.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/kernel/ptrace.c b/kernel/ptrace.c
index 3f2fe68ccb14..7d51cb60c091 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 && !IS_ERR_VALUE(rval))
+ return -ERANGE;
+
if (info->exit.is_error)
syscall_set_return_value(child, regs, rval, 0);
else
--
2.47.3
next prev parent reply other threads:[~2026-11-16 13:41 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-16 13:40 [PATCH v4 0/2] ptrace: reject out of range error values in PTRACE_SET_SYSCALL_INFO Renzo Davoli
2026-11-16 13:40 ` Renzo Davoli [this message]
2026-11-16 14:03 ` [PATCH v4 1/2] " Oleg Nesterov
2026-11-16 13:40 ` [PATCH v4 2/2] selftests/ptrace: check that PTRACE_SET_SYSCALL_INFO rejects invalid error values Renzo Davoli
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=20261116134050.505355-2-renzo@cs.unibo.it \
--to=renzo@cs.unibo.it \
--cc=akpm@linux-foundation.org \
--cc=bradley.morgan@linux.dev \
--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=linux-kselftest@vger.kernel.org \
--cc=oleg@redhat.com \
--cc=shuah@kernel.org \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox