[PATCH v4 0/2] ptrace: reject out of range error values in PTRACE_SET_SYSCALL_INFO

Renzo Davoli posted 2 patches 6 days, 20 hours ago
kernel/ptrace.c                               |  4 ++
.../selftests/ptrace/set_syscall_info.c       | 51 +++++++++++++++++++
2 files changed, 55 insertions(+)
[PATCH v4 0/2] ptrace: reject out of range error values in PTRACE_SET_SYSCALL_INFO
Posted by Renzo Davoli 6 days, 20 hours ago
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.

Patch 1 rejects with -ERANGE any error value outside [-MAX_ERRNO, -1].
Patch 2 adds a test case for this to the set_syscall_info selftest.

This series is independent of the PTRACE_SET_SYSCALL_INFO seccomp skip
and SET_IP series: they apply on top of each other in either order.

Testing (x86_64, QEMU): tools/testing/selftests/ptrace/set_syscall_info
passes 1/1 with this series applied.

Changes in v4:
* patch 1: use !IS_ERR_VALUE(rval) instead of open-coding the range
  check, no functional change. Thanks to Oleg Nesterov for the
  suggestion.
* rebased on current mainline (23c62304dde2)
* added Reviewed-by of Bradley Morgan to patch 2

Changes in v3:
* added Reviewed-by of Dmitry V. Levin and Bradley Morgan to patch 1
* new patch 2: selftest, as suggested by Dmitry V. Levin

Changes in v2:
* shorter commit message and comment, dropped Assisted-by
  (Bradley Morgan)

v3: https://lore.kernel.org/lkml/20261115152703.416254-1-renzo@cs.unibo.it/
v2: https://lore.kernel.org/lkml/20261115082540.385386-1-renzo@cs.unibo.it/
v1: https://lore.kernel.org/lkml/20261114184842.373304-1-renzo@cs.unibo.it/

Renzo Davoli (2):
  ptrace: reject out of range error values in PTRACE_SET_SYSCALL_INFO
  selftests/ptrace: check that PTRACE_SET_SYSCALL_INFO rejects invalid
    error values

 kernel/ptrace.c                               |  4 ++
 .../selftests/ptrace/set_syscall_info.c       | 51 +++++++++++++++++++
 2 files changed, 55 insertions(+)


base-commit: 23c62304dde29abe92013d85910d03a77dada35d
-- 
2.47.3