# \[PATCH v4 1/2\] ptrace: reject out of range error values in PTRACE\_SET\_SYSCALL\_INFO

- From: Renzo Davoli \<hidden\>
- Date: 2026-11-16 13:41:10 
- List: linux-api
- Page: https://ratatoskr.run/linux-api/2026/11/17945158
- Thread: https://ratatoskr.run/linux-api/2026/11/17945156/t.md

```text
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 <redacted>
Reviewed-by: Bradley Morgan <redacted>
Signed-off-by: Renzo Davoli <redacted>
---
 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

```
